Ejemplo n.º 1
0
 private function getSearchResultsForQuery($sql, $params, $maxItems = 0)
 {
     $result = MapDB::connection()->query($sql, $params);
     $displayableCategories = MapDB::getAllCategoryIds();
     // eliminate dupe placemarks if they appear in multiple categories
     $this->resultCount = 0;
     $uniqueResults = array();
     while (($row = $result->fetch()) && (!$maxItems || $this->resultCount <= $maxItems)) {
         if (in_array($row['category_id'], $displayableCategories)) {
             $ukey = $row['placemark_id'] . $row['lat'] . $row['lon'];
             if (isset($uniqueResults[$ukey])) {
                 $uniqueResults[$ukey]->addCategoryId($row['category_id']);
             } else {
                 $placemark = new MapDBPlacemark($row, true);
                 $placemark->addCategoryId($row['category_id']);
                 $uniqueResults[$ukey] = $placemark;
                 $this->resultCount++;
             }
         }
     }
     $this->searchResults = array_values($uniqueResults);
     return $this->searchResults;
 }
Ejemplo n.º 2
0
 public static function propertiesForFeature(MapDBPlacemark $feature)
 {
     $sql = 'SELECT property_name, property_value FROM ' . self::PLACEMARK_PROPERTIES_TABLE . ' WHERE placemark_id = ? AND lat = ? AND lon = ?';
     $center = $feature->getGeometry()->getCenterCoordinate();
     $params = array($feature->getId(), $center['lat'], $center['lon']);
     $results = self::connection()->query($sql, $params);
     if ($results) {
         return $results->fetchAll();
     }
     return array();
 }