-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathDecode.php
More file actions
49 lines (43 loc) · 1.39 KB
/
Decode.php
File metadata and controls
49 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* This file is part of the Geotools library.
*
* (c) Antoine Corcy <contact@sbin.dk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
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;
/**
* Command-line geohash:decode class
*
* @author Antoine Corcy <contact@sbin.dk>
*/
class Decode extends \Symfony\Component\Console\Command\Command
{
protected function configure(): void
{
$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;
}
}