1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PHPCoord. |
4
|
|
|
* |
5
|
|
|
* @author Doug Wright |
6
|
|
|
*/ |
7
|
|
|
declare(strict_types=1); |
8
|
|
|
|
9
|
|
|
namespace PHPCoord\Coordinate\ReferenceSystem; |
10
|
|
|
|
11
|
|
|
use PHPCoord\Coordinate\System\CoordinateSystem; |
12
|
|
|
use PHPCoord\Datum\Datum; |
13
|
|
|
use PHPCoord\EPSG\Repository; |
14
|
|
|
use PHPCoord\Exception\UnknownCoordinateReferenceSystemException; |
15
|
|
|
|
16
|
|
|
abstract class CoordinateReferenceSystem implements CoordinateReferenceSystemIds |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
public const CRS_TYPE_COMPOUND = 'compound'; |
19
|
|
|
|
20
|
|
|
public const CRS_TYPE_DERIVED = 'derived'; |
21
|
|
|
|
22
|
|
|
public const CRS_TYPE_DYNAMIC_GEOCENTRIC = 'dynamic geocentric'; |
23
|
|
|
|
24
|
|
|
public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_2D = 'dynamic geographic 2D'; |
25
|
|
|
|
26
|
|
|
public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_3D = 'dynamic geographic 3D'; |
27
|
|
|
|
28
|
|
|
public const CRS_TYPE_DYNAMIC_VERTICAL = 'dynamic vertical'; |
29
|
|
|
|
30
|
|
|
public const CRS_TYPE_ENGINEERING = 'engineering'; |
31
|
|
|
|
32
|
|
|
public const CRS_TYPE_GEOCENTRIC = 'geocentric'; |
33
|
|
|
|
34
|
|
|
public const CRS_TYPE_GEOGRAPHIC_2D = 'geographic 2D'; |
35
|
|
|
|
36
|
|
|
public const CRS_TYPE_GEOGRAPHIC_3D = 'geographic 3D'; |
37
|
|
|
|
38
|
|
|
public const CRS_TYPE_PROJECTED = 'projected'; |
39
|
|
|
|
40
|
|
|
public const CRS_TYPE_VERTICAL = 'vertical'; |
41
|
|
|
|
42
|
|
|
/** @var int */ |
43
|
|
|
protected $epsgCode; |
44
|
|
|
|
45
|
|
|
/** @var CoordinateSystem */ |
46
|
|
|
protected $coordinateSystem; |
47
|
|
|
|
48
|
|
|
/** @var Datum */ |
49
|
|
|
protected $datum; |
50
|
|
|
|
51
|
|
|
/** @var CoordinateReferenceSystem */ |
52
|
|
|
protected $baseCRS; |
53
|
|
|
|
54
|
|
|
/** @var Repository */ |
55
|
|
|
private static $repository; |
56
|
|
|
|
57
|
|
|
public static function fromEPSGCode(int $epsgCode): self |
58
|
|
|
{ |
59
|
|
|
$repository = static::$repository ?? new Repository(); |
|
|
|
|
60
|
|
|
$allData = $repository->getCoordinateReferenceSystems(true); |
61
|
|
|
|
62
|
|
|
if (!isset($allData[$epsgCode])) { |
63
|
|
|
throw new UnknownCoordinateReferenceSystemException($epsgCode); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$data = $allData[$epsgCode]; |
67
|
|
|
|
68
|
|
|
switch ($data['coord_ref_sys_kind']) { |
69
|
|
|
case self::CRS_TYPE_GEOCENTRIC: |
70
|
|
|
return new Geocentric( |
71
|
|
|
$epsgCode, |
72
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
73
|
|
|
$data['datum_code'] ? Datum::fromEPSGCode($data['datum_code']) : self::fromEPSGCode($data['base_crs_code'])->getDatum() |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
case self::CRS_TYPE_DYNAMIC_GEOCENTRIC: |
77
|
|
|
return new DynamicGeocentric( |
78
|
|
|
$epsgCode, |
79
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
80
|
|
|
$data['datum_code'] ? Datum::fromEPSGCode($data['datum_code']) : self::fromEPSGCode($data['base_crs_code'])->getDatum() |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
case self::CRS_TYPE_GEOGRAPHIC_2D: |
84
|
|
|
return new Geographic2D( |
85
|
|
|
$epsgCode, |
86
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
87
|
|
|
$data['datum_code'] ? Datum::fromEPSGCode($data['datum_code']) : self::fromEPSGCode($data['base_crs_code'])->getDatum() |
88
|
|
|
); |
89
|
|
|
|
90
|
|
|
case self::CRS_TYPE_DYNAMIC_GEOGRAPHIC_2D: |
91
|
|
|
return new DynamicGeographic2D( |
92
|
|
|
$epsgCode, |
93
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
94
|
|
|
Datum::fromEPSGCode($data['datum_code']) |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
case self::CRS_TYPE_GEOGRAPHIC_3D: |
98
|
|
|
return new Geographic3D( |
99
|
|
|
$epsgCode, |
100
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
101
|
|
|
$data['datum_code'] ? Datum::fromEPSGCode($data['datum_code']) : self::fromEPSGCode($data['base_crs_code'])->getDatum() |
102
|
|
|
); |
103
|
|
|
|
104
|
|
|
case self::CRS_TYPE_DYNAMIC_GEOGRAPHIC_3D: |
105
|
|
|
return new DynamicGeographic3D( |
106
|
|
|
$epsgCode, |
107
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
108
|
|
|
Datum::fromEPSGCode($data['datum_code']) |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
case self::CRS_TYPE_PROJECTED: |
112
|
|
|
return new Projected( |
113
|
|
|
$epsgCode, |
114
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
115
|
|
|
self::fromEPSGCode($data['base_crs_code']) |
116
|
|
|
); |
117
|
|
|
|
118
|
|
|
case self::CRS_TYPE_VERTICAL: |
119
|
|
|
return new Vertical( |
120
|
|
|
$epsgCode, |
121
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
122
|
|
|
Datum::fromEPSGCode($data['datum_code']) |
123
|
|
|
); |
124
|
|
|
|
125
|
|
|
case self::CRS_TYPE_DYNAMIC_VERTICAL: |
126
|
|
|
return new DynamicVertical( |
127
|
|
|
$epsgCode, |
128
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
129
|
|
|
Datum::fromEPSGCode($data['datum_code']) |
130
|
|
|
); |
131
|
|
|
|
132
|
|
|
case self::CRS_TYPE_COMPOUND: |
133
|
|
|
return new Compound( |
134
|
|
|
$epsgCode, |
135
|
|
|
self::fromEPSGCode($data['cmpd_horizcrs_code']), |
136
|
|
|
self::fromEPSGCode($data['cmpd_vertcrs_code']) |
137
|
|
|
); |
138
|
|
|
|
139
|
|
|
default: |
140
|
|
|
throw new UnknownCoordinateReferenceSystemException($epsgCode); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function getEpsgCode(): int |
145
|
|
|
{ |
146
|
|
|
return $this->epsgCode; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function getCoordinateSystem(): CoordinateSystem |
150
|
|
|
{ |
151
|
|
|
return $this->coordinateSystem; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function getDatum(): Datum |
155
|
|
|
{ |
156
|
|
|
return $this->datum; |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths