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