JuliaEarth / geospatial-data-science-with-julia

Geospatial Data Science with Julia

Home Page:https://juliaearth.github.io/geospatial-data-science-with-julia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Intersection graph in chapter 04 does not seem right.

ErickChacon opened this issue · comments

In the section of operations there is an example of the intersection of 2 geometries. Is that graph right?

outer = [(8, 0), (4, 8), (2, 8), (-2, 0), (0, 0), (1, 2), (5, 2), (6, 0)]
inner = [(4, 4), (2, 4), (3, 6)]
poly  = PolyArea([outer, inner])
quad  = Quadrangle((0, 1), (3, 1), (3, 7), (0, 7))

int = poly  quad

viz([poly, quad, boundary(int)],
    color = ["slategray3", "teal", "red"],
    alpha = [1.0, 0.2, 1.0])

image

I think there is a red segment in the center that should not be there?

That is true. Probably an issue with the Sutherland-Hodgman clipping method: https://github.com/JuliaGeometry/Meshes.jl/blob/master/src/clipping/sutherlandhodgman.jl

The ultimate goal is to use a more general clipping method such as Weiler-Atherton: https://github.com/JuliaGeometry/Meshes.jl/blob/c470b18ab57256e0b902874b416296f535e6e696/src/intersections/polygons.jl#L6

We have an open issue for it: JuliaGeometry/Meshes.jl#578

We simplified the example in the meantime. Further work is needed in Meshes.jl to add these other algorithms.