public function getEntities()
 {
     REST::requireRequestMethod('GET');
     $db = new MySQL();
     $entitiesNode = new XMLNode('entities');
     foreach (Model::getEntities() as $entity) {
         $entityNode = new XMLNode('entity');
         $entityNode->setAttribute('identifier', $entity['IDENTIFIER']);
         $entityNode->setAttribute('friendlyname', $entity['FRIENDLYNAME']);
         $entityNode->setAttribute('lat', $entity['LATITUDE']);
         $entityNode->setAttribute('lon', $entity['LONGITUDE']);
         $entityNode->setAttribute('date', strtotime($entity['DATETIME']));
         $entitiesNode->addNode($entityNode);
     }
     $xmlDoc = new XMLDocument();
     $xmlDoc->setRootNode($entitiesNode);
     REST::sendResponse(200, $xmlDoc, 'application/xml');
 }
 public function getTileUrl()
 {
     REST::requireRequestMethod('GET');
     $requiredParameters = array('lat', 'lon', 'zoom');
     if (Util::isValid($requiredParameters, $values, $this->params)) {
         extract($values);
         $url = "http://tile.openstreetmap.org/" . Map::getTileNumber($lat, $lon, $zoom) . ".png";
         $urlNode = new XMLNode('url');
         $urlNode->setAttribute('href', $url);
         $mapNode = new XMLNode('map');
         $mapNode->setAttributes($values);
         $mapNode->addNode($urlNode);
         $xmlDoc = new XMLDocument();
         $xmlDoc->setRootNode($mapNode);
         REST::sendResponse(200, $xmlDoc, 'application/xml');
     } else {
         REST::sendResponse(400);
     }
 }
 public function getZones()
 {
     REST::requireRequestMethod('GET');
     $zonesNode = new XMLNode('zones');
     foreach (Model::getZones() as $zone) {
         $zoneNode = new XMLNode('zone');
         $zoneNode->setAttribute('id', $zone['ID']);
         $zoneNode->setAttribute('type', $zone['TYPE']);
         $zoneNode->setAttribute('date', strtotime($zone['CREATED_ON']));
         $zoneNode->setAttribute('deleted', $zone['DELETED_ON'] != '0000-00-00 00:00:00' ? 'true' : 'false');
         $waypointsNode = new XMLNode('waypoints');
         foreach (Model::getWaypoints($zone['ID']) as $waypoint) {
             $waypointNode = new XMLNode('waypoint');
             $waypointNode->setAttribute('latitude', $waypoint['LATITUDE']);
             $waypointNode->setAttribute('longitude', $waypoint['LONGITUDE']);
             $waypointsNode->addNode($waypointNode);
         }
         $zoneNode->addNode($waypointsNode);
         $zonesNode->addNode($zoneNode);
     }
     $xmlDoc = new XMLDocument();
     $xmlDoc->setRootNode($zonesNode);
     REST::sendResponse(200, $xmlDoc, 'application/xml');
 }