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
|
|
|
use function array_map; |
14
|
|
|
|
15
|
|
|
class Ellipsoidal extends CoordinateSystem |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* 2D Axes: latitude, longitude. Orientations: north, east. Units: degree |
19
|
|
|
* Coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be |
20
|
|
|
* used but that used must be declared for the user by the supplier of data. Used in geographic 2D coordinate |
21
|
|
|
* reference systems. |
22
|
|
|
*/ |
23
|
|
|
public const EPSG_2D_AXES_LATITUDE_LONGITUDE_ORIENTATIONS_NORTH_EAST_UOM_DEGREE = 'urn:ogc:def:cs:EPSG::6422'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* 2D Axes: latitude, longitude. Orientations: north, east. Units: grads. |
27
|
|
|
* Used in geographic 2D coordinate reference systems. |
28
|
|
|
*/ |
29
|
|
|
public const EPSG_2D_AXES_LATITUDE_LONGITUDE_ORIENTATIONS_NORTH_EAST_UOM_GRADS = 'urn:ogc:def:cs:EPSG::6403'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* 2D Axes: longitude, latitude. Orientations: east, north. Units: degree |
33
|
|
|
* Used in geog2D CRSs for some web mapping: CS code 6422 recommended. Coordinates referenced to this CS are in |
34
|
|
|
* degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that used must be declared for the |
35
|
|
|
* user by the supplier of data. |
36
|
|
|
*/ |
37
|
|
|
public const EPSG_2D_AXES_LONGITUDE_LATITUDE_ORIENTATIONS_EAST_NORTH_UOM_DEGREE = 'urn:ogc:def:cs:EPSG::6424'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* 3D Axes: latitude, longitude, ellipsoidal height. Orientations: north, east, up. Units: degree, degree, metre. |
41
|
|
|
* Horizontal coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, |
42
|
|
|
* etc.) may be used but that used must be declared for the user. Used in geographic 3D coordinate reference |
43
|
|
|
* systems. |
44
|
|
|
*/ |
45
|
|
|
public const EPSG_3D_AXES_LATITUDE_LONGITUDE_ELLIPSOIDAL_HEIGHT_ORIENTATIONS_NORTH_EAST_UP_UOM_DEGREE_DEGREE_METRE = 'urn:ogc:def:cs:EPSG::6423'; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* 3D Axes: longitude, latitude, ellipsoidal height. Orientations: east, north, up. Units: degree, degree, metre. |
49
|
|
|
* Used in some geographic 3D CRSs for web mapping. CS code 6423 recommended instead. Horizontal coordinates |
50
|
|
|
* referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that |
51
|
|
|
* used must be declared for the user. |
52
|
|
|
*/ |
53
|
|
|
public const EPSG_3D_AXES_LONGITUDE_LATITUDE_ELLIPSOIDAL_HEIGHT_ORIENTATIONS_EAST_NORTH_UP_UOM_DEGREE_DEGREE_METRE = 'urn:ogc:def:cs:EPSG::6426'; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var array<string, array{name: string, axes: array<array{orientation: string, abbreviation: string, name: string, uom: string}>, help: string}> |
57
|
|
|
*/ |
58
|
|
|
protected static array $sridData = [ |
59
|
|
|
'urn:ogc:def:cs:EPSG::6403' => [ |
60
|
|
|
'name' => '2D Axes: latitude, longitude. Orientations: north, east. UoM: grads.', |
61
|
|
|
'axes' => [ |
62
|
|
|
[ |
63
|
|
|
'orientation' => 'north', |
64
|
|
|
'abbreviation' => 'Lat', |
65
|
|
|
'name' => 'Geodetic latitude', |
66
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9105', |
67
|
|
|
], |
68
|
|
|
[ |
69
|
|
|
'orientation' => 'east', |
70
|
|
|
'abbreviation' => 'Lon', |
71
|
|
|
'name' => 'Geodetic longitude', |
72
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9105', |
73
|
|
|
], |
74
|
|
|
], |
75
|
|
|
'help' => 'Used in geographic 2D coordinate reference systems.', |
76
|
|
|
], |
77
|
|
|
'urn:ogc:def:cs:EPSG::6422' => [ |
78
|
|
|
'name' => '2D Axes: latitude, longitude. Orientations: north, east. UoM: degree', |
79
|
|
|
'axes' => [ |
80
|
|
|
[ |
81
|
|
|
'orientation' => 'north', |
82
|
|
|
'abbreviation' => 'Lat', |
83
|
|
|
'name' => 'Geodetic latitude', |
84
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
85
|
|
|
], |
86
|
|
|
[ |
87
|
|
|
'orientation' => 'east', |
88
|
|
|
'abbreviation' => 'Lon', |
89
|
|
|
'name' => 'Geodetic longitude', |
90
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
91
|
|
|
], |
92
|
|
|
], |
93
|
|
|
'help' => 'Coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that used must be declared for the user by the supplier of data. Used in geographic 2D coordinate reference systems.', |
94
|
|
|
], |
95
|
|
|
'urn:ogc:def:cs:EPSG::6423' => [ |
96
|
|
|
'name' => '3D Axes: latitude, longitude, ellipsoidal height. Orientations: north, east, up. UoM: degree, degree, metre.', |
97
|
|
|
'axes' => [ |
98
|
|
|
[ |
99
|
|
|
'orientation' => 'north', |
100
|
|
|
'abbreviation' => 'Lat', |
101
|
|
|
'name' => 'Geodetic latitude', |
102
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
103
|
|
|
], |
104
|
|
|
[ |
105
|
|
|
'orientation' => 'east', |
106
|
|
|
'abbreviation' => 'Lon', |
107
|
|
|
'name' => 'Geodetic longitude', |
108
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
109
|
|
|
], |
110
|
|
|
[ |
111
|
|
|
'orientation' => 'up', |
112
|
|
|
'abbreviation' => 'h', |
113
|
|
|
'name' => 'Ellipsoidal height', |
114
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9001', |
115
|
|
|
], |
116
|
|
|
], |
117
|
|
|
'help' => 'Horizontal coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that used must be declared for the user. Used in geographic 3D coordinate reference systems.', |
118
|
|
|
], |
119
|
|
|
'urn:ogc:def:cs:EPSG::6424' => [ |
120
|
|
|
'name' => '2D Axes: longitude, latitude. Orientations: east, north. UoM: degree', |
121
|
|
|
'axes' => [ |
122
|
|
|
[ |
123
|
|
|
'orientation' => 'east', |
124
|
|
|
'abbreviation' => 'Lon', |
125
|
|
|
'name' => 'Geodetic longitude', |
126
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
127
|
|
|
], |
128
|
|
|
[ |
129
|
|
|
'orientation' => 'north', |
130
|
|
|
'abbreviation' => 'Lat', |
131
|
|
|
'name' => 'Geodetic latitude', |
132
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
133
|
|
|
], |
134
|
|
|
], |
135
|
|
|
'help' => 'Used in geog2D CRSs for some web mapping: CS code 6422 recommended. Coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that used must be declared for the user by the supplier of data.', |
136
|
|
|
], |
137
|
|
|
'urn:ogc:def:cs:EPSG::6426' => [ |
138
|
|
|
'name' => '3D Axes: longitude, latitude, ellipsoidal height. Orientations: east, north, up. UoM: degree, degree, metre.', |
139
|
|
|
'axes' => [ |
140
|
|
|
[ |
141
|
|
|
'orientation' => 'east', |
142
|
|
|
'abbreviation' => 'Lon', |
143
|
|
|
'name' => 'Geodetic longitude', |
144
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
145
|
|
|
], |
146
|
|
|
[ |
147
|
|
|
'orientation' => 'north', |
148
|
|
|
'abbreviation' => 'Lat', |
149
|
|
|
'name' => 'Geodetic latitude', |
150
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
151
|
|
|
], |
152
|
|
|
[ |
153
|
|
|
'orientation' => 'up', |
154
|
|
|
'abbreviation' => 'h', |
155
|
3529 |
|
'name' => 'Ellipsoidal height', |
156
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9001', |
157
|
3529 |
|
], |
158
|
9 |
|
], |
159
|
|
|
'help' => 'Used in some geographic 3D CRSs for web mapping. CS code 6423 recommended instead. Horizontal coordinates referenced to this CS are in degrees. Any degree representation (e.g. DMSH, decimal, etc.) may be used but that used must be declared for the user.', |
160
|
|
|
], |
161
|
3520 |
|
]; |
162
|
36 |
|
|
163
|
|
|
/** |
164
|
36 |
|
* @var array<string, self> |
165
|
36 |
|
*/ |
166
|
36 |
|
private static array $cachedObjects = []; |
167
|
36 |
|
|
168
|
36 |
|
public static function fromSRID(string $srid): self |
169
|
36 |
|
{ |
170
|
36 |
|
if (!isset(static::$sridData[$srid])) { |
171
|
36 |
|
throw new UnknownCoordinateSystemException($srid); |
172
|
|
|
} |
173
|
|
|
|
174
|
36 |
|
if (!isset(self::$cachedObjects[$srid])) { |
175
|
|
|
$data = static::$sridData[$srid]; |
176
|
|
|
|
177
|
3520 |
|
$axes = []; |
178
|
|
|
foreach ($data['axes'] as $axisData) { |
179
|
|
|
$axes[] = new Axis( |
180
|
9 |
|
$axisData['orientation'], |
181
|
|
|
$axisData['abbreviation'], |
182
|
9 |
|
$axisData['name'], |
183
|
9 |
|
$axisData['uom'], |
184
|
9 |
|
); |
185
|
|
|
} |
186
|
|
|
|
187
|
9 |
|
self::$cachedObjects[$srid] = new self($srid, $axes); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return self::$cachedObjects[$srid]; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return array<string, string> |
195
|
|
|
*/ |
196
|
|
|
public static function getSupportedSRIDs(): array |
197
|
|
|
{ |
198
|
|
|
return array_map(fn (array $data) => $data['name'], static::$sridData); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return array<string, array{name: string, help: string}> |
203
|
|
|
*/ |
204
|
|
|
public static function getSupportedSRIDsWithHelp(): array |
205
|
|
|
{ |
206
|
|
|
return array_map(fn (array $data) => ['name' => $data['name'], 'help' => $data['help']], static::$sridData); |
207
|
|
|
} |
208
|
|
|
} |
209
|
|
|
|