Skip to content

Commit

Permalink
Adjust test points to be within accurate extents
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Apr 24, 2021
1 parent df5bd61 commit a51958d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
16 changes: 8 additions & 8 deletions tests/CoordinateOperation/AutoConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,22 @@ public function testPZ9011ToITRF2008NoEpoch(): void

public function testBritishNationalGridToOSGB(): void
{
$from = ProjectedPoint::createFromEastingNorthing(new Metre(577274.99), new Metre(69740.50), Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID));
$from = ProjectedPoint::createFromEastingNorthing(new Metre(573502.85), new Metre(180912.71), Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID));
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_OSGB36);
$to = $from->convert($toCRS);

self::assertEqualsWithDelta(50.5, $to->getLatitude()->getValue(), 0.0001);
self::assertEqualsWithDelta(51.5, $to->getLatitude()->getValue(), 0.0001);
self::assertEqualsWithDelta(0.5, $to->getLongitude()->getValue(), 0.0001);
}

public function testBritishNationalGridToUTM(): void
{
$from = ProjectedPoint::createFromEastingNorthing(new Metre(577274.99), new Metre(69740.50), Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID));
$from = ProjectedPoint::createFromEastingNorthing(new Metre(573502.85), new Metre(180912.71), Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID));
$toCRS = Projected::fromSRID(Projected::EPSG_WGS_84_UTM_GRID_SYSTEM_NORTHERN_HEMISPHERE);
$to = $from->convert($toCRS);

self::assertEqualsWithDelta(31322594.503502, $to->getEasting()->getValue(), 0.0001);
self::assertEqualsWithDelta(5597286.6916335, $to->getNorthing()->getValue(), 0.0001);
self::assertEqualsWithDelta(31326366.159092, $to->getEasting()->getValue(), 0.0001);
self::assertEqualsWithDelta(5708455.7715515, $to->getNorthing()->getValue(), 0.0001);
}

public function testETRSLN02ToETRSEVRF2000(): void
Expand All @@ -211,12 +211,12 @@ public function testETRSLN02ToETRSEVRF2000(): void
BoundingArea::createWorld(),
);

$from = CompoundPoint::create(GeographicPoint::create(new Radian(0.826122513), new Radian(0.168715161), null, Geographic2D::fromSRID(Geographic2D::EPSG_ETRS89)), VerticalPoint::create(new Metre(473), Vertical::fromSRID(Vertical::EPSG_LN02_HEIGHT)), $fromCRS);
$from = CompoundPoint::create(GeographicPoint::create(new Radian(0.826122513), new Radian(0.167215161), null, Geographic2D::fromSRID(Geographic2D::EPSG_ETRS89)), VerticalPoint::create(new Metre(473), Vertical::fromSRID(Vertical::EPSG_LN02_HEIGHT)), $fromCRS);
$toCRS = Compound::fromSRID(Compound::EPSG_ETRS89_PLUS_EVRF2000_HEIGHT);
$to = $from->convert($toCRS);

self::assertEqualsWithDelta(0.826122513, $to->getHorizontalPoint()->getLatitude()->asRadians()->getValue(), 0.0000000001);
self::assertEqualsWithDelta(0.168715161, $to->getHorizontalPoint()->getLongitude()->asRadians()->getValue(), 0.0000000001);
self::assertEqualsWithDelta(472.69, $to->getVerticalPoint()->getHeight()->asMetres()->getValue(), 0.001);
self::assertEqualsWithDelta(0.167215161, $to->getHorizontalPoint()->getLongitude()->asRadians()->getValue(), 0.0000000001);
self::assertEqualsWithDelta(472.691, $to->getVerticalPoint()->getHeight()->asMetres()->getValue(), 0.001);
}
}
8 changes: 3 additions & 5 deletions tests/GeographicPoint2DTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use function array_merge;
use function class_exists;
use DateTime;
use PHPCoord\CoordinateOperation\CoordinateOperationMethods;
use PHPCoord\CoordinateOperation\CoordinateOperations;
use PHPCoord\CoordinateOperation\CRSTransformations;
use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem;
Expand Down Expand Up @@ -55,14 +54,13 @@ public function testOperations(string $sourceCrsSrid, string $targetCrsSrid, str
self::assertEquals($targetCRS, $newPoint->getCRS());

if ($reversible) {
$delta = isset($operation['method']) && $operation['method'] === CoordinateOperationMethods::EPSG_REVERSIBLE_POLYNOMIAL_OF_DEGREE_13 ? 0.01 : 0.001;
$reversedPoint = $newPoint->performOperation($operationSrid, $sourceCRS, true);

self::assertEquals($sourceCRS, $reversedPoint->getCRS());
self::assertEqualsWithDelta($originalPoint->getLatitude()->getValue(), $reversedPoint->getLatitude()->getValue(), $delta);
self::assertEqualsWithDelta($originalPoint->getLongitude()->getValue(), $reversedPoint->getLongitude()->getValue(), $delta);
self::assertEqualsWithDelta($originalPoint->getLatitude()->getValue(), $reversedPoint->getLatitude()->getValue(), 0.002);
self::assertEqualsWithDelta($originalPoint->getLongitude()->getValue(), $reversedPoint->getLongitude()->getValue(), 0.002);
if ($sourceHeight) {
self::assertEqualsWithDelta($originalPoint->getHeight()->getValue(), $reversedPoint->getHeight()->getValue(), $delta);
self::assertEqualsWithDelta($originalPoint->getHeight()->getValue(), $reversedPoint->getHeight()->getValue(), 0.002);
} else {
self::assertNull($reversedPoint->getHeight());
}
Expand Down
6 changes: 3 additions & 3 deletions tests/GeographicPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@ public function testObliqueMercatorHotineVariantB(): void

public function testTransverseMercator(): void
{
$from = GeographicPoint::create(new Degree(50.5), new Degree(0.5), null, Geographic2D::fromSRID(Geographic2D::EPSG_OSGB36));
$from = GeographicPoint::create(new Degree(51.5), new Degree(0.5), null, Geographic2D::fromSRID(Geographic2D::EPSG_OSGB36));
$toCRS = Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID);
$to = $from->transverseMercator($toCRS, new Degree(49), new Degree(-2), new Unity(0.9996012717), new Metre(400000), new Metre(-100000));

self::assertEqualsWithDelta(577274.99, $to->getEasting()->asMetres()->getValue(), 0.01);
self::assertEqualsWithDelta(69740.50, $to->getNorthing()->asMetres()->getValue(), 0.01);
self::assertEqualsWithDelta(573502.85, $to->getEasting()->asMetres()->getValue(), 0.01);
self::assertEqualsWithDelta(180912.71, $to->getNorthing()->asMetres()->getValue(), 0.01);
}

public function testTransverseMercatorSouthOrientated(): void
Expand Down

0 comments on commit a51958d

Please sign in to comment.