/** * Renders and returns the output. * @see ParserHook::render * * @since 0.7 * * @param array $parameters * * @return string */ public function render(array $parameters) { $destination = MapsGeoFunctions::findDestination($parameters['location']->getCoordinates(), $parameters['bearing'], $parameters['distance']); $options = new \ValueFormatters\FormatterOptions(array(GeoCoordinateFormatter::OPT_FORMAT => $parameters['format'], GeoCoordinateFormatter::OPT_DIRECTIONAL => $parameters['directional'])); $formatter = new GeoCoordinateFormatter($options); $geoCoords = new \DataValues\LatLongValue($destination['lat'], $destination['lon']); $output = $formatter->format($geoCoords); 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 lat and lon limits of a bounding box around a circle defined by the provided parameters. * * @since 0.6 * * @param array $centerCoordinates Array containing non-directional float coordinates with lat and lon keys. * @param float $circleRadius The radidus of the circle to create a bounding box for, in m. * * @return An associative array containing the limits with keys north, east, south and west. */ protected static function getBoundingBox(array $centerCoordinates, $circleRadius) { $north = MapsGeoFunctions::findDestination($centerCoordinates, 0, $circleRadius); $east = MapsGeoFunctions::findDestination($centerCoordinates, 90, $circleRadius); $south = MapsGeoFunctions::findDestination($centerCoordinates, 180, $circleRadius); $west = MapsGeoFunctions::findDestination($centerCoordinates, 270, $circleRadius); return array('north' => $north['lat'], 'east' => $east['lon'], 'south' => $south['lat'], 'west' => $west['lon']); }
/** * @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']); }