|
9 | 9 | namespace PHPCoord\Geometry; |
10 | 10 |
|
11 | 11 | use PHPCoord\CoordinateOperation\GeographicValue; |
| 12 | +use PHPCoord\CoordinateReferenceSystem\Geographic2D; |
| 13 | +use PHPCoord\CoordinateReferenceSystem\Projected; |
12 | 14 | use PHPCoord\Datum\Datum; |
| 15 | +use PHPCoord\Point\GeographicPoint; |
| 16 | +use PHPCoord\Point\ProjectedPoint; |
13 | 17 | use PHPCoord\UnitOfMeasure\Angle\Degree; |
| 18 | +use PHPCoord\UnitOfMeasure\Length\Metre; |
14 | 19 | use PHPUnit\Framework\TestCase; |
15 | 20 |
|
16 | 21 | class BoundingAreaTest extends TestCase |
@@ -102,4 +107,36 @@ public function testNetherlandsBufferedCorrectly(): void |
102 | 107 | $polygon = BoundingArea::createFromExtentCodes(['urn:ogc:def:area:EPSG::1275']); |
103 | 108 | self::assertTrue($polygon->containsPoint(new GeographicValue(new Degree(50.965613067768), new Degree(5.8249181759236), null, Datum::fromSRID(Datum::EPSG_WORLD_GEODETIC_SYSTEM_1984_ENSEMBLE)))); |
104 | 109 | } |
| 110 | + |
| 111 | + public function testBoundaryChecking(): void |
| 112 | + { |
| 113 | + $newYorkInED50 = GeographicPoint::create( |
| 114 | + latitude: new Degree(40.689167), |
| 115 | + longitude: new Degree(-74.044444), |
| 116 | + crs: Geographic2D::fromSRID(Geographic2D::EPSG_ED50) |
| 117 | + ); |
| 118 | + |
| 119 | + $newYorkInNAD83 = GeographicPoint::create( |
| 120 | + latitude: new Degree(40.689167), |
| 121 | + longitude: new Degree(-74.044444), |
| 122 | + crs: Geographic2D::fromSRID(Geographic2D::EPSG_NAD83_2011) |
| 123 | + ); |
| 124 | + |
| 125 | + $newYorkInCorrectUTM = ProjectedPoint::createFromEastingNorthing( |
| 126 | + easting: new Metre(580741), |
| 127 | + northing: new Metre(4504692), |
| 128 | + crs: Projected::fromSRID(Projected::EPSG_WGS_84_UTM_ZONE_18N) |
| 129 | + ); |
| 130 | + |
| 131 | + $newYorkInOSGB = ProjectedPoint::createFromEastingNorthing( |
| 132 | + easting: new Metre(580741), |
| 133 | + northing: new Metre(4504692), |
| 134 | + crs: Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID) |
| 135 | + ); |
| 136 | + |
| 137 | + self::assertFalse($newYorkInED50->isWithinCRSBoundingArea()); |
| 138 | + self::assertTrue($newYorkInNAD83->isWithinCRSBoundingArea()); |
| 139 | + self::assertTrue($newYorkInCorrectUTM->isWithinCRSBoundingArea()); |
| 140 | + self::assertFalse($newYorkInOSGB->isWithinCRSBoundingArea()); |
| 141 | + } |
105 | 142 | } |
0 commit comments