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