|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHPCoord. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Doug Wright |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace PHPCoord\CoordinateOperation; |
|
10
|
|
|
|
|
11
|
|
|
use PHPCoord\CoordinateReferenceSystem\Projected; |
|
|
|
|
|
|
12
|
|
|
use PHPCoord\CoordinateSystem\Cartesian; |
|
13
|
|
|
use PHPCoord\Datum\Datum; |
|
14
|
|
|
use PHPCoord\ProjectedPoint; |
|
15
|
|
|
use PHPCoord\UnitOfMeasure\Length\Metre; |
|
16
|
|
|
use SplFileObject; |
|
17
|
|
|
|
|
18
|
|
|
use function abs; |
|
19
|
|
|
|
|
20
|
|
|
class OSTNOSGM15Grid extends Grid |
|
21
|
|
|
{ |
|
22
|
|
|
use BilinearInterpolation; |
|
23
|
|
|
|
|
24
|
|
|
private const ITERATION_CONVERGENCE = 0.0001; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct($filename) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->gridFile = new SplFileObject($filename); |
|
29
|
|
|
|
|
30
|
|
|
$this->startX = 0; |
|
31
|
|
|
$this->startY = 0; |
|
32
|
|
|
$this->columnGridInterval = 1000; |
|
33
|
|
|
$this->rowGridInterval = 1000; |
|
34
|
|
|
$this->numberOfColumns = 700; |
|
35
|
|
|
$this->numberOfRows = 1250; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function applyForwardHorizontalAdjustment(ProjectedPoint $point): ProjectedPoint |
|
39
|
|
|
{ |
|
40
|
|
|
$adjustment = $this->getValues($point->getEasting()->asMetres()->getValue(), $point->getNorthing()->asMetres()->getValue()); |
|
41
|
|
|
|
|
42
|
|
|
$easting = $point->getEasting()->add($adjustment[0]); |
|
43
|
|
|
$northing = $point->getNorthing()->add($adjustment[1]); |
|
44
|
|
|
|
|
45
|
|
|
return ProjectedPoint::createFromEastingNorthing(Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID), $easting, $northing, $point->getCoordinateEpoch()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function applyReverseHorizontalAdjustment(ProjectedPoint $point): ProjectedPoint |
|
49
|
|
|
{ |
|
50
|
|
|
$osgb36NationalGrid = Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID); |
|
51
|
|
|
$etrs89NationalGrid = new Projected( |
|
52
|
|
|
'ETRS89 / National Grid', |
|
53
|
|
|
Cartesian::fromSRID(Cartesian::EPSG_2D_AXES_EASTING_NORTHING_E_N_ORIENTATIONS_EAST_NORTH_UOM_M), |
|
54
|
|
|
Datum::fromSRID(Datum::EPSG_EUROPEAN_TERRESTRIAL_REFERENCE_SYSTEM_1989_ENSEMBLE), |
|
55
|
|
|
$osgb36NationalGrid->getBoundingArea() |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
$adjustment = [new Metre(0), new Metre(0)]; |
|
59
|
|
|
$easting = $point->getEasting(); |
|
60
|
|
|
$northing = $point->getNorthing(); |
|
61
|
|
|
|
|
62
|
|
|
do { |
|
63
|
|
|
$prevAdjustment = $adjustment; |
|
64
|
|
|
$adjustment = $this->getValues($easting->asMetres()->getValue(), $northing->asMetres()->getValue()); |
|
65
|
|
|
$easting = $point->getEasting()->subtract($adjustment[0]); |
|
66
|
|
|
$northing = $point->getNorthing()->subtract($adjustment[1]); |
|
67
|
|
|
} while (abs($adjustment[0]->subtract($prevAdjustment[0])->getValue()) > self::ITERATION_CONVERGENCE && abs($adjustment[1]->subtract($prevAdjustment[1])->getValue()) > self::ITERATION_CONVERGENCE); |
|
68
|
|
|
|
|
69
|
|
|
return ProjectedPoint::createFromEastingNorthing($etrs89NationalGrid, $easting, $northing, $point->getCoordinateEpoch()); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getHeightAdjustment(ProjectedPoint $point): Metre |
|
73
|
|
|
{ |
|
74
|
|
|
$adjustment = $this->getValues($point->getEasting()->asMetres()->getValue(), $point->getNorthing()->asMetres()->getValue()); |
|
75
|
|
|
|
|
76
|
|
|
return $adjustment[2]; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return Metre[] |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getValues(float $x, float $y): array |
|
83
|
|
|
{ |
|
84
|
|
|
$offsets = $this->interpolate($x, $y); |
|
85
|
|
|
|
|
86
|
|
|
return [new Metre($offsets[0]), new Metre($offsets[1]), new Metre($offsets[2])]; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
private function getRecord(int $eastIndex, int $northIndex): GridValues |
|
|
|
|
|
|
90
|
|
|
{ |
|
91
|
|
|
$record = $northIndex * 701 + $eastIndex + 1; |
|
92
|
|
|
|
|
93
|
|
|
$this->gridFile->seek($record); |
|
94
|
|
|
$rawData = $this->gridFile->fgetcsv(); |
|
95
|
|
|
|
|
96
|
|
|
return new GridValues((float) $rawData[1], (float) $rawData[2], [(float) $rawData[3], (float) $rawData[4], (float) $rawData[5]]); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
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