/** * Does the same as Geocode, but also formats the result into a string. * * @since 0.7 * * @param string $coordsOrAddress * @param string $service * @param string $mappingService * @param coordinate type $targetFormat The notation to which they should be formatted. Defaults to floats. * @param boolean $directional Indicates if the target notation should be directional. Defaults to false. * * @return formatted coordinates string or false */ public static function geocodeToString($address, $service = '', $mappingService = false, $targetFormat = Maps_COORDS_FLOAT, $directional = false) { $coordinates = self::geocode($address, $service, $mappingService); return $coordinates ? MapsCoordinateParser::formatCoordinates($coordinates, $targetFormat, $directional) : false; }
/** * Renders and returns the output. * @see ParserHook::render * * @since 0.7 * * @param array $parameters * * @return string */ public function render(array $parameters) { $parsedCoords = MapsCoordinateParser::parseCoordinates($parameters['location']); if ($parsedCoords) { $output = MapsCoordinateParser::formatCoordinates($parsedCoords, $parameters['format'], $parameters['directional']); } else { // The coordinates should be valid when this method gets called. throw new Exception('Attempt to format an invalid set of coordinates'); } return $output; }
/** * Renders and returns the output. * @see ParserHook::render * * @since 0.7 * * @param array $parameters * * @return string */ public function render(array $parameters) { $canGeocode = MapsGeocoders::canGeocode(); if ($canGeocode) { $location = MapsGeocoders::attemptToGeocode($parameters['location'], $parameters['geoservice'], $parameters['mappingservice']); } else { $location = MapsCoordinateParser::parseCoordinates($parameters['location']); } // TODO if ($location) { $destination = MapsGeoFunctions::findDestination($location, $parameters['bearing'], MapsDistanceParser::parseDistance($parameters['distance'])); $output = MapsCoordinateParser::formatCoordinates($destination, $parameters['format'], $parameters['directional']); } else { // The location should be valid when this method gets called. throw new MWException('Attempt to find a destination from an invalid location'); } return $output; }
/** * Returns the locations coordinates formatted in the specified notation. * * @since 0.7.1 * * @param string $format Element of the Maps_COORDS_ enum * @param boolean $directional * @param string $separator * * @return string */ public function getCoordinates($format = null, $directional = null, $separator = null) { if (!$this->isValid()) { throw new Exception('Attempt to get the coordinates for an invalid location'); } return MapsCoordinateParser::formatCoordinates(array('lat' => $this->latitude, 'lon' => $this->longitude), is_null($format) ? $this->format : $format, is_null($directional) ? $this->directional : $directional, is_null($separator) ? $this->separator : $separator); }
/** * Create links to mapping services based on a wiki-editable message. The parameters * available to the message are: * * $1: The location in non-directional float notation. * $2: The location in directional DMS notation. * $3: The latitude in non-directional float notation. * $4 The longitude in non-directional float notation. * * @since 0.6.4 * * @return array */ protected function getServiceLinkParams() { $coordinateSet = $this->m_dataitem->getCoordinateSet(); return array(MapsCoordinateParser::formatCoordinates($coordinateSet, 'float', false), MapsCoordinateParser::formatCoordinates($coordinateSet, 'dms', true), $coordinateSet['lat'], $coordinateSet['lon']); }