Ola pessoal !
Sou novato em desenvolvimento com PHP 5 e MySQL , estou fazendo uma classe para pegar dados de arquivos XML e GPS. Meu codigo-fonte este :
<?php class Route { var $points; //array with points var $lats; //array with latitudes var $maxlat; var $minlat; var $lngs; //array with longitudes var $maxlng; var $minlng; var $alts; //array with elevations var $maxalt; var $minalt; var $n; var $dist; //total distance in metres var $drop; //total drop in metres var $time; //time the route spent in secconds var $hours; var $minutes; function fromPoints($points) { $this->n = count($points); for($i = 0; $i < $this->n; $i++) { $this->lats[$i] = $points[$i]->lat; $this->lngs[$i] = $points[$i]->lng; $this->alts[$i] = $points[$i]->alt; } //max and min $this->maxlat = max($this->lats); $this->maxlng = max($this->lngs); $this->maxalt = max($this->alts); $this->minlat = min($this->lats); $this->minlng = min($this->lngs); $this->minalt = min($this->alts); $this->drop = $this->getDrop($points); $this->dist = $this->getTotalDistance($this->lats,$this->lngs,$this->alts); $this->time = $points[($this->n-1)]->time - $points[0]->time; $this->hours = floor($this->time / 3600); $this->minutes = floor(($this->time - 3600 * $this->hours) / 60); } function getDrop($points) // returns total drop in { $n = count($points); $drop = 0; for($i = 1; $i < $n; $i++) { if($points[$i]->alt > $points[($i-1)]->alt) $drop += round($points[$i]->alt - $points[($i-1)]->alt); } return $drop; } function distAB($lat1,$lng1,$alt1,$lat2,$lng2,$alt2) { //returns the distance in metres between two points $distKM = 6371000 * acos(cos(deg2rad($lat1))*cos(deg2rad($lat2))*cos(deg2rad($lng2)-deg2rad($lng1))+sin(deg2rad($lat1))*sin(deg2rad($lat2))); $dist = sqrt(pow($distKM,2)+pow(($alt1-$alt2),2)); return $dist; } function getTotalDistance($lats,$lngs,$alts) { //returns total distance in meters $step = 1; $total = count($lats); $a = $b = $c = 0; //this algorithm takes the max and the min difference distances, to calculate a pitagoric distance at the end for($i = $step; $i < $total; $i += $step) { $latn = abs($lats[$i]-$lats[$i-$step]); $lngn = abs($lngs[$i]-$lngs[$i-$step]); $a += max($latn,$lngn); $b += min($latn,$lngn); $c += abs($alts[$i]-$alts[$i-$step]); } return $this->distAB(0,0,0,$a,$b,$c); } } ?>
A página que utiliza esta classe roda neste url --
http://trekhotel.com.../index.php?r=46
No entanto o php retorna estes warnings :
Warning: Wrong parameter count for max() in /home/trekhote/public_html/bina/core/georoute.class.php on line 41 Warning: Wrong parameter count for max() in /home/trekhote/public_html/bina/core/georoute.class.php on line 42 Warning: Wrong parameter count for max() in /home/trekhote/public_html/bina/core/georoute.class.php on line 43 Warning: Wrong parameter count for min() in /home/trekhote/public_html/bina/core/georoute.class.php on line 44 Warning: Wrong parameter count for min() in /home/trekhote/public_html/bina/core/georoute.class.php on line 45 Warning: Wrong parameter count for min() in /home/trekhote/public_html/bina/core/georoute.class.php on line 46
As funções max() e min() não aceitam os arrays , por que ?
Obrigado por qualquer sugestão .
Djalma Bina.