Potential Polygon Bug?
AlextheYounga opened this issue · 0 comments
AlextheYounga commented
I'm trying to test if a point is inside a polygon and I'm wondering if I have found an issue or perhaps I've misread the docs. Would really appreciate your help here. I included a couple of dump and die's to show that my code appears to be correct. Thanks ahead of time.
use Geokit\Polygon;
use Geokit\Position;
$polygon = new Polygon(
new Position(125.2, 5512),
new Position(136.6, 5512),
new Position(139.7, 3880),
new Position(139.7, 3307),
new Position(129.9, 3307),
new Position(122, 4409),
);
$envelope = $polygon->close();
dd($polygon);
//Output
array:7 [
0 => Geokit\Position^ {#36
-x: 125.2
-y: 5512.0
}
1 => Geokit\Position^ {#1282
-x: 136.6
-y: 5512.0
}
2 => Geokit\Position^ {#1289
-x: 139.7
-y: 3880.0
}
3 => Geokit\Position^ {#1290
-x: 139.7
-y: 3307.0
}
4 => Geokit\Position^ {#1291
-x: 129.9
-y: 3307.0
}
5 => Geokit\Position^ {#1292
-x: 122.0
-y: 4409.0
}
6 => Geokit\Position^ {#1293
-x: 125.2
-y: 5512.0
}
]
$point = new Position(125.98652772609, 5374.0);
dd($point)
//Output
Geokit\Position^ {#1295
-x: 125.98652772609
-y: 5374.0
}
//This point should appear inside the $envelope.
//I've tested this in Excel as well
//as a Javascript geometric package to make sure.
$envelope->contains($point);
//false