|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Geotools library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Antoine Corcy <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace League\Geotools\CLI\Command\Edge; |
|
13
|
|
|
|
|
14
|
|
|
use League\Geotools\Coordinate\Coordinate; |
|
15
|
|
|
use League\Geotools\Coordinate\Ellipsoid; |
|
16
|
|
|
use League\Geotools\Geotools; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
19
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Command-line edge:initial-cardinal class |
|
24
|
|
|
* |
|
25
|
|
|
* @author Antoine Corcy <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class InitialCardinal extends \Symfony\Component\Console\Command\Command |
|
28
|
|
|
{ |
|
29
|
6 |
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
6 |
|
$availableEllipsoids = Ellipsoid::getAvailableEllipsoidNames(); |
|
32
|
|
|
|
|
33
|
|
|
$this |
|
34
|
6 |
|
->setName('edge:initial-cardinal') |
|
35
|
6 |
|
->setDescription('Compute the initial cardinal point (direction) between 2 coordinates') |
|
36
|
6 |
|
->addArgument('origin', InputArgument::REQUIRED, 'The origin "Lat,Long" coordinate') |
|
37
|
6 |
|
->addArgument('destination', InputArgument::REQUIRED, 'The destination "Lat,Long" coordinate') |
|
38
|
6 |
|
->addOption('ellipsoid', null, InputOption::VALUE_REQUIRED, |
|
39
|
6 |
|
'If set, the name of the ellipsoid to use', Ellipsoid::WGS84) |
|
40
|
6 |
|
->setHelp(<<<EOT |
|
41
|
6 |
|
<info>Available ellipsoids</info>: $availableEllipsoids |
|
42
|
|
|
|
|
43
|
|
|
<info>Example with INTERNATIONAL ellipsoid</info>: |
|
44
|
|
|
|
|
45
|
6 |
|
%command.full_name% "40° 26.7717, -79° 56.93172" "30°16′57″N 029°48′32″W" <comment>--ellipsoid=INTERNATIONAL</comment> |
|
46
|
|
|
EOT |
|
47
|
|
|
); |
|
48
|
6 |
|
} |
|
49
|
|
|
|
|
50
|
5 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
51
|
|
|
{ |
|
52
|
5 |
|
$ellipsoid = Ellipsoid::createFromName($input->getOption('ellipsoid')); |
|
53
|
3 |
|
$from = new Coordinate($input->getArgument('origin'), $ellipsoid); |
|
54
|
2 |
|
$to = new Coordinate($input->getArgument('destination'), $ellipsoid); |
|
55
|
|
|
|
|
56
|
2 |
|
$geotools = new Geotools; |
|
57
|
|
|
|
|
58
|
2 |
|
$output->writeln(sprintf( |
|
59
|
2 |
|
'<value>%s</value>', |
|
60
|
2 |
|
$geotools->edge()->setFrom($from)->setTo($to)->initialCardinal() |
|
61
|
|
|
)); |
|
62
|
2 |
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|