Skip to content

Add GEOSGeom_homogenize - #1493

Open
dbaston wants to merge 2 commits into
libgeos:mainfrom
dbaston:homogenize
Open

Add GEOSGeom_homogenize#1493
dbaston wants to merge 2 commits into
libgeos:mainfrom
dbaston:homogenize

Conversation

@dbaston

@dbaston dbaston commented Jul 28, 2026

Copy link
Copy Markdown
Member

Adds a GEOSGeom_homogenize function to flatten a geometry (remove nesting) and convert it to its most specific representation. The existing GeometryFlattener class provides this, but it was not exposed to the C API. I don't feel like "homogenize" is a great description of what this does, but it has the advantage of matching the PostGIS ST_CollectionHomogenize whose semantics it shares. Alternatives: GEOSGeom_refine, GEOSGeom_flatten

Possibly useful as a postprocessing step for GEOSSplit; see #1482

Comment thread capi/geos_c.h.in
* input is a single-element GeometryCollection, then the input will be
* destroyed and the single element returned. If the elements are not
* homogeneous, or if the input is not a collection, it will be returned
* unmodified. Nested collections are collapsed during processing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the current logic is all collection specific, should the function be named accordingly? ie "GEOSGeom_homogenizeCollection"?

There's an argument to be made that generic homogenization should also do things like turn a multilinestring containing a single linestring to a linestring, or turning a curve polygon which only consists of linestring rings into a non-curved polygon, or a compound curve with only straight segments to a linestring, etc...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the function should be GEOSGeom_simplifyStructure, and it should handle the curve->line cases you're describing.

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