|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHPCoord. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Doug Wright |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace PHPCoord\Datum; |
|
10
|
|
|
|
|
11
|
|
|
use PHPCoord\Exception\UnknownPrimeMeridianException; |
|
12
|
|
|
use PHPCoord\UnitOfMeasure\Angle\Angle; |
|
13
|
|
|
|
|
14
|
|
|
use function array_map; |
|
15
|
|
|
|
|
16
|
|
|
class PrimeMeridian |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Athens |
|
20
|
|
|
* Used in Greece for older mapping based on Hatt projection. |
|
21
|
|
|
*/ |
|
22
|
|
|
public const EPSG_ATHENS = 'urn:ogc:def:meridian:EPSG::8912'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Bern |
|
26
|
|
|
* 1895 value. Newer value of 7°26'22.335" determined in 1938. |
|
27
|
|
|
*/ |
|
28
|
|
|
public const EPSG_BERN = 'urn:ogc:def:meridian:EPSG::8907'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Bogota. |
|
32
|
|
|
*/ |
|
33
|
|
|
public const EPSG_BOGOTA = 'urn:ogc:def:meridian:EPSG::8904'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Brussels. |
|
37
|
|
|
*/ |
|
38
|
|
|
public const EPSG_BRUSSELS = 'urn:ogc:def:meridian:EPSG::8910'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Ferro |
|
42
|
|
|
* El Hierro island, Canary islands, considered the most westerly point in Europe. Its longitude has had various |
|
43
|
|
|
* determinations. 17°40'W of Greenwich was adopted by Austria and former Czechoslovakia, 17°39'46.02"W by former |
|
44
|
|
|
* Yugoslavia. |
|
45
|
|
|
*/ |
|
46
|
|
|
public const EPSG_FERRO = 'urn:ogc:def:meridian:EPSG::8909'; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Greenwich |
|
50
|
|
|
* The international reference meridian as defined first by the 1884 International Meridian Conference and later by |
|
51
|
|
|
* the Bureau International de l'Heure (BIH) and then the International Earth Rotation Service (IERS). |
|
52
|
|
|
*/ |
|
53
|
|
|
public const EPSG_GREENWICH = 'urn:ogc:def:meridian:EPSG::8901'; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Jakarta |
|
57
|
|
|
* 1924 determination. Supersedes 1910 value of 106°48'37.05"E of Greenwich. |
|
58
|
|
|
*/ |
|
59
|
|
|
public const EPSG_JAKARTA = 'urn:ogc:def:meridian:EPSG::8908'; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Lisbon. |
|
63
|
|
|
*/ |
|
64
|
|
|
public const EPSG_LISBON = 'urn:ogc:def:meridian:EPSG::8902'; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Madrid |
|
68
|
|
|
* Longitude has had various determinations. 3°41'14.55"W of Greenwich adopted for Spanish cartography. |
|
69
|
|
|
*/ |
|
70
|
|
|
public const EPSG_MADRID = 'urn:ogc:def:meridian:EPSG::8905'; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Oslo |
|
74
|
|
|
* Formerly known as Kristiania or Christiania. |
|
75
|
|
|
*/ |
|
76
|
|
|
public const EPSG_OSLO = 'urn:ogc:def:meridian:EPSG::8913'; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Paris |
|
80
|
|
|
* Conventional value of 0h 9m 20.935s = 2°20'14.025" adopted by IGN (Paris) in 1936 converted to grads. Preferred |
|
81
|
|
|
* by EPSG to earlier value of 2°20'13.95" (2.596898 grads) used by RGS London (prime meridian code 8914). |
|
82
|
|
|
*/ |
|
83
|
|
|
public const EPSG_PARIS = 'urn:ogc:def:meridian:EPSG::8903'; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Paris RGS |
|
87
|
|
|
* Value replaced by IGN (France) in 1936 - see code 8903. Equivalent to 2.596898 grads. |
|
88
|
|
|
*/ |
|
89
|
|
|
public const EPSG_PARIS_RGS = 'urn:ogc:def:meridian:EPSG::8914'; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Rome. |
|
93
|
|
|
*/ |
|
94
|
|
|
public const EPSG_ROME = 'urn:ogc:def:meridian:EPSG::8906'; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Stockholm. |
|
98
|
|
|
*/ |
|
99
|
|
|
public const EPSG_STOCKHOLM = 'urn:ogc:def:meridian:EPSG::8911'; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @var array<string, array{name: string, greenwich_longitude: float|Angle, uom: string, help: string}> |
|
103
|
|
|
*/ |
|
104
|
|
|
protected static array $sridData = [ |
|
105
|
|
|
'urn:ogc:def:meridian:EPSG::8901' => [ |
|
106
|
|
|
'name' => 'Greenwich', |
|
107
|
|
|
'greenwich_longitude' => 0.0, |
|
108
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9102', |
|
109
|
|
|
'help' => 'The international reference meridian as defined first by the 1884 International Meridian Conference and later by the Bureau International de l\'Heure (BIH) and then the International Earth Rotation Service (IERS).', |
|
110
|
|
|
], |
|
111
|
|
|
'urn:ogc:def:meridian:EPSG::8902' => [ |
|
112
|
|
|
'name' => 'Lisbon', |
|
113
|
|
|
'greenwich_longitude' => -9.0754862, |
|
114
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
115
|
|
|
'help' => '', |
|
116
|
|
|
], |
|
117
|
|
|
'urn:ogc:def:meridian:EPSG::8903' => [ |
|
118
|
|
|
'name' => 'Paris', |
|
119
|
|
|
'greenwich_longitude' => 2.5969213, |
|
120
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9105', |
|
121
|
|
|
'help' => 'Conventional value of 0h 9m 20.935s = 2°20\'14.025" adopted by IGN (Paris) in 1936 converted to grads. Preferred by EPSG to earlier value of 2°20\'13.95" (2.596898 grads) used by RGS London (prime meridian code 8914).', |
|
122
|
|
|
], |
|
123
|
|
|
'urn:ogc:def:meridian:EPSG::8904' => [ |
|
124
|
|
|
'name' => 'Bogota', |
|
125
|
|
|
'greenwich_longitude' => -74.04513, |
|
126
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
127
|
|
|
'help' => '', |
|
128
|
|
|
], |
|
129
|
|
|
'urn:ogc:def:meridian:EPSG::8905' => [ |
|
130
|
|
|
'name' => 'Madrid', |
|
131
|
|
|
'greenwich_longitude' => -3.411455, |
|
132
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
133
|
|
|
'help' => 'Longitude has had various determinations. 3°41\'14.55"W of Greenwich adopted for Spanish cartography.', |
|
134
|
|
|
], |
|
135
|
|
|
'urn:ogc:def:meridian:EPSG::8906' => [ |
|
136
|
|
|
'name' => 'Rome', |
|
137
|
|
|
'greenwich_longitude' => 12.27084, |
|
138
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
139
|
|
|
'help' => '', |
|
140
|
|
|
], |
|
141
|
|
|
'urn:ogc:def:meridian:EPSG::8907' => [ |
|
142
|
|
|
'name' => 'Bern', |
|
143
|
|
|
'greenwich_longitude' => 7.26225, |
|
144
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
145
|
|
|
'help' => '1895 value. Newer value of 7°26\'22.335" determined in 1938.', |
|
146
|
|
|
], |
|
147
|
|
|
'urn:ogc:def:meridian:EPSG::8908' => [ |
|
148
|
|
|
'name' => 'Jakarta', |
|
149
|
|
|
'greenwich_longitude' => 106.482779, |
|
150
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
151
|
|
|
'help' => '1924 determination. Supersedes 1910 value of 106°48\'37.05"E of Greenwich.', |
|
152
|
|
|
], |
|
153
|
|
|
'urn:ogc:def:meridian:EPSG::8909' => [ |
|
154
|
|
|
'name' => 'Ferro', |
|
155
|
|
|
'greenwich_longitude' => -17.4, |
|
156
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
157
|
|
|
'help' => 'El Hierro island, Canary islands, considered the most westerly point in Europe. Its longitude has had various determinations. 17°40\'W of Greenwich was adopted by Austria and former Czechoslovakia, 17°39\'46.02"W by former Yugoslavia.', |
|
158
|
|
|
], |
|
159
|
|
|
'urn:ogc:def:meridian:EPSG::8910' => [ |
|
160
|
|
|
'name' => 'Brussels', |
|
161
|
|
|
'greenwich_longitude' => 4.220471, |
|
162
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
163
|
|
|
'help' => '', |
|
164
|
|
|
], |
|
165
|
|
|
'urn:ogc:def:meridian:EPSG::8911' => [ |
|
166
|
|
|
'name' => 'Stockholm', |
|
167
|
|
|
'greenwich_longitude' => 18.03298, |
|
168
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
169
|
|
|
'help' => '', |
|
170
|
|
|
], |
|
171
|
|
|
'urn:ogc:def:meridian:EPSG::8912' => [ |
|
172
|
|
|
'name' => 'Athens', |
|
173
|
|
|
'greenwich_longitude' => 23.4258815, |
|
174
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
175
|
|
|
'help' => 'Used in Greece for older mapping based on Hatt projection.', |
|
176
|
|
|
], |
|
177
|
|
|
'urn:ogc:def:meridian:EPSG::8913' => [ |
|
178
|
|
|
'name' => 'Oslo', |
|
179
|
|
|
'greenwich_longitude' => 10.43225, |
|
180
|
162 |
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
181
|
|
|
'help' => 'Formerly known as Kristiania or Christiania.', |
|
182
|
162 |
|
], |
|
183
|
162 |
|
'urn:ogc:def:meridian:EPSG::8914' => [ |
|
184
|
162 |
|
'name' => 'Paris RGS', |
|
185
|
|
|
'greenwich_longitude' => 2.201395, |
|
186
|
|
|
'uom' => 'urn:ogc:def:uom:EPSG::9110', |
|
187
|
3294 |
|
'help' => 'Value replaced by IGN (France) in 1936 - see code 8903. Equivalent to 2.596898 grads.', |
|
188
|
|
|
], |
|
189
|
3294 |
|
]; |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
3890 |
|
* @var array<string, self> |
|
193
|
|
|
*/ |
|
194
|
3890 |
|
private static array $cachedObjects = []; |
|
195
|
|
|
|
|
196
|
|
|
private string $name; |
|
197
|
|
|
|
|
198
|
|
|
private Angle $greenwichLongitude; |
|
199
|
|
|
|
|
200
|
|
|
private string $srid; |
|
201
|
|
|
|
|
202
|
3644 |
|
public function __construct(string $name, Angle $greenwichLongitude, string $srid = '') |
|
203
|
|
|
{ |
|
204
|
3644 |
|
$this->name = $name; |
|
205
|
9 |
|
$this->greenwichLongitude = $greenwichLongitude; |
|
206
|
|
|
$this->srid = $srid; |
|
207
|
|
|
} |
|
208
|
3635 |
|
|
|
209
|
162 |
|
public function getName(): string |
|
210
|
|
|
{ |
|
211
|
162 |
|
return $this->name; |
|
212
|
36 |
|
} |
|
213
|
|
|
|
|
214
|
126 |
|
public function getGreenwichLongitude(): Angle |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->greenwichLongitude; |
|
217
|
|
|
} |
|
218
|
3635 |
|
|
|
219
|
|
|
public function getSRID(): string |
|
220
|
|
|
{ |
|
221
|
288 |
|
return $this->srid; |
|
222
|
|
|
} |
|
223
|
288 |
|
|
|
224
|
288 |
|
public static function fromSRID(string $srid): self |
|
225
|
288 |
|
{ |
|
226
|
|
|
if (!isset(static::$sridData[$srid])) { |
|
227
|
|
|
throw new UnknownPrimeMeridianException($srid); |
|
228
|
288 |
|
} |
|
229
|
|
|
|
|
230
|
|
|
if (!isset(self::$cachedObjects[$srid])) { |
|
231
|
36 |
|
$data = static::$sridData[$srid]; |
|
232
|
|
|
|
|
233
|
36 |
|
if ($data['greenwich_longitude'] instanceof Angle) { |
|
234
|
|
|
self::$cachedObjects[$srid] = new self($data['name'], $data['greenwich_longitude'], $srid); |
|
235
|
|
|
} else { |
|
236
|
|
|
self::$cachedObjects[$srid] = new self($data['name'], Angle::makeUnit($data['greenwich_longitude'], $data['uom']), $srid); |
|
237
|
|
|
} |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
return self::$cachedObjects[$srid]; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* @return array<string, string> |
|
245
|
|
|
*/ |
|
246
|
|
|
public static function getSupportedSRIDs(): array |
|
247
|
|
|
{ |
|
248
|
|
|
return array_map(fn (array $data) => $data['name'], static::$sridData); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* @return array<string, array{name: string, help: string}> |
|
253
|
|
|
*/ |
|
254
|
|
|
public static function getSupportedSRIDsWithHelp(): array |
|
255
|
|
|
{ |
|
256
|
|
|
return array_map(fn (array $data) => ['name' => $data['name'], 'help' => $data['help']], static::$sridData); |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
public static function registerCustomMeridian(string $srid, string $name, Angle $longitudeFromGreenwich, string $help = ''): void |
|
260
|
|
|
{ |
|
261
|
|
|
self::$sridData[$srid] = ['name' => $name, 'greenwich_longitude' => $longitudeFromGreenwich, 'uom' => '', 'help' => $help]; |
|
262
|
|
|
} |
|
263
|
|
|
} |
|
264
|
|
|
|