Пример #1
0
 function checkLocation($serverID, $locationArray, $bounds)
 {
     //  print_r($locationArray);
     // find nearest waypoint in local db
     list($nearestTakeoffID, $nearestDistance) = findNearestWaypoint($bounds['firstLat'], $bounds['firstLon']);
     // echo "nearest takeoff :  $nearestTakeoffID,$nearestDistance <BR>";
     if ($nearestDistance < $locationArray['takeoffVinicity'] + 500) {
         // we will use our waypoint if our local waypoint is nearest  ( + 500m margin )
         return array($nearestTakeoffID, $nearestDistance);
     } else {
         // we will import this takeoff and use that instead
         $newWaypoint = new waypoint();
         $newWaypoint->setLat($locationArray['takeoffLat']);
         $newWaypoint->setLon($locationArray['takeoffLon']);
         $newWaypoint->name = $locationArray['takeoffName'];
         $newWaypoint->type = 1000;
         // takeoff
         $newWaypoint->intName = $locationArray['takeoffNameInt'];
         $newWaypoint->location = $locationArray['takeoffLocation'];
         $newWaypoint->intLocation = $locationArray['takeoffLocationInt'];
         $newWaypoint->countryCode = $locationArray['takeoffCountry'];
         $newWaypoint->link = '';
         $newWaypoint->description = '';
         $newWaypoint->putToDB(0);
         // also add it up to $waypoints because we use this array for subsequent queries
         global $waypoints;
         array_push($waypoints, $newWaypoint);
         return array($newWaypoint->waypointID, $locationArray['takeoffVinicity']);
     }
 }