Passed
Push — master ( 3e5121...8c57bf )
by Doug
27:00
created

Vertical::getSupportedSRIDs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\CoordinateSystem;
10
11
use PHPCoord\Exception\UnknownCoordinateSystemException;
12
13
class Vertical extends CoordinateSystem
14
{
15
    /**
16
     * Vertical CS. Axis: depth (D). Orientation: down. UoM: ft.
17
     * Type: vertical
18
     * Used in vertical coordinate reference systems.
19
     */
20
    public const EPSG_AXIS_DEPTH_D_ORIENTATION_DOWN_UOM_FT = 'urn:ogc:def:cs:EPSG::6495';
21
22
    /**
23
     * Vertical CS. Axis: depth (D). Orientation: down. UoM: ftUS.
24
     * Type: vertical
25
     * Used in US vertical coordinate reference systems.
26
     */
27
    public const EPSG_AXIS_DEPTH_D_ORIENTATION_DOWN_UOM_FTUS = 'urn:ogc:def:cs:EPSG::1043';
28
29
    /**
30
     * Vertical CS. Axis: depth (D). Orientation: down. UoM: m.
31
     * Type: vertical
32
     * Used in vertical coordinate reference systems.
33
     */
34
    public const EPSG_AXIS_DEPTH_D_ORIENTATION_DOWN_UOM_M = 'urn:ogc:def:cs:EPSG::6498';
35
36
    /**
37
     * Vertical CS. Axis: height (H). Orientation: up. UoM: ft(Br36).
38
     * Type: vertical
39
     * Used in vertical coordinate reference systems.
40
     */
41
    public const EPSG_AXIS_HEIGHT_H_ORIENTATION_UP_UOM_FT_BR36 = 'urn:ogc:def:cs:EPSG::6496';
42
43
    /**
44
     * Vertical CS. Axis: height (H). Orientation: up. UoM: ft.
45
     * Type: vertical
46
     * Used in vertical coordinate reference systems.
47
     */
48
    public const EPSG_AXIS_HEIGHT_H_ORIENTATION_UP_UOM_FT = 'urn:ogc:def:cs:EPSG::1030';
49
50
    /**
51
     * Vertical CS. Axis: height (H). Orientation: up. UoM: ftUS.
52
     * Type: vertical
53
     * Used in vertical coordinate reference systems.
54
     */
55
    public const EPSG_AXIS_HEIGHT_H_ORIENTATION_UP_UOM_FTUS = 'urn:ogc:def:cs:EPSG::6497';
56
57
    /**
58
     * Vertical CS. Axis: height (H). Orientation: up. UoM: m.
59
     * Type: vertical
60
     * Used in vertical coordinate reference systems.
61
     */
62
    public const EPSG_AXIS_HEIGHT_H_ORIENTATION_UP_UOM_M = 'urn:ogc:def:cs:EPSG::6499';
63
64
    protected static array $sridData = [
65
        'urn:ogc:def:cs:EPSG::1030' => [
66
            'name' => 'Axis: height (H). Orientation: up. UoM: ft.',
67
            'axes' => [
68
                [
69
                    'orientation' => 'up',
70
                    'abbreviation' => 'H',
71
                    'name' => 'Gravity-related height',
72
                    'uom' => 'urn:ogc:def:uom:EPSG::9002',
73
                ],
74
            ],
75
        ],
76
        'urn:ogc:def:cs:EPSG::1043' => [
77
            'name' => 'Axis: depth (D). Orientation: down. UoM: ftUS.',
78
            'axes' => [
79
                [
80
                    'orientation' => 'down',
81
                    'abbreviation' => 'D',
82
                    'name' => 'Depth',
83
                    'uom' => 'urn:ogc:def:uom:EPSG::9003',
84
                ],
85
            ],
86
        ],
87
        'urn:ogc:def:cs:EPSG::6495' => [
88
            'name' => 'Axis: depth (D). Orientation: down. UoM: ft.',
89
            'axes' => [
90
                [
91
                    'orientation' => 'down',
92
                    'abbreviation' => 'D',
93
                    'name' => 'Depth',
94
                    'uom' => 'urn:ogc:def:uom:EPSG::9002',
95
                ],
96
            ],
97
        ],
98
        'urn:ogc:def:cs:EPSG::6496' => [
99
            'name' => 'Axis: height (H). Orientation: up. UoM: ft(Br36).',
100
            'axes' => [
101
                [
102
                    'orientation' => 'up',
103
                    'abbreviation' => 'H',
104
                    'name' => 'Gravity-related height',
105
                    'uom' => 'urn:ogc:def:uom:EPSG::9095',
106
                ],
107
            ],
108
        ],
109
        'urn:ogc:def:cs:EPSG::6497' => [
110
            'name' => 'Axis: height (H). Orientation: up. UoM: ftUS.',
111
            'axes' => [
112
                [
113
                    'orientation' => 'up',
114
                    'abbreviation' => 'H',
115
                    'name' => 'Gravity-related height',
116
                    'uom' => 'urn:ogc:def:uom:EPSG::9003',
117
                ],
118
            ],
119
        ],
120
        'urn:ogc:def:cs:EPSG::6498' => [
121
            'name' => 'Axis: depth (D). Orientation: down. UoM: m.',
122
            'axes' => [
123
                [
124
                    'orientation' => 'down',
125
                    'abbreviation' => 'D',
126
                    'name' => 'Depth',
127
                    'uom' => 'urn:ogc:def:uom:EPSG::9001',
128
                ],
129
            ],
130
        ],
131
        'urn:ogc:def:cs:EPSG::6499' => [
132
            'name' => 'Axis: height (H). Orientation: up. UoM: m.',
133
            'axes' => [
134
                [
135
                    'orientation' => 'up',
136
                    'abbreviation' => 'H',
137
                    'name' => 'Gravity-related height',
138
                    'uom' => 'urn:ogc:def:uom:EPSG::9001',
139
                ],
140
            ],
141
        ],
142
    ];
143
144
    private static array $cachedObjects = [];
145
146 85
    public static function fromSRID(string $srid): self
147
    {
148 85
        if (!isset(static::$sridData[$srid])) {
149 9
            throw new UnknownCoordinateSystemException($srid);
150
        }
151
152 76
        if (!isset(self::$cachedObjects[$srid])) {
153
            $data = static::$sridData[$srid];
154
155
            $axes = [];
156
            foreach ($data['axes'] as $axisData) {
157
                $axes[] = new Axis(
158
                    $axisData['orientation'],
159
                    $axisData['abbreviation'],
160
                    $axisData['name'],
161
                    $axisData['uom'],
162
                );
163
            }
164
165
            self::$cachedObjects[$srid] = new self($srid, $axes);
166
        }
167
168 76
        return self::$cachedObjects[$srid];
169
    }
170
171 9
    public static function getSupportedSRIDs(): array
172
    {
173 9
        $supported = [];
174 9
        foreach (static::$sridData as $srid => $data) {
175 9
            $supported[$srid] = $data['name'];
176
        }
177
178 9
        return $supported;
179
    }
180
}
181