Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union of touching geometries is incorrect #116

Closed
asinghvi17 opened this issue Apr 21, 2024 · 1 comment
Closed

Union of touching geometries is incorrect #116

asinghvi17 opened this issue Apr 21, 2024 · 1 comment
Labels
bug Something isn't working clipping About polygon clipping or processing

Comments

@asinghvi17
Copy link
Member

MWE:

using GeometryBasics
import GeometryOps as GO, GeoInterface as GI
p1 = GI.Polygon([decompose(Point2f, Rect2f(0,0,1,1))]) |> GO.fix
p2 = GI.Polygon([decompose(Point2f, Rect2f(1,1,1,1))]) |> GO.fix

julia> GO.intersects(p1, p2)
true

julia> GO.touches(p1, p2)
true

julia> GO.union(p1, p2; target = GI.PolygonTrait)
2-element Vector{GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}}:
 GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}(GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}[GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}([(0.0, 0.0), (1.0, 0.0), (0.0, 1.0), (1.0, 1.0), (0.0, 0.0)], nothing, nothing)], nothing, nothing)
 GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}(GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}[GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}([(1.0, 1.0), (2.0, 1.0), (1.0, 2.0), (2.0, 2.0), (1.0, 1.0)], nothing, nothing)], nothing, nothing)

This should be a single polygon, that represents a rectangle of height 2 and width 1.

@asinghvi17 asinghvi17 added bug Something isn't working clipping About polygon clipping or processing labels Apr 21, 2024
@asinghvi17
Copy link
Member Author

This is actually fine - the geometries were self intersecting and so incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working clipping About polygon clipping or processing
Projects
None yet
Development

No branches or pull requests

1 participant