Completed
Push — issue13 ( 26c4fb )
by Doug
30:39
created

AlabamaGrid::getOriginLongitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * PHPCoord
4
 * @package PHPCoord
5
 * @author Jonathan Stott
6
 * @author Doug Wright
7
 */
8
namespace PHPCoord;
9
10
class AlabamaGrid extends TransverseMercator
11
{
12
13
    CONST FEET_TO_METERS = 0.3048;
14
15
    public function getReferenceEllipsoid()
16
    {
17
        return RefEll::grs80();
18
    }
19
20
    public function getScaleFactor()
21
    {
22
        return 0.99996;
23
    }
24
25
    public function getOriginNorthing()
26
    {
27
        return 0;
28
    }
29
30
    public function getOriginEasting()
31
    {
32
        return 656166.6666666665 * static::FEET_TO_METERS;
33
    }
34
35
    public function getOriginLatitude()
36
    {
37
        return 30.5;
38
    }
39
40
    public function getOriginLongitude()
41
    {
42
        return -85.83333333333333;
43
    }
44
45
    /**
46
     * Create a new object representing grid ref
47
     *
48
     * @param int $x
49
     * @param int $y
50
     * @param int $z
51
     */
52
    public function __construct($x, $y, $z = 0)
53
    {
54
        $x = $x * static::FEET_TO_METERS;
55
        $y = $y * static::FEET_TO_METERS;
56
57
        parent::__construct($x, $y, $z, RefEll::grs80());
58
    }
59
60
61
    /**
62
     * Convert this grid reference into a latitude and longitude
63
     * @return LatLng
64
     */
65
    public function toLatLng()
66
    {
67
        $N = $this->y;
68
        $E = $this->x;
69
        $N0 = $this->getOriginNorthing();
70
        $E0 = $this->getOriginEasting();
71
        $phi0 = $this->getOriginLatitude();
72
        $lambda0 = $this->getOriginLongitude();
73
74
        return $this->convertToLatitudeLongitude($N, $E, $N0, $E0, $phi0, $lambda0);
75
    }
76
77
    /**
78
     * String version of coordinate.
79
     * @return string
80
     */
81
    public function __toString()
82
    {
83
        return "({$this->x}, {$this->y})";
84
    }
85
}
86