<?php
namespace League\Geotools\CLI\Command\Geohash;
use League\Geotools\Geotools;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Decode extends \Symfony\Component\Console\Command\Command
{
protected function configure()
{
$this
->setName('geohash:decode')
->setDescription('Decode a geo hash string to a coordinate')
->addArgument('geohash', InputArgument::REQUIRED, 'The geo hash to decode to coordinate')
->setHelp(<<<EOT
<info>Example</info>: %command.full_name% spey61y
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$geotools = new Geotools;
$coordinate = $geotools->geohash()->decode($input->getArgument('geohash'))->getCoordinate();
$output->writeln(sprintf(
'<value>%s, %s</value>',
$coordinate->getLatitude(), $coordinate->getLongitude()
));
return 0;
}
}