protected function addPlacemark(Placemark $placemark) { $categoryIds = $this->getIdStack(); foreach ($categoryIds as $id) { $placemark->addCategoryId($id); } $placemark->setId(count($this->placemarks)); $this->placemarks[] = $placemark; }
public function addPlacemark(Placemark $placemark) { $categoryIds = array($this->id); $currentFolder = $this; while ($parent = $currentFolder->getParent()) { array_unshift($categoryIds, $parent->getId()); $currentFolder = $parent; } foreach ($categoryIds as $id) { $placemark->addCategoryId($id); } $this->placemarks[] = $placemark; }
function __construct($id = NULL, $name = NULL, $color = NULL, $lon = NULL, $lat = NULL, $height = NULL, $flag) { $RADIAN = 180 / pi(); $this->id = is_null($id) ? "No ID" : $id; $this->name = is_null($name) ? "Unnamed" : $name . ": " . $height; $this->color = is_null($color) ? generateRandomColor() : $color; //$this->lat = (is_null($lat)?"43.65".strval(rand(00,99)):$lat/$RADIAN); //$this->lon = (is_null($lon)?"-79.37".strval(rand(00,99)):$lon/$RADIAN); $this->lat = $lat / $RADIAN; $this->lon = $lon / $RADIAN; //$this->height = (is_null($height)?rand(50,399):$height*5.0); $this->height = $height * 9; if ($flag == 0) { $this->name = is_null($name) ? "Unnamed" : $name . ": " . $height; } else { if ($flag == 1) { $this->name = is_null($name) ? "Unnamed" : $name . ", Rank: " . self::$rankOfTrend; self::$rankOfTrend = self::$rankOfTrend + 1; } } //Values for coordinates forumla $points = 45; $EARTH_RADIUS_EQUATOR = 6378140.0; $RADIAN = 180 / pi(); $f = 1 / 298.257; $e = 0.08181922; $distance = 100; for ($bearing = 45; $bearing <= 405; $bearing += 360 / $points) { $b = $bearing / $RADIAN; $R = $EARTH_RADIUS_EQUATOR * (1 - $e * $e) / pow(1 - $e * $e * pow(sin($this->lat), 2), 1.5); $psi = $distance / $R; $phi = pi() / 2 - $this->lat; $arccos = cos($psi) * cos($phi) + sin($psi) * sin($phi) * cos($b); $latA = (pi() / 2 - acos($arccos)) * $RADIAN; $arcsin = sin($b) * sin($psi) / sin($phi); $longA = ($this->lon - asin($arcsin)) * $RADIAN; $this->coordinates .= " " . round($longA, $this->coordDecimals) . "," . round($latA, $this->coordDecimals); if ($this->height) { $this->coordinates .= "," . $this->height; } } $this->midCoordinate = "\n\t\t" . $this->lon * $RADIAN . "," . $this->lat * $RADIAN . "," . ($this->height + 80); /* $this->coordinates = "\n\t\t" . $this->lon . "," . $this->lat . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 2, 4) . "," . bcadd($this->lat, $this->LENGTH_OF_BLOCK * 2 , 4) . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 4 , 4) . "," . bcadd($this->lat, $this->LENGTH_OF_BLOCK * 2 , 4) . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 6 , 4) . "," . $this->lat . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 6 , 4) . "," . bcadd($this->lat, $this->mLENGTH_OF_BLOCK * 2 , 4) . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 4 , 4) . "," . bcadd($this->lat, $this->mLENGTH_OF_BLOCK * 4 , 4) . "," . $this->height . "\n\t\t" . bcadd($this->lon, $this->LENGTH_OF_BLOCK * 2 , 4) . "," . bcadd($this->lat, $this->mLENGTH_OF_BLOCK * 4 , 4) . "," . $this->height . "\n\t\t" . $this->lon . "," . bcadd($this->lat, $this->mLENGTH_OF_BLOCK * 2, 4) . "," . $this->height . "\n\t\t" . $this->lon . "," . $this->lat . "," . $this->height; */ }
protected function shortArrayFromPlacemark(Placemark $placemark) { $result = array('title' => $placemark->getTitle(), 'subtitle' => $placemark->getSubtitle(), 'id' => $placemark->getId(), 'categories' => $placemark->getCategoryIds()); $geometry = $placemark->getGeometry(); if ($geometry) { $center = $geometry->getCenterCoordinate(); $result['lat'] = $center['lat']; $result['lon'] = $center['lon']; } return $result; }
protected function shortArrayFromPlacemark(Placemark $placemark) { $result = array('title' => $placemark->getTitle(), 'subtitle' => $placemark->getSubtitle(), 'id' => $placemark->getId(), 'categories' => $placemark->getCategoryIds(), 'url' => $this->urlForPlacemark($placemark)); $geometry = $placemark->getGeometry(); if ($geometry) { $center = $geometry->getCenterCoordinate(); if (isset($this->mapProjector)) { $center = $this->mapProjector->projectPoint($center); } $result['lat'] = $center['lat']; $result['lon'] = $center['lon']; } return $result; }
protected function pageForPlacemark(Placemark $placemark) { $page = 'detail'; $params = $placemark->getURLParams(); if (isset($params['feed']) && $this->isMapDrivenUI($params['feed'])) { //$fullscreen = ($this->numGroups > 1) ? 'campus' : 'index'; //if ($this->page != $fullscreen) { // use detail page if we're already on a fullscreen map // $page = $fullscreen; //} if (($this->page != 'campus' || $this->getArg('listview')) && !$this->getArg('mapview')) { // use detail page if we're already on a fullscreen map $page = 'campus'; } } return $page; }
public function addPlacemark(Placemark $placemark) { // only GoogleJSMap, ArcGISJSMap, and GoogleStaticMap support overlays $geometry = $placemark->getGeometry(); if ($geometry instanceof MapPolygon) { $this->addPolygon($placemark); } elseif ($geometry instanceof MapPolyline) { $this->addPath($placemark); } else { $this->addPoint($placemark); } }
protected function pageForPlacemark(Placemark $placemark) { $page = 'detail'; $params = $placemark->getURLParams(); // only if the placemark is searched, and there are 2 feed groups // the feedGroup is mandartory if (empty($this->feedGroup) && isset($params['group'])) { $this->feedGroup = $params['group']; } if (isset($params['feed']) && $this->isMapDrivenUI($params['feed'])) { //$fullscreen = ($this->numGroups > 1) ? 'campus' : 'index'; //if ($this->page != $fullscreen) { // use detail page if we're already on a fullscreen map // $page = $fullscreen; //} if (($this->page != 'campus' || $this->getArg('listview')) && !$this->getArg('mapview')) { // use detail page if we're already on a fullscreen map $page = 'campus'; } } return $page; }
function shortArrayFromMapFeature(Placemark $feature) { $category = current($feature->getCategoryIds()); $result = array('category' => $category); $id = $feature->getId(); if ($id) { $result['featureindex'] = $id; } else { $geometry = $feature->getGeometry(); if ($geometry) { $coords = $geometry->getCenterCoordinate(); $result['lat'] = $coords['lat']; $result['lon'] = $coords['lon']; } $result['title'] = $feature->getTitle(); } return $result; }
protected function addPlacemark(Placemark $placemark) { $placemark->addCategoryId($this->getId()); $placemark->setId(count($this->placemarks)); $this->placemarks[] = $placemark; }
public static function updateFeature(Placemark $feature, $parentCategoryId, $projector = null) { $style = $feature->getStyle(); if (method_exists($style, 'getId')) { $styleId = $style->getId(); } else { $styleId = null; } $geometry = $feature->getGeometry(); if ($geometry) { if ($projector) { $geometry = $projector->projectGeometry($geometry); } $centroid = $geometry->getCenterCoordinate(); $wkt = WKTParser::wktFromGeometry($geometry); } else { // TODO: handle this instead of throwing exception throw new KurogoDataException("feature has no geometry"); } $placemarkId = $feature->getId(); // placemark table $isStored = $feature instanceof MapDBPlacemark && $feature->isStored(); if (!$isStored) { $sql = 'SELECT * FROM ' . self::PLACEMARK_TABLE . ' WHERE placemark_id=? AND lat=? AND lon=?'; $params = array($placemarkId, $centroid['lat'], $centroid['lon']); $results = self::connection()->query($sql, $params); if ($results->fetch()) { $isStored = true; } } $params = array($feature->getTitle(), $feature->getAddress(), $styleId, $wkt, $placemarkId, $centroid['lat'], $centroid['lon']); if ($isStored) { $sql = 'UPDATE ' . self::PLACEMARK_TABLE . ' SET name=?, address=?, style_id=?, geometry=?' . ' WHERE placemark_id=? AND lat=? AND lon=?'; } else { $sql = 'INSERT INTO ' . self::PLACEMARK_TABLE . ' (name, address, style_id, geometry, placemark_id, lat, lon)' . ' VALUES (?, ?, ?, ?, ?, ?, ?)'; } self::connection()->query($sql, $params); if ($placemarkId === null) { // TODO: check db compatibility for this function $placemarkId = self::connection()->lastInsertId(); } // categories $categories = $feature->getCategoryIds(); if (!is_array($categories)) { $categories = array(); } if (!in_array($parentCategoryId, $categories)) { $categories[] = $parentCategoryId; } foreach ($categories as $categoryId) { $sql = 'INSERT INTO ' . self::PLACEMARK_CATEGORY_TABLE . ' (placemark_id, lat, lon, category_id)' . ' VALUES (?, ?, ?, ?)'; $params = array($placemarkId, $centroid['lat'], $centroid['lon'], $categoryId); self::connection()->query($sql, $params, db::IGNORE_ERRORS); } // properties $sql = 'DELETE FROM ' . self::PLACEMARK_PROPERTIES_TABLE . ' WHERE placemark_id=?'; $params = array($placemarkId); self::connection()->query($sql, $params); $properties = $feature->getFields(); foreach ($properties as $name => $value) { $sql = 'INSERT INTO ' . self::PLACEMARK_PROPERTIES_TABLE . ' (placemark_id, lat, lon, property_name, property_value)' . ' VALUES (?, ?, ?, ?, ?)'; $params = array($placemarkId, $centroid['lat'], $centroid['lon'], $name, $value); self::connection()->query($sql, $params); } }
protected function getProjectedFeature(Placemark $placemark) { if ($placemark instanceof BasePlacemark) { // generic Placemark does not implement setGeometry $this->setupProjector(); if ($this->projector !== null) { $geometry = $placemark->getGeometry(); if ($geometry) { $placemark->setGeometry($this->projector->projectGeometry($geometry)); } } } return $placemark; }
protected function getProjectedFeature(Placemark $placemark) { if ($placemark instanceof BasePlacemark) { // generic Placemark does not implement setGeometry $this->setupProjector(); if ($this->projector !== null) { $geometry = $placemark->getGeometry(); if ($geometry) { $placemark->setGeometry($this->projector->projectGeometry($geometry)); } } } $placemark->setURLParam('feed', $this->categoryId); $placemark->setURLParam('group', $this->feedGroup); return $placemark; }