-
Notifications
You must be signed in to change notification settings - Fork 12
GeometryOps.within(poly1, poly2) inconsistent with LibGEOS.within(poly1, poly2) #396
Description
For certain polygons, within() seems to incorrectly return true. I honestly don't know why this is happening. Maybe it relates to the polygons sharing vertices? I used Point2i to try to avoid floating point issues but maybe that's responsible? Both polygons are simply connected. In my example, I added the within() checks for the point (4,2) to test if the winding order of my points was causing an issue. I'm rather new to the julia geometry packages, so apologies if this is user error. I suspect this is a bug as I can't understand how a certain point could be within rect, not within poly, yet rect is within poly.
Example:
using GeometryBasics, GeometryOps, CairoMakie
rect = Polygon{2, Int64}(Point{2, Int64}[[0, 0], [8, 0], [8, 4], [0, 4]], Vector{Point{2, Int64}}[])
poly = Polygon{2, Int64}(Point{2, Int64}[[8, 4], [0, 4], [0, 3], [7, 3], [7, 1], [0, 2], [0, 0], [8, 0]], Vector{Point{2, Int64}}[])
within(rect, poly) # returns true, should be false
within(poly, rect) # returns true
within(Point2i(4, 2), rect) # returns true
within(Point2i(4, 2), poly) # returns false
f,ax,_ = plot(rect);
plot!(ax,poly);
display(f)
I was able to reproduce this issue in a temporary environment with the following package versions:
[13f3f980] CairoMakie v0.15.9
[5c1252a2] GeometryBasics v0.5.10
[3251bfac] GeometryOps v0.1.38