|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHPCoord. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Doug Wright |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace PHPCoord; |
|
10
|
|
|
|
|
11
|
|
|
use DateTimeInterface; |
|
12
|
|
|
use PHPCoord\CoordinateReferenceSystem\Compound; |
|
13
|
|
|
use PHPCoord\CoordinateReferenceSystem\Geocentric; |
|
14
|
|
|
use PHPCoord\CoordinateReferenceSystem\Geographic; |
|
15
|
|
|
use PHPCoord\CoordinateReferenceSystem\Geographic2D; |
|
16
|
|
|
use PHPCoord\CoordinateReferenceSystem\Geographic3D; |
|
17
|
|
|
use PHPCoord\CoordinateReferenceSystem\Projected; |
|
|
|
|
|
|
18
|
|
|
use PHPCoord\CoordinateReferenceSystem\Vertical; |
|
19
|
|
|
use PHPCoord\CoordinateSystem\Cartesian; |
|
20
|
|
|
use PHPCoord\Geometry\BoundingArea; |
|
21
|
|
|
use PHPCoord\Geometry\RegionMap; |
|
22
|
|
|
use PHPCoord\UnitOfMeasure\Length\Length; |
|
23
|
|
|
|
|
24
|
|
|
use function str_replace; |
|
25
|
|
|
|
|
26
|
|
|
class UTMPoint extends ProjectedPoint |
|
27
|
|
|
{ |
|
28
|
|
|
public const HEMISPHERE_NORTH = 'N'; |
|
29
|
|
|
|
|
30
|
|
|
public const HEMISPHERE_SOUTH = 'S'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Zone number. |
|
34
|
|
|
*/ |
|
35
|
|
|
protected int $zone; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Hemisphere (N or S). |
|
39
|
|
|
*/ |
|
40
|
|
|
protected string $hemisphere; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Base CRS. |
|
44
|
|
|
* @deprecated use $this->crs->getBaseCRS() |
|
45
|
|
|
*/ |
|
46
|
|
|
protected Geographic2D $baseCRS; |
|
47
|
|
|
|
|
48
|
72 |
|
public function __construct(Geographic2D $crs, Length $easting, Length $northing, int $zone, string $hemisphere, ?DateTimeInterface $epoch = null) |
|
49
|
|
|
{ |
|
50
|
72 |
|
$this->zone = $zone; |
|
51
|
72 |
|
$this->hemisphere = $hemisphere; |
|
52
|
72 |
|
$this->baseCRS = $crs; |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
72 |
|
$longitudeOrigin = $zone * 6 - 3; |
|
55
|
72 |
|
if ($hemisphere === self::HEMISPHERE_NORTH) { |
|
56
|
54 |
|
$boundingArea = BoundingArea::createFromArray([[[[$longitudeOrigin, 0], [$longitudeOrigin, 90], [$longitudeOrigin + 6, 90], [$longitudeOrigin + 6, 0]]]], RegionMap::REGION_GLOBAL); |
|
57
|
54 |
|
$derivingConversion = 'urn:ogc:def:coordinateOperation:EPSG::' . ($zone + 16000); |
|
58
|
|
|
} else { |
|
59
|
18 |
|
$boundingArea = BoundingArea::createFromArray([[[[$longitudeOrigin, -90], [$longitudeOrigin, 0], [$longitudeOrigin + 6, 0], [$longitudeOrigin + 6, -90]]]], RegionMap::REGION_GLOBAL); |
|
60
|
18 |
|
$derivingConversion = 'urn:ogc:def:coordinateOperation:EPSG::' . ($zone + 16100); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
72 |
|
$srid = 'urn:ogc:def:crs,' . str_replace('urn:ogc:def:', '', $crs->getSRID()) . ',' . str_replace('urn:ogc:def:', '', Cartesian::EPSG_2D_AXES_EASTING_NORTHING_E_N_ORIENTATIONS_EAST_NORTH_UOM_M) . ',' . str_replace('urn:ogc:def:', '', $derivingConversion); |
|
64
|
|
|
|
|
65
|
72 |
|
$projectedCRS = new Projected( |
|
66
|
72 |
|
$srid, |
|
67
|
72 |
|
Cartesian::fromSRID(Cartesian::EPSG_2D_AXES_EASTING_NORTHING_E_N_ORIENTATIONS_EAST_NORTH_UOM_M), |
|
68
|
72 |
|
$crs->getDatum(), |
|
69
|
72 |
|
$boundingArea, |
|
70
|
72 |
|
"{$crs->getName()} / UTM zone {$zone}{$hemisphere}", |
|
71
|
72 |
|
$crs, |
|
72
|
72 |
|
$derivingConversion |
|
73
|
72 |
|
); |
|
74
|
|
|
|
|
75
|
72 |
|
parent::__construct($projectedCRS, $easting, $northing, null, null, $epoch, null); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
18 |
|
public function getZone(): int |
|
79
|
|
|
{ |
|
80
|
18 |
|
return $this->zone; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
18 |
|
public function getHemisphere(): string |
|
84
|
|
|
{ |
|
85
|
18 |
|
return $this->hemisphere; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getBaseCRS(): Geographic |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->crs->getBaseCRS(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
36 |
|
public function convert(Compound|Geocentric|Geographic2D|Geographic3D|Projected|Vertical $to, bool $ignoreBoundaryRestrictions = false): Point |
|
94
|
|
|
{ |
|
95
|
36 |
|
return $this->asGeographicPoint()->convert($to, $ignoreBoundaryRestrictions); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
27 |
|
public function calculateDistance(Point $to): Length |
|
99
|
|
|
{ |
|
100
|
27 |
|
if ($this->crs == $to->getCRS()) { |
|
101
|
9 |
|
return parent::calculateDistance($to); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
18 |
|
return $this->asGeographicPoint()->calculateDistance($to); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
18 |
|
public function __toString(): string |
|
108
|
|
|
{ |
|
109
|
18 |
|
return $this->getZone() . $this->getHemisphere() . ' ' . (int) $this->easting->getValue() . ' ' . (int) $this->northing->getValue(); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
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