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

Basic support for curved geometries #215

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jaakkor2
Copy link
Contributor

Add basic support CircularString, CompoundCurve, CurvePolygon, MultiCurve, MultiSurface. Reading WKT tests added.

Lots of additional methods to be added for constructing geometries. Those should fall under open_issue_if_conversion_makes_sense for now.

@jaakkor2
Copy link
Contributor Author

One thing I did not yet figure out how to get the geometries from a CompoundCurve.

cc = readgeom("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 2 -1, 0 -1, 0 0))")
getGeometries(cc) # returns [cc]
ngeom(cc) # how to define?

@jaakkor2
Copy link
Contributor Author

Failures on nightlies {ubuntu, macOS, windows}-latest are due to Makie not compiling under Julia Version 1.12.0-DEV.1908. Not related to this PR.

@evetion
Copy link
Member

evetion commented Jan 19, 2025

Thanks for working on this! ❤️

One thing I did not yet figure out how to get the geometries from a CompoundCurve.

cc = readgeom("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 2 -1, 0 -1, 0 0))")
getGeometries(cc) # returns [cc]
ngeom(cc) # how to define?

A CompoundCurve is a collection, so I'd say ngeom counts for the number of segments. This has one, and getgeom will get you the CircularString. While it maybe confusing from a Curve perspective (expecting ngeom to be the number of points), I'd say it fits the indentation (ngeom is just the number of things between brackets on level down).

@jaakkor2
Copy link
Contributor Author

@evetion , I am still confused since getGeometries(cc) results [cc], not the circular string.

julia> LibGEOS.getGeometries(cc)
1-element Vector{CompoundCurve}:
 COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 2 -1, 0 -1, 0 0))

Also, geosop cannot compare curved geometries nor operate booleans. I would say curved geometry support is still in its infancy in GEOS. Some examples

using GEOS_jll
geosop = GEOS_jll.geosop()
wkt1 = "POLYGON ((0 0,1 0,0 1,0 0))"
run(`$geosop -a $wkt1 -b $wkt1 equals`); # ok
run(`$geosop -a $wkt1 -b $wkt1 intersection`); # ok
wkt2 = "CIRCULARSTRING (0 0,1 1,2 0)"
run(`$geosop -a $wkt2 -b $wkt2 equals`); # Run-time exception: UnsupportedOperationException: Curved geometry types are not supported.
wkt3 = "CURVEPOLYGON (CIRCULARSTRING (0 0,1 1,2 0,1 -1,0 0))"
run(`$geosop -a $wkt3 area`); # ok 3.14
run(`$geosop -a $wkt3 length`); # ok 6.28
run(`$geosop -a $wkt1 -b $wkt3 intersection`); # Run-time exception: UnsupportedOperationException: Curved geometry types are not supported.

That said, I am indifferent if this PR gets accepted or not. No hurries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants