Beispiel #1
0
 /**
  * Renders and returns the output.
  * @see ParserHook::render
  * 
  * @since 0.7
  * 
  * @param array $parameters
  * 
  * @return string
  */
 public function render(array $parameters)
 {
     $options = new \ValueFormatters\FormatterOptions(array(GeoCoordinateFormatter::OPT_FORMAT => $parameters['format'], GeoCoordinateFormatter::OPT_DIRECTIONAL => $parameters['directional']));
     $coordinateFormatter = new GeoCoordinateFormatter($options);
     $output = $coordinateFormatter->format($parameters['location']);
     return $output;
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * Renders and returns the output.
  * @see ParserHook::render
  * 
  * @since 0.7
  * 
  * @param array $parameters
  * 
  * @return string
  */
 public function render(array $parameters)
 {
     /**
      * @var \DataValues\LatLongValue $coordinates
      */
     $coordinates = $parameters['location']->getCoordinates();
     $options = new \ValueFormatters\FormatterOptions(array(GeoCoordinateFormatter::OPT_FORMAT => $parameters['format'], GeoCoordinateFormatter::OPT_DIRECTIONAL => $parameters['directional']));
     $formatter = new GeoCoordinateFormatter($options);
     return $formatter->format($coordinates);
 }
Beispiel #4
0
 /**
  * Geocodes an address with the provided geocoding service and returns the result 
  * as a string with the optionally provided format, or false when the geocoding failed.
  * 
  * @since 0.7
  * 
  * @param string $coordsOrAddress
  * @param string $service
  * @param string $mappingService
  * @param boolean $checkForCoords
  * @param string $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 string|false
  */
 public static function attemptToGeocodeToString($coordsOrAddress, $service = '', $mappingService = false, $checkForCoords = true, $targetFormat = Maps_COORDS_FLOAT, $directional = false)
 {
     $geoCoordinate = self::attemptToGeocode($coordsOrAddress, $service, $mappingService, $checkForCoords);
     if ($geoCoordinate === false) {
         return false;
     }
     $options = new \ValueFormatters\FormatterOptions(array(GeoCoordinateFormatter::OPT_FORMAT => $targetFormat, GeoCoordinateFormatter::OPT_DIRECTIONAL => $directional));
     $formatter = new GeoCoordinateFormatter($options);
     return $formatter->format($geoCoordinate);
 }