public function getFields() { if (!$this->fields) { $results = MapDB::propertiesForFeature($this); foreach ($results as $row) { $this->fields[$row['property_name']] = $row['property_value']; } } return $this->fields; }
protected function parseData($data, DataParser $parser = null) { $items = null; if ($this->cacheIsFresh() && $this->hasDBData) { $items = $this->dbParser->getCategory()->getListItems(); } if (!$items) { $items = parent::parseData($data, $parser); $projection = $this->getProjection(); $category = $this->dbParser->getCategory(); $category->setTitle($this->getTitle()); $category->setSubtitle($this->getSubtitle()); MapDB::updateCategory($category, $items, $projection); //$items = $category->getListItems(); $this->hasDBData = true; } return $items; }
public function getListItems() { if ($this->childCategories) { return $this->childCategories; } else { if ($this->features) { return $this->features; } } // no data in memory, check db $this->childCategories = MapDB::childrenForCategory($this->id); if ($this->childCategories) { return $this->childCategories; } $this->features = MapDB::featuresForCategory($this->id); if ($this->features) { return $this->features; } return array(); }
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; }
public function getFeatureById($featureId, $possibleCategories = array()) { $possibleCategories[] = $this->categoryId; return MapDB::getFeatureByIdAndCategory($featureId, $possibleCategories); }
public static function connection() { if (self::$db === null) { // TODO: get other db config values self::$db = SiteDB::connection(); self::createTables(); } return self::$db; }