getLongitude() public method

{@inheritDoc}
public getLongitude ( )
Example #1
0
 /**
  * Returns a new Longitude object
  *
  * @param $value
  * @throws InvalidNativeArgumentException
  */
 public function __construct($value)
 {
     $value = \filter_var($value, FILTER_VALIDATE_FLOAT);
     if (false === $value) {
         throw new InvalidNativeArgumentException($value, array('float'));
     }
     // normalization process through Coordinate object
     $coordinate = new BaseCoordinate(array(0, $value));
     $longitude = $coordinate->getLongitude();
     $this->value = $longitude;
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $coordinate = new Coordinate($input->getArgument('coordinate'));
     $geocoder = new ProviderAggregator();
     $adapter = $this->getAdapter($input->getOption('adapter'));
     $provider = $this->getProvider($input->getOption('provider'));
     if ($input->getOption('args')) {
         $args = is_array($input->getOption('args')) ? implode(',', $input->getOption('args')) : $input->getOption('args');
         $geocoder->registerProvider(new $provider(new $adapter(), $args));
     } else {
         $geocoder->registerProvider(new $provider(new $adapter()));
     }
     $reversed = $geocoder->reverse($coordinate->getLatitude(), $coordinate->getLongitude());
     $reversed = $reversed->first();
     $formatter = new Formatter();
     if ($input->getOption('raw')) {
         $result = array();
         $result[] = sprintf('<label>Adapter</label>:       <value>%s</value>', $adapter);
         $result[] = sprintf('<label>Provider</label>:      <value>%s</value>', $provider);
         if ($input->getOption('args')) {
             $result[] = sprintf('<label>Arguments</label>:     <value>%s</value>', $args);
         }
         $result[] = '---';
         $result[] = sprintf('<label>Latitude</label>:      <value>%s</value>', $reversed->getLatitude());
         $result[] = sprintf('<label>Longitude</label>:     <value>%s</value>', $reversed->getLongitude());
         if (null !== ($bounds = $reversed->getBounds()->toArray())) {
             $result[] = '<label>Bounds</label>';
             $result[] = sprintf(' - <label>South</label>: <value>%s</value>', $bounds['south']);
             $result[] = sprintf(' - <label>West</label>:  <value>%s</value>', $bounds['west']);
             $result[] = sprintf(' - <label>North</label>: <value>%s</value>', $bounds['north']);
             $result[] = sprintf(' - <label>East</label>:  <value>%s</value>', $bounds['east']);
         }
         $result[] = sprintf('<label>Street Number</label>: <value>%s</value>', $reversed->getStreetNumber());
         $result[] = sprintf('<label>Street Name</label>:   <value>%s</value>', $reversed->getStreetName());
         $result[] = sprintf('<label>Zipcode</label>:       <value>%s</value>', $reversed->getPostalCode());
         $result[] = sprintf('<label>City</label>:          <value>%s</value>', $reversed->getLocality());
         $result[] = sprintf('<label>City District</label>: <value>%s</value>', $reversed->getSubLocality());
         if (NULL !== ($adminLevels = $reversed->getAdminLevels())) {
             $result[] = '<label>Admin Levels</label>';
             foreach ($adminLevels as $adminLevel) {
                 $result[] = sprintf(' - <label>%s</label>: <value>%s</value>', $adminLevel->getCode(), $adminLevel->getName());
             }
         }
         $result[] = sprintf('<label>Country</label>:       <value>%s</value>', $reversed->getCountry()->toString());
         $result[] = sprintf('<label>Country Code</label>:  <value>%s</value>', $reversed->getCountryCode());
         $result[] = sprintf('<label>Timezone</label>:      <value>%s</value>', $reversed->getTimezone());
     } elseif ($input->getOption('json')) {
         $result = sprintf('<value>%s</value>', json_encode($reversed->toArray()));
     } else {
         $result = $formatter->format($reversed, $input->getOption('format'));
     }
     $output->writeln($result);
 }
 /**
  * Returns a new Coordinate object from native PHP arguments
  *
  * @return self
  * @throws \BadMethodCallException
  */
 public static function fromNative()
 {
     $args = \func_get_args();
     if (\count($args) < 2 || \count($args) > 3) {
         throw new \BadMethodCallException('You must provide 2 to 3 arguments: 1) latitude, 2) longitude, 3) valid ellipsoid type (optional)');
     }
     $coordinate = new BaseCoordinate(array($args[0], $args[1]));
     $latitude = Latitude::fromNative($coordinate->getLatitude());
     $longitude = Longitude::fromNative($coordinate->getLongitude());
     $nativeEllipsoid = isset($args[2]) ? $args[2] : null;
     $ellipsoid = Ellipsoid::fromNative($nativeEllipsoid);
     return new static($latitude, $longitude, $ellipsoid);
 }
Example #4
0
 /**
  * Returns a boolean determining coordinates equality
  * @param  Coordinate  $coordinate
  * @return boolean
  */
 public function isEqual(Coordinate $coordinate)
 {
     return bccomp($this->latitude, $coordinate->getLatitude(), $this->getPrecision()) === 0 && bccomp($this->longitude, $coordinate->getLongitude(), $this->getPrecision()) === 0;
 }