/** * @since 3.0 * * @param SMWDIGeoCoord $dataItem * @param string|null $format * * @return string|null */ protected function getFormattedCoord(SMWDIGeoCoord $dataItem, $format = null) { global $smgQPCoodFormat; $options = new \ValueFormatters\FormatterOptions(array(GeoCoordinateFormatter::OPT_FORMAT => $format === null ? $smgQPCoodFormat : $format)); // TODO: $smgQPCoodDirectional $coordinateFormatter = new GeoCoordinateFormatter($options); $value = new LatLongValue($dataItem->getLatitude(), $dataItem->getLongitude()); return $coordinateFormatter->format($value); }
/** * @return float[] An associative array containing the limits with keys north, east, south and west. */ protected function getBoundingBox() { $center = new LatLongValue($this->center->getLatitude(), $this->center->getLongitude()); $north = MapsGeoFunctions::findDestination($center, 0, $this->radius); $east = MapsGeoFunctions::findDestination($center, 90, $this->radius); $south = MapsGeoFunctions::findDestination($center, 180, $this->radius); $west = MapsGeoFunctions::findDestination($center, 270, $this->radius); return array('north' => $north['lat'], 'east' => $east['lon'], 'south' => $south['lat'], 'west' => $west['lon']); }
/** * Sets the bounds fields to an array returned by SMAreaValueDescription::getBoundingBox. * * @since 0.6 * * @param SMWDIGeoCoord $dataItem * @param string $radius */ protected function calculateBounds(SMWDIGeoCoord $dataItem, $radius) { $this->bounds = self::getBoundingBox(array('lat' => $dataItem->getLatitude(), 'lon' => $dataItem->getLongitude()), MapsDistanceParser::parseDistance($radius)); }
/** * @see SMWDataItemHandler::dataItemFromDBKeys() * @since 1.8 * @param $dbkeys array of mixed * * @return SMWDataItem */ public function dataItemFromDBKeys($dbkeys) { return SMWDIGeoCoord::doUnserialize($dbkeys[0]); }
/** * @see SMWDataItemHandler::dataItemFromDBKeys() * @since 1.8 * @param array|string $dbkeys expecting string here * * @return SMWDataItem */ public function dataItemFromDBKeys($dbkeys) { if (is_string($dbkeys)) { return SMWDIGeoCoord::doUnserialize($dbkeys); } else { throw new SMWDataItemException('Failed to create data item from DB keys.'); } }
/** * @since 1.8 * * {@inheritDoc} */ public function dataItemFromDBKeys($dbkeys) { if (is_string($dbkeys)) { return DIGeoCoord::doUnserialize($dbkeys); } throw new DataItemHandlerException('Failed to create data item from DB keys.'); }