Skip to content

Commit

Permalink
Use geographically-appropriate coordinates when testing geocentric op…
Browse files Browse the repository at this point in the history
…erations
  • Loading branch information
dvdoug committed Aug 26, 2021
1 parent 70dcdbe commit 079e4d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/GeocentricPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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());
Expand Down

0 comments on commit 079e4d5

Please sign in to comment.