Completed
Push — master ( 520645...0aa38f )
by Antoine
03:23
created

UTM   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 94.74%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 34
ccs 18
cts 19
cp 0.9474
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 19 1
A execute() 0 11 1
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\Convert;
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 convert:utm class
24
 *
25
 * @author Antoine Corcy <[email protected]>
26
 */
27
class UTM extends \Symfony\Component\Console\Command\Command
28
{
29 8
    protected function configure()
30
    {
31 8
        $availableEllipsoids = Ellipsoid::getAvailableEllipsoidNames();
32
33
        $this
34 8
            ->setName('convert:utm')
35 8
            ->setDescription('Convert decimal degrees coordinates in the Universal Transverse Mercator projection')
36 8
            ->addArgument('coordinate', InputArgument::REQUIRED, 'The "Lat,Long" coordinate')
37 8
            ->addOption('ellipsoid', null, InputOption::VALUE_REQUIRED,
38 8
                'If set, the name of the ellipsoid to use', Ellipsoid::WGS84)
39 8
            ->setHelp(<<<EOT
40
<info>Available ellipsoids</info>: $availableEllipsoids
41
42
<info>Example with CLARKE_1866 ellipsoid</info>:
43
44 8
    %command.full_name% "40.446195, -79.948862" <comment>--ellipsoid=CLARKE_1866</comment>
45
EOT
46
            );
47 8
    }
48
49 7
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51 7
        $ellipsoid  = Ellipsoid::createFromName($input->getOption('ellipsoid'));
52 5
        $coordinate = new Coordinate($input->getArgument('coordinate'), $ellipsoid);
53 4
        $geotools   = new Geotools;
54
55 4
        $output->writeln(sprintf(
56 4
            '<value>%s</value>',
57 4
            $geotools->convert($coordinate)->toUTM()
58
        ));
59 4
    }
60
}
61