|
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\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_GEOGRAPHIC_2D: |
|
77
|
|
|
return new Geographic2D( |
|
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_3D: |
|
84
|
|
|
return new Geographic3D( |
|
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_PROJECTED: |
|
91
|
|
|
return new Projected( |
|
92
|
|
|
$epsgCode, |
|
93
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
|
94
|
|
|
self::fromEPSGCode($data['base_crs_code']) |
|
95
|
|
|
); |
|
96
|
|
|
|
|
97
|
|
|
case self::CRS_TYPE_VERTICAL: |
|
98
|
|
|
return new Vertical( |
|
99
|
|
|
$epsgCode, |
|
100
|
|
|
CoordinateSystem::fromEPSGCode($data['coord_sys_code']), |
|
101
|
|
|
Datum::fromEPSGCode($data['datum_code']) |
|
102
|
|
|
); |
|
103
|
|
|
|
|
104
|
|
|
case self::CRS_TYPE_COMPOUND: |
|
105
|
|
|
return new Compound( |
|
106
|
|
|
$epsgCode, |
|
107
|
|
|
self::fromEPSGCode($data['cmpd_horizcrs_code']), |
|
108
|
|
|
self::fromEPSGCode($data['cmpd_vertcrs_code']) |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
default: |
|
112
|
|
|
throw new UnknownCoordinateReferenceSystemException($epsgCode); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getEpsgCode(): int |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->epsgCode; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getCoordinateSystem(): CoordinateSystem |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->coordinateSystem; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getDatum(): Datum |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->datum; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
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