|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHPCoord. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Doug Wright |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace PHPCoord\CoordinateReferenceSystem; |
|
10
|
|
|
|
|
11
|
|
|
use PHPCoord\CoordinateSystem\CoordinateSystem; |
|
12
|
|
|
use PHPCoord\Datum\Datum; |
|
13
|
|
|
use PHPCoord\Exception\UnknownCoordinateReferenceSystemException; |
|
14
|
|
|
|
|
15
|
|
|
abstract class CoordinateReferenceSystem |
|
16
|
|
|
{ |
|
17
|
|
|
public const CRS_TYPE_COMPOUND = 'compound'; |
|
18
|
|
|
|
|
19
|
|
|
public const CRS_TYPE_DERIVED = 'derived'; |
|
20
|
|
|
|
|
21
|
|
|
public const CRS_TYPE_DYNAMIC_GEOCENTRIC = 'dynamic geocentric'; |
|
22
|
|
|
|
|
23
|
|
|
public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_2D = 'dynamic geographic 2D'; |
|
24
|
|
|
|
|
25
|
|
|
public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_3D = 'dynamic geographic 3D'; |
|
26
|
|
|
|
|
27
|
|
|
public const CRS_TYPE_DYNAMIC_VERTICAL = 'dynamic vertical'; |
|
28
|
|
|
|
|
29
|
|
|
public const CRS_TYPE_ENGINEERING = 'engineering'; |
|
30
|
|
|
|
|
31
|
|
|
public const CRS_TYPE_GEOCENTRIC = 'geocentric'; |
|
32
|
|
|
|
|
33
|
|
|
public const CRS_TYPE_GEOGRAPHIC_2D = 'geographic 2D'; |
|
34
|
|
|
|
|
35
|
|
|
public const CRS_TYPE_GEOGRAPHIC_3D = 'geographic 3D'; |
|
36
|
|
|
|
|
37
|
|
|
public const CRS_TYPE_PROJECTED = 'projected'; |
|
38
|
|
|
|
|
39
|
|
|
public const CRS_TYPE_VERTICAL = 'vertical'; |
|
40
|
|
|
|
|
41
|
|
|
public const CRS_SRID_PREFIX_EPSG = 'urn:ogc:def:crs:EPSG::'; |
|
42
|
|
|
|
|
43
|
|
|
protected string $srid; |
|
44
|
|
|
|
|
45
|
|
|
protected CoordinateSystem $coordinateSystem; |
|
46
|
|
|
|
|
47
|
|
|
protected Datum $datum; |
|
48
|
|
|
|
|
49
|
|
|
public function getSRID(): string |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->srid; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getCoordinateSystem(): CoordinateSystem |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->coordinateSystem; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
46 |
|
public function getDatum(): Datum |
|
60
|
|
|
{ |
|
61
|
46 |
|
return $this->datum; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
138 |
|
public static function fromSRID(string $srid): self |
|
65
|
|
|
{ |
|
66
|
138 |
|
if (isset(Projected::getSupportedSRIDs()[$srid])) { |
|
67
|
4 |
|
return Projected::fromSRID($srid); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
138 |
|
if (isset(Geographic2D::getSupportedSRIDs()[$srid])) { |
|
71
|
136 |
|
return Geographic2D::fromSRID($srid); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
2 |
|
if (isset(Geographic3D::getSupportedSRIDs()[$srid])) { |
|
75
|
1 |
|
return Geographic3D::fromSRID($srid); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
1 |
|
if (isset(Geocentric::getSupportedSRIDs()[$srid])) { |
|
79
|
1 |
|
return Geocentric::fromSRID($srid); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if (isset(Vertical::getSupportedSRIDs()[$srid])) { |
|
83
|
|
|
return Vertical::fromSRID($srid); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if (isset(Compound::getSupportedSRIDs()[$srid])) { |
|
87
|
|
|
return Compound::fromSRID($srid); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
throw new UnknownCoordinateReferenceSystemException($srid); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public static function getSupportedSRIDs(): array |
|
94
|
|
|
{ |
|
95
|
|
|
return array_merge(Compound::getSupportedSRIDs(), Geocentric::getSupportedSRIDs(), Geographic2D::getSupportedSRIDs(), Geographic3D::getSupportedSRIDs(), Projected::getSupportedSRIDs(), Vertical::getSupportedSRIDs()); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|