From 079e4d57f624bd794eed032b0f650cfd985cafcd Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Thu, 26 Aug 2021 22:51:18 +0100 Subject: [PATCH] Use geographically-appropriate coordinates when testing geocentric operations --- tests/GeocentricPointTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/GeocentricPointTest.php b/tests/GeocentricPointTest.php index 790759865..fd7358d08 100644 --- a/tests/GeocentricPointTest.php +++ b/tests/GeocentricPointTest.php @@ -17,12 +17,14 @@ use PHPCoord\CoordinateOperation\CoordinateOperationParams; use PHPCoord\CoordinateOperation\CoordinateOperations; use PHPCoord\CoordinateOperation\CRSTransformations; +use PHPCoord\CoordinateOperation\GeographicValue; use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem; use PHPCoord\CoordinateReferenceSystem\Geocentric; use PHPCoord\CoordinateReferenceSystem\GeocentricSRIDData; use PHPCoord\CoordinateReferenceSystem\Geographic2D; use PHPCoord\CoordinateReferenceSystem\Geographic3D; use PHPCoord\Exception\InvalidCoordinateException; +use PHPCoord\Geometry\BoundingArea; use PHPCoord\UnitOfMeasure\Angle\ArcSecond; use PHPCoord\UnitOfMeasure\Length\Foot; use PHPCoord\UnitOfMeasure\Length\Metre; @@ -352,8 +354,11 @@ public function testTimeDependentPositionVectorTransformationEpochMissing(): voi public function testOperations(string $sourceCrsSrid, string $targetCrsSrid, string $operationSrid, bool $reversible): void { $operation = CoordinateOperations::getOperationData($operationSrid); + $operationExtent = BoundingArea::createFromExtentCodes($operation['extent_code']); + $centre = $operationExtent->getPointInside(); $sourceCRS = Geocentric::fromSRID($sourceCrsSrid); + $centre = (new GeographicValue($centre[0], $centre[1], new Metre(0), $sourceCRS->getDatum()))->asGeocentricValue(); $targetCRS = CoordinateReferenceSystem::fromSRID($targetCrsSrid); $epoch = new DateTime(); @@ -362,7 +367,7 @@ public function testOperations(string $sourceCrsSrid, string $targetCrsSrid, str $epoch = (new Year($params['Transformation reference epoch']['value']))->asDateTime(); } - $originalPoint = GeocentricPoint::create(new Metre(0), new Metre(0), new Metre(0), $sourceCRS, $epoch); + $originalPoint = GeocentricPoint::create($centre->getX(), $centre->getY(), $centre->getZ(), $sourceCRS, $epoch); $newPoint = $originalPoint->performOperation($operationSrid, $targetCRS, false); self::assertInstanceOf(Point::class, $newPoint); self::assertEquals($targetCRS, $newPoint->getCRS());