Skip to content

Commit

Permalink
Reduce number of times the slow-to-parse IGNF file is used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Nov 11, 2021
1 parent 408f944 commit 78ded9e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 67 deletions.
27 changes: 0 additions & 27 deletions tests/CompoundPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use PHPCoord\CoordinateOperation\GTXNZGeoid2016Provider;
use PHPCoord\CoordinateOperation\GUGiKHeightETRF2000Baltic1986PolandProvider;
use PHPCoord\CoordinateOperation\IGNESHeightETRS89REDNAPSpainProvider;
use PHPCoord\CoordinateOperation\IGNFHeightRGF93v2bNGFIGN69FranceProvider;
use PHPCoord\CoordinateOperation\OSTN15OSGM15Provider;
use PHPCoord\CoordinateReferenceSystem\Compound;
use PHPCoord\CoordinateReferenceSystem\CompoundSRIDData;
Expand Down Expand Up @@ -176,32 +175,6 @@ public function testGeographic3DTo2DPlusGravityHeightGTX(): void
self::assertEqualsWithDelta(50.000, $to->getHeight()->getValue(), 0.0001);
}

public function testGeographic3DTo2DPlusGravityHeightIGNF(): void
{
if (!class_exists(IGNFHeightRGF93v2bNGFIGN69FranceProvider::class)) {
self::markTestSkipped('Requires phpcoord/datapack-europe');
}
$from = CompoundPoint::create(
Compound::fromSRID(Compound::EPSG_RGF93_V2B_PLUS_NGF_IGN69_HEIGHT),
GeographicPoint::create(
Geographic2D::fromSRID(Geographic2D::EPSG_RGF93_V2B),
new Degree(48.858222),
new Degree(2.2945),
null
),
VerticalPoint::create(
Vertical::fromSRID(Vertical::EPSG_NGF_IGN69_HEIGHT),
new Metre(6.187)
)
);
$toCRS = Geographic3D::fromSRID(Geographic3D::EPSG_RGF93_V2B);
$to = $from->geographic3DTo2DPlusGravityHeightFromGrid($toCRS, (new IGNFHeightRGF93v2bNGFIGN69FranceProvider())->provideGrid());

self::assertEqualsWithDelta(48.858222, $to->getLatitude()->getValue(), 0.00000000001);
self::assertEqualsWithDelta(2.2945, $to->getLongitude()->getValue(), 0.00000000001);
self::assertEqualsWithDelta(50.000, $to->getHeight()->getValue(), 0.001);
}

public function testGeographic3DTo2DPlusGravityHeightIGNESSpain(): void
{
if (!class_exists(IGNESHeightETRS89REDNAPSpainProvider::class)) {
Expand Down
12 changes: 0 additions & 12 deletions tests/GeographicPoint3DTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ public function testGeographic3DTo2DPlusGravityHeightIGNFFrance(): void
self::assertEqualsWithDelta(6.187, $to->getVerticalPoint()->getHeight()->getValue(), 0.001);
}

public function testGeographic3DGravityHeightIGNFFrance(): void
{
if (!class_exists(IGNFHeightRGF93v2bNGFIGN69FranceProvider::class)) {
self::markTestSkipped('Requires phpcoord/datapack-europe');
}
$from = GeographicPoint::create(Geographic3D::fromSRID(Geographic3D::EPSG_RGF93_V2B), new Degree(48.858222), new Degree(2.2945), new Metre(50));
$toCRS = Vertical::fromSRID(Vertical::EPSG_NGF_IGN69_HEIGHT);
$to = $from->geographic3DToGravityHeightFromGrid($toCRS, (new IGNFHeightRGF93v2bNGFIGN69FranceProvider())->provideGrid());

self::assertEqualsWithDelta(6.187, $to->getHeight()->getValue(), 0.001);
}

public function testGeographic3DTo2DPlusGravityHeightIGNESSpain(): void
{
if (!class_exists(IGNESHeightETRS89REDNAPSpainProvider::class)) {
Expand Down
48 changes: 20 additions & 28 deletions tests/GeographicPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1241,76 +1241,68 @@ public function testNTv2ReverseAustralia(): void
self::assertNull($to->getHeight());
}

public function testIGNFGeocentricTranslationFranceForward(): void
public function testIGNFGeocentricTranslationFrance(): void
{
if (!class_exists(IGNFGeocentricTranslationNTFRGF93Provider::class)) {
self::markTestSkipped('Requires phpcoord/europe');
}

$grid = (new IGNFGeocentricTranslationNTFRGF93Provider())->provideGrid();

$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_NTF), new Degree(48.84451225), new Degree(2.42567186), null);
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_RGF93_V1);
$to = $from->offsetsFromGrid(
$toCRS,
(new IGNFGeocentricTranslationNTFRGF93Provider())->provideGrid(),
$grid,
false
);

self::assertEqualsWithDelta(48.844445839, $to->getLatitude()->asDegrees()->getValue(), 0.0000001);
self::assertEqualsWithDelta(2.424971108, $to->getLongitude()->asDegrees()->getValue(), 0.0000001);
self::assertNull($to->getHeight());
}

public function testIGNFGeocentricTranslationFranceReverse(): void
{
if (!class_exists(IGNFGeocentricTranslationNTFRGF93Provider::class)) {
self::markTestSkipped('Requires phpcoord/europe');
}
$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_RGF93_V1), new Degree(48.844445839), new Degree(2.424971108), null);
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_NTF);
$to = $from->offsetsFromGrid(
$from = $to->offsetsFromGrid(
$toCRS,
(new IGNFGeocentricTranslationNTFRGF93Provider())->provideGrid(),
$grid,
true
);

self::assertEqualsWithDelta(48.84451225, $to->getLatitude()->asDegrees()->getValue(), 0.0000001);
self::assertEqualsWithDelta(2.42567186, $to->getLongitude()->asDegrees()->getValue(), 0.0000001);
self::assertNull($to->getHeight());
self::assertEqualsWithDelta(48.84451225, $from->getLatitude()->asDegrees()->getValue(), 0.0000001);
self::assertEqualsWithDelta(2.42567186, $from->getLongitude()->asDegrees()->getValue(), 0.0000001);
self::assertNull($from->getHeight());
}

public function testIGNFGeocentricTranslationNoumeaForward(): void
public function testIGNFGeocentricTranslationNoumea(): void
{
if (!class_exists(IGNFGeocentricTranslationNEA74NoumeaRGNC9193Provider::class)) {
self::markTestSkipped('Requires phpcoord/oceania');
}

$grid = (new IGNFGeocentricTranslationNEA74NoumeaRGNC9193Provider())->provideGrid();

$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_NEA74_NOUMEA), new Degree(-22.268889), new Degree(166.419444), null);
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_RGNC91_93);
$to = $from->offsetsFromGrid(
$toCRS,
(new IGNFGeocentricTranslationNEA74NoumeaRGNC9193Provider())->provideGrid(),
$grid,
false
);

self::assertEqualsWithDelta(-22.26612898, $to->getLatitude()->asDegrees()->getValue(), 0.000001);
self::assertEqualsWithDelta(166.42277652, $to->getLongitude()->asDegrees()->getValue(), 0.000001);
self::assertNull($to->getHeight());
}

public function testIGNFGeocentricTranslationNoumeaReverse(): void
{
if (!class_exists(IGNFGeocentricTranslationNEA74NoumeaRGNC9193Provider::class)) {
self::markTestSkipped('Requires phpcoord/oceania');
}
$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_RGNC91_93), new Degree(-22.26612898), new Degree(166.42277652), null);
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_NEA74_NOUMEA);
$to = $from->offsetsFromGrid(
$from = $to->offsetsFromGrid(
$toCRS,
(new IGNFGeocentricTranslationNEA74NoumeaRGNC9193Provider())->provideGrid(),
$grid,
true
);

self::assertEqualsWithDelta(-22.268889, $to->getLatitude()->asDegrees()->getValue(), 0.000001);
self::assertEqualsWithDelta(166.419444, $to->getLongitude()->asDegrees()->getValue(), 0.000001);
self::assertNull($to->getHeight());
self::assertEqualsWithDelta(-22.268889, $from->getLatitude()->asDegrees()->getValue(), 0.000001);
self::assertEqualsWithDelta(166.419444, $from->getLongitude()->asDegrees()->getValue(), 0.000001);
self::assertNull($from->getHeight());
}

public function testIGNFGeocentricTranslationGrandeTerreForward(): void
Expand Down

0 comments on commit 78ded9e

Please sign in to comment.