Passed
Push — 4.x ( f9780c...a64886 )
by Doug
05:20
created

Ellipsoid::getFlattening()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\Datum;
10
11
use function array_map;
12
use PHPCoord\Exception\UnknownEllipsoidException;
13
use PHPCoord\UnitOfMeasure\Length\Length;
14
use function sqrt;
15
16
class Ellipsoid
17
{
18
    /**
19
     * Airy 1830
20
     * Original definition is a=20923713, b=20853810 feet of 1796. 1/f is given to 7 decimal places. For the 1936
21
     * retriangulation OSGB defines the relationship of 10 feet of 1796 to the International metre through
22
     * ([10^0.48401603]/10) exactly = 0.3048007491...
23
     */
24
    public const EPSG_AIRY_1830 = 'urn:ogc:def:ellipsoid:EPSG::7001';
25
26
    /**
27
     * Airy Modified 1849
28
     * OSGB Airy 1830 figure (ellipsoid code 7001) rescaled by 0.999965 to best fit the scale of the 19th century
29
     * primary triangulation of Ireland.
30
     */
31
    public const EPSG_AIRY_MODIFIED_1849 = 'urn:ogc:def:ellipsoid:EPSG::7002';
32
33
    /**
34
     * Australian National Spheroid
35
     * Based on the GRS 1967 figure but with 1/f taken to 2 decimal places exactly.  The dimensions are also used as
36
     * the GRS 1967 Modified ellipsoid (see code 7050).
37
     */
38
    public const EPSG_AUSTRALIAN_NATIONAL_SPHEROID = 'urn:ogc:def:ellipsoid:EPSG::7003';
39
40
    /**
41
     * Average Terrestrial System 1977.
42
     */
43
    public const EPSG_AVERAGE_TERRESTRIAL_SYSTEM_1977 = 'urn:ogc:def:ellipsoid:EPSG::7041';
44
45
    /**
46
     * Bessel 1841
47
     * Original Bessel definition is a=3272077.14 and b=3261139.33 toise. This used a weighted mean of values from
48
     * several authors but did not account for differences in the length of the various toise: the "Bessel toise" is
49
     * therefore of uncertain length.
50
     */
51
    public const EPSG_BESSEL_1841 = 'urn:ogc:def:ellipsoid:EPSG::7004';
52
53
    /**
54
     * Bessel Modified
55
     * Used in Norway and also in Sweden with a 1mm increase in semi-major axis.
56
     */
57
    public const EPSG_BESSEL_MODIFIED = 'urn:ogc:def:ellipsoid:EPSG::7005';
58
59
    /**
60
     * Bessel Namibia (GLM)
61
     * The semi-major axis has the same value as the Bessel 1841 ellipsoid (code 7004) but is in different units -
62
     * German Legal Metres rather than International metres - hence a different size.  a = 6377483.865 International
63
     * metres. Used in Namibia.
64
     */
65
    public const EPSG_BESSEL_NAMIBIA_GLM = 'urn:ogc:def:ellipsoid:EPSG::7046';
66
67
    /**
68
     * CGCS2000
69
     * Defining parameters semi-major axis, flattening and angular velocity are same as for GRS 1980 (ellipsoid code
70
     * 7019); GM = 3986004.4e8 m*m*m/s/s (from NASA 1986 Lageos determination).
71
     */
72
    public const EPSG_CGCS2000 = 'urn:ogc:def:ellipsoid:EPSG::1024';
73
74
    /**
75
     * Clarke 1858
76
     * Clarke's 1858/II solution. Derived parameters: a = 6378293.645m using his 1865 ratio of 0.3047972654 feet per
77
     * metre; 1/f = 294.26068…  In Australia and Amoco Trinidad 1/f taken to two decimal places (294.26 exactly);
78
     * elsewhere a and b used to derive 1/f.
79
     */
80
    public const EPSG_CLARKE_1858 = 'urn:ogc:def:ellipsoid:EPSG::7007';
81
82
    /**
83
     * Clarke 1866
84
     * Original definition a=20926062 and b=20855121 (British) feet. Uses Clarke's 1865 inch-metre ratio of 39.370432
85
     * to obtain metres. (Metric value then converted to US survey feet for use in the US and international feet for
86
     * use in Cayman Islands).
87
     */
88
    public const EPSG_CLARKE_1866 = 'urn:ogc:def:ellipsoid:EPSG::7008';
89
90
    /**
91
     * Clarke 1866 Authalic Sphere
92
     * Authalic sphere derived from Clarke 1866 ellipsoid (code 7008).
93
     */
94
    public const EPSG_CLARKE_1866_AUTHALIC_SPHERE = 'urn:ogc:def:ellipsoid:EPSG::7052';
95
96
    /**
97
     * Clarke 1880
98
     * Clarke gave a and b and also 1/f=293.465 (to 3 decimal places exactly). In the 19th century b was normally given
99
     * as the second defining parameter.
100
     */
101
    public const EPSG_CLARKE_1880 = 'urn:ogc:def:ellipsoid:EPSG::7034';
102
103
    /**
104
     * Clarke 1880 (Arc)
105
     * Adopts Clarke's value for a with derived 1/f.  Uses his 1865 ratio of 39.370432 inch per metre to convert
106
     * semi-major axis to metres.
107
     */
108
    public const EPSG_CLARKE_1880_ARC = 'urn:ogc:def:ellipsoid:EPSG::7013';
109
110
    /**
111
     * Clarke 1880 (Benoit)
112
     * Adopts Clarke's values for a and b.  Uses Benoit's 1895 ratio of 0.9143992 metres per yard to convert to metres.
113
     */
114
    public const EPSG_CLARKE_1880_BENOIT = 'urn:ogc:def:ellipsoid:EPSG::7010';
115
116
    /**
117
     * Clarke 1880 (IGN)
118
     * Adopts Clarke's values for a and b using his 1865 ratio of 39.370432 inches per metre to convert axes to metres.
119
     */
120
    public const EPSG_CLARKE_1880_IGN = 'urn:ogc:def:ellipsoid:EPSG::7011';
121
122
    /**
123
     * Clarke 1880 (RGS)
124
     * Adopts Clarke's values for a and 1/f.  Adopts his 1865 ratio of 39.370432 inches per metre to convert semi-major
125
     * axis to metres. Also known as Clarke Modified 1880.
126
     */
127
    public const EPSG_CLARKE_1880_RGS = 'urn:ogc:def:ellipsoid:EPSG::7012';
128
129
    /**
130
     * Clarke 1880 (SGA 1922)
131
     * Used in Old French Triangulation (ATF).   Uses Clarke's 1865 inch-metre ratio of 39.370432 to convert axes to
132
     * metres.
133
     */
134
    public const EPSG_CLARKE_1880_SGA_1922 = 'urn:ogc:def:ellipsoid:EPSG::7014';
135
136
    /**
137
     * Clarke 1880 (international foot)
138
     * Clarke's 1880 definition in feet assumed for the purposes of metric conversion to be international foot. a =
139
     * 6378306.370…metres. 1/f derived from a and b = 293.4663077… Used in Fiji.
140
     */
141
    public const EPSG_CLARKE_1880_INTERNATIONAL_FOOT = 'urn:ogc:def:ellipsoid:EPSG::7055';
142
143
    /**
144
     * Danish 1876
145
     * Semi-major axis originally given as 3271883.25 toise. Uses toise to French metre ratio of 1.94903631 to two
146
     * decimal place precision. An alternative ratio with the German legal metre of 1.9490622 giving 6377104m has not
147
     * been used in Danish work.
148
     */
149
    public const EPSG_DANISH_1876 = 'urn:ogc:def:ellipsoid:EPSG::7051';
150
151
    /**
152
     * Everest (1830 Definition)
153
     * Everest gave a and b to 2 decimal places and also 1/f=300.8017 (to 4 decimal places exactly). In the 19th
154
     * century b was normally given as the second defining parameter.
155
     */
156
    public const EPSG_EVEREST_1830_DEFINITION = 'urn:ogc:def:ellipsoid:EPSG::7042';
157
158
    /**
159
     * Everest 1830 (1937 Adjustment)
160
     * Used for the 1937 readjustment of Indian triangulation.  Clarke's 1865 Indian-British foot ratio (0.99999566)
161
     * and Benoit's 1898 British inch-metre ratio (39.370113) rounded as 0.30479841 exactly and applied to Everest's
162
     * 1830 definition taken as a and 1/f.
163
     */
164
    public const EPSG_EVEREST_1830_1937_ADJUSTMENT = 'urn:ogc:def:ellipsoid:EPSG::7015';
165
166
    /**
167
     * Everest 1830 (1962 Definition)
168
     * Used by Pakistan since metrication.  Clarke's 1865 Indian foot-British foot ratio (0.99999566) and his 1865
169
     * British inch-metre ratio (39.369971) rounded with slight error as 1 Ind ft = 0.3047995m exactly and applied to
170
     * Everest's 1830 definition of a & b.
171
     */
172
    public const EPSG_EVEREST_1830_1962_DEFINITION = 'urn:ogc:def:ellipsoid:EPSG::7044';
173
174
    /**
175
     * Everest 1830 (1967 Definition)
176
     * Adopted 1967 for use in East Malaysia.  Applies Sears 1922 inch-metre ratio of 39.370147 to Everest 1830
177
     * original definition of a and 1/f but with a taken to be in British rather than Indian feet.
178
     */
179
    public const EPSG_EVEREST_1830_1967_DEFINITION = 'urn:ogc:def:ellipsoid:EPSG::7016';
180
181
    /**
182
     * Everest 1830 (1975 Definition)
183
     * Used by India since metrication.  Clarke's 1865 Indian foot-British foot ratio (0.99999566) and his 1865 British
184
     * inch-metre ratio (39.369971) rounded as 1 Ind ft = 0.3047995m exactly applied to Everest's 1830 original
185
     * definition taken as a and b.
186
     */
187
    public const EPSG_EVEREST_1830_1975_DEFINITION = 'urn:ogc:def:ellipsoid:EPSG::7045';
188
189
    /**
190
     * Everest 1830 (RSO 1969)
191
     * Adopted for 1969 metrication of peninsula Malaysia RSO grid.  Uses Sears 1922 yard-metre ratio truncated to 6
192
     * significant figures applied to Everest 1830 original definition of a and 1/f but with a taken to be in British
193
     * rather than Indian feet.
194
     */
195
    public const EPSG_EVEREST_1830_RSO_1969 = 'urn:ogc:def:ellipsoid:EPSG::7056';
196
197
    /**
198
     * Everest 1830 Modified
199
     * Adopted 1967 for use in West Malaysia.  Applies Benoit 1898 inch-metre ratio of 39.370113 to Everest 1830
200
     * original definition of a and 1/f but with a taken to be in British rather than Indian feet.
201
     */
202
    public const EPSG_EVEREST_1830_MODIFIED = 'urn:ogc:def:ellipsoid:EPSG::7018';
203
204
    /**
205
     * GEM 10C
206
     * Used for  GEM 10C Gravity Potential Model.
207
     */
208
    public const EPSG_GEM_10C = 'urn:ogc:def:ellipsoid:EPSG::7031';
209
210
    /**
211
     * GRS 1967
212
     * Adopted by IUGG 1967 Lucerne.  1/f given is derived from geocentric gravitational constant (GM)= 398603e9
213
     * m*m*m/s/s; dynamic form factor (J2) = 0.0010827 and Earth's angular velocity w = 7.2921151467e-5 rad/s. See also
214
     * GRS 1967 Modified (code 7050).
215
     */
216
    public const EPSG_GRS_1967 = 'urn:ogc:def:ellipsoid:EPSG::7036';
217
218
    /**
219
     * GRS 1967 Modified
220
     * Based on the GRS 1967 figure (code 7036) but with 1/f taken to 2 decimal places exactly. Used with SAD69 and
221
     * TWD67 datums. The dimensions are also used as the Australian National Spheroid (code 7003).
222
     */
223
    public const EPSG_GRS_1967_MODIFIED = 'urn:ogc:def:ellipsoid:EPSG::7050';
224
225
    /**
226
     * GRS 1980
227
     * Adopted by IUGG 1979 Canberra.  Inverse flattening is derived from geocentric gravitational constant GM =
228
     * 3986005e8 m*m*m/s/s; dynamic form factor J2 = 108263e-8 and Earth's angular velocity = 7292115e-11 rad/s.
229
     */
230
    public const EPSG_GRS_1980 = 'urn:ogc:def:ellipsoid:EPSG::7019';
231
232
    /**
233
     * GRS 1980 Authalic Sphere
234
     * Authalic sphere derived from GRS 1980 ellipsoid (code 7019).  (An authalic sphere is one with a surface area
235
     * equal to the surface area of the ellipsoid). 1/f is infinite.
236
     */
237
    public const EPSG_GRS_1980_AUTHALIC_SPHERE = 'urn:ogc:def:ellipsoid:EPSG::7048';
238
239
    /**
240
     * GSK-2011.
241
     */
242
    public const EPSG_GSK_2011 = 'urn:ogc:def:ellipsoid:EPSG::1025';
243
244
    /**
245
     * Helmert 1906
246
     * Helmert 1906/III solution.
247
     */
248
    public const EPSG_HELMERT_1906 = 'urn:ogc:def:ellipsoid:EPSG::7020';
249
250
    /**
251
     * Hough 1960.
252
     */
253
    public const EPSG_HOUGH_1960 = 'urn:ogc:def:ellipsoid:EPSG::7053';
254
255
    /**
256
     * Hughes 1980
257
     * Used in US DMSP SSM/I microwave sensor processing software. Semi-minor axis derived from
258
     * eccentricity=0.081816153. Semi-major axis (a) sometimes given as 3443.992nm which OGP suspects is a derived
259
     * approximation. OGP conversion assumes 1nm=1852m exactly.
260
     */
261
    public const EPSG_HUGHES_1980 = 'urn:ogc:def:ellipsoid:EPSG::7058';
262
263
    /**
264
     * IAG 1975.
265
     */
266
    public const EPSG_IAG_1975 = 'urn:ogc:def:ellipsoid:EPSG::7049';
267
268
    /**
269
     * Indonesian National Spheroid
270
     * Based on the GRS 1967 figure but with 1/f taken to 3 decimal places exactly.
271
     */
272
    public const EPSG_INDONESIAN_NATIONAL_SPHEROID = 'urn:ogc:def:ellipsoid:EPSG::7021';
273
274
    /**
275
     * International 1924
276
     * Adopted by IUGG 1924 in Madrid. Based on Hayford 1909/1910 figures.
277
     */
278
    public const EPSG_INTERNATIONAL_1924 = 'urn:ogc:def:ellipsoid:EPSG::7022';
279
280
    /**
281
     * International 1924 Authalic Sphere
282
     * Authalic sphere derived from International 1924 ellipsoid (code 7022).
283
     */
284
    public const EPSG_INTERNATIONAL_1924_AUTHALIC_SPHERE = 'urn:ogc:def:ellipsoid:EPSG::7057';
285
286
    /**
287
     * Krassowsky 1940.
288
     */
289
    public const EPSG_KRASSOWSKY_1940 = 'urn:ogc:def:ellipsoid:EPSG::7024';
290
291
    /**
292
     * NWL 9D
293
     * Used by Transit Precise Ephemeris between October 1971 and January 1987.
294
     */
295
    public const EPSG_NWL_9D = 'urn:ogc:def:ellipsoid:EPSG::7025';
296
297
    /**
298
     * OSU86F
299
     * Used for OSU86 gravity potential (geoidal) model.
300
     */
301
    public const EPSG_OSU86F = 'urn:ogc:def:ellipsoid:EPSG::7032';
302
303
    /**
304
     * OSU91A
305
     * Used for OSU91 gravity potential (geoidal) model.
306
     */
307
    public const EPSG_OSU91A = 'urn:ogc:def:ellipsoid:EPSG::7033';
308
309
    /**
310
     * PZ-90
311
     * Earth's angular velocity ω = 7.292115e-5 rad/sec; gravitational constant GM =  3986004.418e8 m*m*m/s/s.
312
     */
313
    public const EPSG_PZ_90 = 'urn:ogc:def:ellipsoid:EPSG::7054';
314
315
    /**
316
     * Plessis 1817
317
     * Rescaling of Delambre 1810 figure (a=6376985 m) to make meridional arc from equator to pole equal to 10000000
318
     * metres exactly. (Ref: Strasser).
319
     */
320
    public const EPSG_PLESSIS_1817 = 'urn:ogc:def:ellipsoid:EPSG::7027';
321
322
    /**
323
     * Struve 1860
324
     * Original definition of semi-major axis given as 3272539 toise.  In "Ellipsoidisch Parameter der Erdfigur
325
     * (1800-1950)" , Strasser suggests a conversion factor of 1.94903631 which gives a=6378297.337 metres.
326
     */
327
    public const EPSG_STRUVE_1860 = 'urn:ogc:def:ellipsoid:EPSG::7028';
328
329
    /**
330
     * WGS 72.
331
     */
332
    public const EPSG_WGS_72 = 'urn:ogc:def:ellipsoid:EPSG::7043';
333
334
    /**
335
     * WGS 84
336
     * 1/f derived from four defining parameters semi-major axis; C20 = -484.16685*10e-6; earth's angular velocity ω =
337
     * 7292115e-11 rad/sec; gravitational constant GM = 3986005e8 m*m*m/s/s. In 1994 new GM = 3986004.418e8 m*m*m/s/s
338
     * but a and 1/f retained.
339
     */
340
    public const EPSG_WGS_84 = 'urn:ogc:def:ellipsoid:EPSG::7030';
341
342
    /**
343
     * War Office
344
     * In non-metric form, a=20926201 Gold Coast feet. DMA Technical Manual 8358.1 and data derived from this quotes
345
     * value for semi-major axis as 6378300.58m: OGP recommends use of defined value 6378300m exactly.
346
     */
347
    public const EPSG_WAR_OFFICE = 'urn:ogc:def:ellipsoid:EPSG::7029';
348
349
    /**
350
     * Zach 1812
351
     * Defined as log a = 6.5266022 Klafter (Austrian fathom, Kl), log b = 6.5251990 Kl. a=10^6.526 6022 = 3362035 Kl.
352
     * Then using the Austro-Hungarian 1871 KL/m legal ratio of 1.89648384, a = 6376045m.
353
     */
354
    public const EPSG_ZACH_1812 = 'urn:ogc:def:ellipsoid:EPSG::1026';
355
356
    protected static array $sridData = [
357
        'urn:ogc:def:ellipsoid:EPSG::1024' => [
358
            'name' => 'CGCS2000',
359
            'semi_major_axis' => 6378137.0,
360
            'semi_minor_axis' => 6356752.314140356,
361
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
362
        ],
363
        'urn:ogc:def:ellipsoid:EPSG::1025' => [
364
            'name' => 'GSK-2011',
365
            'semi_major_axis' => 6378136.5,
366
            'semi_minor_axis' => 6356751.757955603,
367
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
368
        ],
369
        'urn:ogc:def:ellipsoid:EPSG::1026' => [
370
            'name' => 'Zach 1812',
371
            'semi_major_axis' => 6376045.0,
372
            'semi_minor_axis' => 6355477.112903226,
373
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
374
        ],
375
        'urn:ogc:def:ellipsoid:EPSG::7001' => [
376
            'name' => 'Airy 1830',
377
            'semi_major_axis' => 6377563.396,
378
            'semi_minor_axis' => 6356256.909237285,
379
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
380
        ],
381
        'urn:ogc:def:ellipsoid:EPSG::7002' => [
382
            'name' => 'Airy Modified 1849',
383
            'semi_major_axis' => 6377340.189,
384
            'semi_minor_axis' => 6356034.447938534,
385
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
386
        ],
387
        'urn:ogc:def:ellipsoid:EPSG::7003' => [
388
            'name' => 'Australian National Spheroid',
389
            'semi_major_axis' => 6378160.0,
390
            'semi_minor_axis' => 6356774.719195306,
391
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
392
        ],
393
        'urn:ogc:def:ellipsoid:EPSG::7004' => [
394
            'name' => 'Bessel 1841',
395
            'semi_major_axis' => 6377397.155,
396
            'semi_minor_axis' => 6356078.962818189,
397
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
398
        ],
399
        'urn:ogc:def:ellipsoid:EPSG::7005' => [
400
            'name' => 'Bessel Modified',
401
            'semi_major_axis' => 6377492.018,
402
            'semi_minor_axis' => 6356173.508712696,
403
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
404
        ],
405
        'urn:ogc:def:ellipsoid:EPSG::7007' => [
406
            'name' => 'Clarke 1858',
407
            'semi_major_axis' => 20926348.0,
408
            'semi_minor_axis' => 20855233.0,
409
            'uom' => 'urn:ogc:def:uom:EPSG::9005',
410
        ],
411
        'urn:ogc:def:ellipsoid:EPSG::7008' => [
412
            'name' => 'Clarke 1866',
413
            'semi_major_axis' => 6378206.4,
414
            'semi_minor_axis' => 6356583.8,
415
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
416
        ],
417
        'urn:ogc:def:ellipsoid:EPSG::7010' => [
418
            'name' => 'Clarke 1880 (Benoit)',
419
            'semi_major_axis' => 6378300.789,
420
            'semi_minor_axis' => 6356566.435,
421
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
422
        ],
423
        'urn:ogc:def:ellipsoid:EPSG::7011' => [
424
            'name' => 'Clarke 1880 (IGN)',
425
            'semi_major_axis' => 6378249.2,
426
            'semi_minor_axis' => 6356515.0,
427
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
428
        ],
429
        'urn:ogc:def:ellipsoid:EPSG::7012' => [
430
            'name' => 'Clarke 1880 (RGS)',
431
            'semi_major_axis' => 6378249.145,
432
            'semi_minor_axis' => 6356514.8695497755,
433
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
434
        ],
435
        'urn:ogc:def:ellipsoid:EPSG::7013' => [
436
            'name' => 'Clarke 1880 (Arc)',
437
            'semi_major_axis' => 6378249.145,
438
            'semi_minor_axis' => 6356514.966398753,
439
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
440
        ],
441
        'urn:ogc:def:ellipsoid:EPSG::7014' => [
442
            'name' => 'Clarke 1880 (SGA 1922)',
443
            'semi_major_axis' => 6378249.2,
444
            'semi_minor_axis' => 6356514.996941779,
445
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
446
        ],
447
        'urn:ogc:def:ellipsoid:EPSG::7015' => [
448
            'name' => 'Everest 1830 (1937 Adjustment)',
449
            'semi_major_axis' => 6377276.345,
450
            'semi_minor_axis' => 6356075.413140239,
451
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
452
        ],
453
        'urn:ogc:def:ellipsoid:EPSG::7016' => [
454
            'name' => 'Everest 1830 (1967 Definition)',
455
            'semi_major_axis' => 6377298.556,
456
            'semi_minor_axis' => 6356097.550300896,
457
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
458
        ],
459
        'urn:ogc:def:ellipsoid:EPSG::7018' => [
460
            'name' => 'Everest 1830 Modified',
461
            'semi_major_axis' => 6377304.063,
462
            'semi_minor_axis' => 6356103.038993155,
463
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
464
        ],
465
        'urn:ogc:def:ellipsoid:EPSG::7019' => [
466
            'name' => 'GRS 1980',
467
            'semi_major_axis' => 6378137.0,
468
            'semi_minor_axis' => 6356752.314140356,
469
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
470
        ],
471
        'urn:ogc:def:ellipsoid:EPSG::7020' => [
472
            'name' => 'Helmert 1906',
473
            'semi_major_axis' => 6378200.0,
474
            'semi_minor_axis' => 6356818.169627891,
475
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
476
        ],
477
        'urn:ogc:def:ellipsoid:EPSG::7021' => [
478
            'name' => 'Indonesian National Spheroid',
479
            'semi_major_axis' => 6378160.0,
480
            'semi_minor_axis' => 6356774.50408554,
481
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
482
        ],
483
        'urn:ogc:def:ellipsoid:EPSG::7022' => [
484
            'name' => 'International 1924',
485
            'semi_major_axis' => 6378388.0,
486
            'semi_minor_axis' => 6356911.9461279465,
487
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
488
        ],
489
        'urn:ogc:def:ellipsoid:EPSG::7024' => [
490
            'name' => 'Krassowsky 1940',
491
            'semi_major_axis' => 6378245.0,
492
            'semi_minor_axis' => 6356863.018773047,
493
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
494
        ],
495
        'urn:ogc:def:ellipsoid:EPSG::7025' => [
496
            'name' => 'NWL 9D',
497
            'semi_major_axis' => 6378145.0,
498
            'semi_minor_axis' => 6356759.769488684,
499
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
500
        ],
501
        'urn:ogc:def:ellipsoid:EPSG::7027' => [
502
            'name' => 'Plessis 1817',
503
            'semi_major_axis' => 6376523.0,
504
            'semi_minor_axis' => 6355862.933255573,
505
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
506
        ],
507
        'urn:ogc:def:ellipsoid:EPSG::7028' => [
508
            'name' => 'Struve 1860',
509
            'semi_major_axis' => 6378298.3,
510
            'semi_minor_axis' => 6356657.142669562,
511
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
512
        ],
513
        'urn:ogc:def:ellipsoid:EPSG::7029' => [
514
            'name' => 'War Office',
515
            'semi_major_axis' => 6378300.0,
516
            'semi_minor_axis' => 6356751.689189189,
517
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
518
        ],
519
        'urn:ogc:def:ellipsoid:EPSG::7030' => [
520
            'name' => 'WGS 84',
521
            'semi_major_axis' => 6378137.0,
522
            'semi_minor_axis' => 6356752.314245179,
523
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
524
        ],
525
        'urn:ogc:def:ellipsoid:EPSG::7031' => [
526
            'name' => 'GEM 10C',
527
            'semi_major_axis' => 6378137.0,
528
            'semi_minor_axis' => 6356752.314245179,
529
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
530
        ],
531
        'urn:ogc:def:ellipsoid:EPSG::7032' => [
532
            'name' => 'OSU86F',
533
            'semi_major_axis' => 6378136.2,
534
            'semi_minor_axis' => 6356751.516927429,
535
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
536
        ],
537
        'urn:ogc:def:ellipsoid:EPSG::7033' => [
538
            'name' => 'OSU91A',
539
            'semi_major_axis' => 6378136.3,
540
            'semi_minor_axis' => 6356751.616592146,
541
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
542
        ],
543
        'urn:ogc:def:ellipsoid:EPSG::7034' => [
544
            'name' => 'Clarke 1880',
545
            'semi_major_axis' => 20926202.0,
546
            'semi_minor_axis' => 20854895.0,
547
            'uom' => 'urn:ogc:def:uom:EPSG::9005',
548
        ],
549
        'urn:ogc:def:ellipsoid:EPSG::7036' => [
550
            'name' => 'GRS 1967',
551
            'semi_major_axis' => 6378160.0,
552
            'semi_minor_axis' => 6356774.516090714,
553
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
554
        ],
555
        'urn:ogc:def:ellipsoid:EPSG::7041' => [
556
            'name' => 'Average Terrestrial System 1977',
557
            'semi_major_axis' => 6378135.0,
558
            'semi_minor_axis' => 6356750.304921594,
559
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
560
        ],
561
        'urn:ogc:def:ellipsoid:EPSG::7042' => [
562
            'name' => 'Everest (1830 Definition)',
563
            'semi_major_axis' => 20922931.8,
564
            'semi_minor_axis' => 20853374.58,
565
            'uom' => 'urn:ogc:def:uom:EPSG::9080',
566
        ],
567
        'urn:ogc:def:ellipsoid:EPSG::7043' => [
568
            'name' => 'WGS 72',
569
            'semi_major_axis' => 6378135.0,
570
            'semi_minor_axis' => 6356750.520016094,
571
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
572
        ],
573
        'urn:ogc:def:ellipsoid:EPSG::7044' => [
574
            'name' => 'Everest 1830 (1962 Definition)',
575
            'semi_major_axis' => 6377301.243,
576
            'semi_minor_axis' => 6356100.230165385,
577
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
578
        ],
579
        'urn:ogc:def:ellipsoid:EPSG::7045' => [
580
            'name' => 'Everest 1830 (1975 Definition)',
581
            'semi_major_axis' => 6377299.151,
582
            'semi_minor_axis' => 6356098.145120132,
583
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
584
        ],
585
        'urn:ogc:def:ellipsoid:EPSG::7046' => [
586
            'name' => 'Bessel Namibia (GLM)',
587
            'semi_major_axis' => 6377397.155,
588
            'semi_minor_axis' => 6356078.962818189,
589
            'uom' => 'urn:ogc:def:uom:EPSG::9031',
590
        ],
591
        'urn:ogc:def:ellipsoid:EPSG::7048' => [
592
            'name' => 'GRS 1980 Authalic Sphere',
593
            'semi_major_axis' => 6371007.0,
594
            'semi_minor_axis' => 6371007.0,
595
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
596
        ],
597
        'urn:ogc:def:ellipsoid:EPSG::7049' => [
598
            'name' => 'IAG 1975',
599
            'semi_major_axis' => 6378140.0,
600
            'semi_minor_axis' => 6356755.288157528,
601
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
602
        ],
603
        'urn:ogc:def:ellipsoid:EPSG::7050' => [
604
            'name' => 'GRS 1967 Modified',
605
            'semi_major_axis' => 6378160.0,
606
            'semi_minor_axis' => 6356774.719195306,
607
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
608
        ],
609
        'urn:ogc:def:ellipsoid:EPSG::7051' => [
610
            'name' => 'Danish 1876',
611
            'semi_major_axis' => 6377019.27,
612
            'semi_minor_axis' => 6355762.5391,
613
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
614
        ],
615
        'urn:ogc:def:ellipsoid:EPSG::7052' => [
616
            'name' => 'Clarke 1866 Authalic Sphere',
617
            'semi_major_axis' => 6370997.0,
618
            'semi_minor_axis' => 6370997.0,
619
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
620
        ],
621
        'urn:ogc:def:ellipsoid:EPSG::7053' => [
622
            'name' => 'Hough 1960',
623
            'semi_major_axis' => 6378270.0,
624
            'semi_minor_axis' => 6356794.343434343,
625
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
626
        ],
627
        'urn:ogc:def:ellipsoid:EPSG::7054' => [
628
            'name' => 'PZ-90',
629
            'semi_major_axis' => 6378136.0,
630
            'semi_minor_axis' => 6356751.361745712,
631
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
632
        ],
633
        'urn:ogc:def:ellipsoid:EPSG::7055' => [
634
            'name' => 'Clarke 1880 (international foot)',
635
            'semi_major_axis' => 20926202.0,
636
            'semi_minor_axis' => 20854895.0,
637
            'uom' => 'urn:ogc:def:uom:EPSG::9002',
638
        ],
639
        'urn:ogc:def:ellipsoid:EPSG::7056' => [
640
            'name' => 'Everest 1830 (RSO 1969)',
641
            'semi_major_axis' => 6377295.664,
642
            'semi_minor_axis' => 6356094.667915204,
643
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
644
        ],
645
        'urn:ogc:def:ellipsoid:EPSG::7057' => [
646
            'name' => 'International 1924 Authalic Sphere',
647
            'semi_major_axis' => 6371228.0,
648
            'semi_minor_axis' => 6371228.0,
649
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
650
        ],
651
        'urn:ogc:def:ellipsoid:EPSG::7058' => [
652
            'name' => 'Hughes 1980',
653
            'semi_major_axis' => 6378273.0,
654
            'semi_minor_axis' => 6356889.449,
655
            'uom' => 'urn:ogc:def:uom:EPSG::9001',
656
        ],
657
    ];
658
659
    protected Length $semiMajorAxis;
660
661
    protected Length $semiMinorAxis;
662
663 212
    public function __construct(Length $semiMajorAxis, Length $semiMinorAxis)
664
    {
665 212
        $this->semiMajorAxis = $semiMajorAxis;
666 212
        $this->semiMinorAxis = $semiMinorAxis;
667 212
    }
668
669 112
    public function getSemiMajorAxis(): Length
670
    {
671 112
        return $this->semiMajorAxis;
672
    }
673
674 5
    public function getSemiMinorAxis(): Length
675
    {
676 5
        return $this->semiMinorAxis;
677
    }
678
679 100
    public function getInverseFlattening(): float
680
    {
681 100
        return ($this->semiMajorAxis->getValue() - $this->semiMinorAxis->getValue()) / $this->semiMajorAxis->getValue();
682
    }
683
684 72
    public function getEccentricity(): float
685
    {
686 72
        return sqrt($this->getEccentricitySquared());
687
    }
688
689 100
    public function getEccentricitySquared(): float
690
    {
691 100
        return (2 * $this->getInverseFlattening()) - $this->getInverseFlattening() ** 2;
692
    }
693
694 213
    public static function fromSRID(string $srid): self
695
    {
696 213
        if (!isset(static::$sridData[$srid])) {
697 1
            throw new UnknownEllipsoidException($srid);
698
        }
699
700 212
        $data = static::$sridData[$srid];
701
702 212
        return new static(
703 212
            Length::makeUnit($data['semi_major_axis'], $data['uom']),
704 212
            Length::makeUnit($data['semi_minor_axis'], $data['uom'])
705
        );
706
    }
707
708 1
    public static function getSupportedSRIDs(): array
709
    {
710 1
        return array_map(function ($sridData) {return $sridData['name']; }, static::$sridData);
711
    }
712
}
713