Create the ellipsoid chosen by its name.
public static createFromName ( string $name = self::WGS84 ) : |
||
$name | string | The name of the ellipsoid to create (optional). |
return |
protected function execute(InputInterface $input, OutputInterface $output) { $ellipsoid = Ellipsoid::createFromName($input->getOption('ellipsoid')); $coordinate = new Coordinate($input->getArgument('coordinate'), $ellipsoid); $geotools = new Geotools(); $output->writeln(sprintf('<value>%s</value>', $geotools->convert($coordinate)->toUTM())); }
protected function execute(InputInterface $input, OutputInterface $output) { $ellipsoid = Ellipsoid::createFromName($input->getOption('ellipsoid')); $from = new Coordinate($input->getArgument('origin'), $ellipsoid); $to = new Coordinate($input->getArgument('destination'), $ellipsoid); $geotools = new Geotools(); $output->writeln(sprintf('<value>%s</value>', $geotools->vertex()->setFrom($from)->setTo($to)->finalBearing())); }
public function testCoordinateWithEllipsoid() { $coordinate = $this->geotools->coordinate('1, 2', Ellipsoid::createFromName(Ellipsoid::AIRY)); $this->assertInstanceOf('League\\Geotools\\Coordinate\\Coordinate', $coordinate); $this->assertSame(1.0, $coordinate->getLatitude()); $this->assertSame(2.0, $coordinate->getLongitude()); $this->assertSame('Airy', $coordinate->getEllipsoid()->getName()); }
protected function execute(InputInterface $input, OutputInterface $output) { $from = new Coordinate($input->getArgument('origin'), Ellipsoid::createFromName($input->getOption('ellipsoid'))); $geotools = new Geotools(); $destination = $geotools->vertex()->setFrom($from); $destination = $destination->destination($input->getArgument('bearing'), $input->getArgument('distance')); $output->writeln(sprintf('<value>%s, %s</value>', $destination->getLatitude(), $destination->getLongitude())); }
protected function execute(InputInterface $input, OutputInterface $output) { $ellipsoid = Ellipsoid::createFromName($input->getOption('ellipsoid')); $from = new Coordinate($input->getArgument('origin'), $ellipsoid); $to = new Coordinate($input->getArgument('destination'), $ellipsoid); $geotools = new Geotools(); $middle = $geotools->point()->setFrom($from)->setTo($to)->middle(); $output->writeln(sprintf('<value>%s, %s</value>', $middle->getLatitude(), $middle->getLongitude())); }
/** * Set the latitude and the longitude of the coordinates into an selected ellipsoid. * * @param ResultInterface|array|string $coordinates The coordinates. * @param Ellipsoid $ellipsoid The selected ellipsoid (WGS84 by default). * * @throws InvalidArgumentException */ public function __construct($coordinates, Ellipsoid $ellipsoid = null) { if ($coordinates instanceof ResultInterface) { $this->setLatitude($coordinates->getLatitude()); $this->setLongitude($coordinates->getLongitude()); } elseif (is_array($coordinates) && 2 === count($coordinates)) { $this->setLatitude($coordinates[0]); $this->setLongitude($coordinates[1]); } elseif (is_string($coordinates)) { $this->setFromString($coordinates); } else { throw new InvalidArgumentException('It should be a string, an array or a class which implements Geocoder\\Result\\ResultInterface !'); } $this->ellipsoid = $ellipsoid ?: Ellipsoid::createFromName(Ellipsoid::WGS84); }
protected function execute(InputInterface $input, OutputInterface $output) { $ellipsoid = Ellipsoid::createFromName($input->getOption('ellipsoid')); $from = new Coordinate($input->getArgument('origin'), $ellipsoid); $to = new Coordinate($input->getArgument('destination'), $ellipsoid); $geotools = new Geotools(); $distance = $geotools->distance()->setFrom($from)->setTo($to); if ($input->getOption('km')) { $distance->in('km'); } if ($input->getOption('mi')) { $distance->in('mi'); } if ($input->getOption('ft')) { $distance->in('ft'); } $output->writeln(sprintf('<value>%s</value>', $distance->haversine())); }
/** * Returns the underlying Coordinate object * * @param self $coordinate * @return BaseCoordinate */ protected static function getBaseCoordinate(self $coordinate) { $latitude = $coordinate->getLatitude()->toNative(); $longitude = $coordinate->getLongitude()->toNative(); $ellipsoid = BaseEllipsoid::createFromName($coordinate->getEllipsoid()->toNative()); $coordinate = new BaseCoordinate(array($latitude, $longitude), $ellipsoid); return $coordinate; }