Ejemplo n.º 1
0
 /**
  * Set an option
  *
  * XMLPOIConnector supports one option, "stylesheet"
  *
  * @param string $optionName
  * @param string $optionValue
  *
  * @return void
  */
 public function setOption($optionName, $optionValue)
 {
     switch ($optionName) {
         case "stylesheet":
             $this->setStyleSheet($optionValue);
             break;
         default:
             parent::setOption($optionName, $optionValue);
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * Determines nearby POIs and stores them for later use
  *
  * @param Filter $filter
  *
  * @return int number of POIs
  */
 public function determineNearbyPOIs(Filter $filter)
 {
     if (isset($filter->pageKey)) {
         $offset = $filter->pageKey * self::POIS_PER_PAGE;
     } else {
         $offset = 0;
     }
     if (($offset == 0 || !$this->session_restore($filter->userID)) && !empty($this->poiConnector)) {
         $this->response = $this->poiConnector->getLayarResponse($filter);
         $pois = $this->response->hotspots;
         foreach ($pois as $poi) {
             if ($poi->distance > $this->response->radius) {
                 $this->response->radius = $poi->distance;
             }
             // fix a scaling bug in the iPhone 5.0.2
             if (!empty($filter->userAgent) && strpos($filter->userAgent, "Layar/5.0.2 iPhoneOS") !== FALSE) {
                 if ($poi->dimension == 3) {
                     if (!empty($poi->transform->scale) && !empty($poi->object->size)) {
                         $poi->transform->scale = $poi->transform->scale / $poi->object->size;
                     }
                 }
             }
         }
         $this->session_save($filter->userID);
     }
     // iterate over POIs and determine max distance
     // TODO: do something sensible with this
     // Current implementation adds all POIs in the order they are
     // retrieved, while according to the spec max 50 POIs are displayed.
     // So limit POIs to max. 50, optionally after sorting by distance.
     // Maybe make the sorting order a config setting
     //
     // JdS 2010-07-08
     // --- 8< ---
     // ordering is done by POIConnectors using the most
     // efficient technique available for the specific data source
     //
     // Propose to let POI cutoff be determined by client, not enforce
     // 50 POI maximum in server
     // --- >8 ---
     //
     // JdS 2010-07-08
     // --- 8< ---
     // TODO: rewrite the last part of this method. We're cutting in the
     // object's response->hotspots for the final response. This works
     // because the complete set has already been saved in the session a
     // few lines before, but this approach is a bit murky. However, other
     // parts of PorPOISe rely on getNearbyPOIs to return only the POIs
     // for the current page so if we're gonna separate the POI sets for
     // the current page and the overall request we need to fix some more
     // lines than just the next 10 or so
     // --- >8 ---
     $this->hasMorePOIs = FALSE;
     $this->nextPageKey = NULL;
     $numPois = count($this->response->hotspots);
     if ($numPois - $offset > self::POIS_PER_PAGE) {
         $this->response->morePages = TRUE;
         $this->response->nextPageKey = $offset / self::POIS_PER_PAGE + 1;
     }
     if ($offset > $numPois) {
         // no POIs on this page
         $this->response->hotspots = array();
     } else {
         $limit = min(self::POIS_PER_PAGE, $numPois - $offset);
         $this->response->hotspots = array_slice($this->response->hotspots, $offset, $limit);
     }
     if (!$this->hasMorePOIs) {
         $this->session_delete($filter->userID);
     }
     return $numPois;
 }