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

Add PolygonizerExcludeHoles and MakeValid operations (fixes #952) #151

Merged
merged 3 commits into from
Feb 28, 2019

Conversation

rouault
Copy link
Contributor

@rouault rouault commented Feb 25, 2019

See https://trac.osgeo.org/geos/ticket/952

This is a proper C++ port of the librttopo code, originally using GEOS C API.

capi/geos_c.h.in Outdated Show resolved Hide resolved
@@ -0,0 +1,76 @@
/**********************************************************************
Copy link
Member

@dbaston dbaston Feb 26, 2019

Choose a reason for hiding this comment

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

I think @dr-jts made some improvements in the JTS polygonizer (excluding holes from output) that may make this redundant. I see no problem including it now and replacing the implementation later, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, Polygonizer has not changed recently. I might have done some experimental work on a BuildArea equivalent though. Will have to look for the code. So probably not relevant to this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@dbaston ah right, had forgotten about that. And I see a bit of cleanup needed there too...

As you say, can always port this JTS code later and replace internals of BuildArea.


static std::unique_ptr<geom::MultiPolygon> collectFacesWithEvenAncestors(
std::vector<std::unique_ptr<Face>>& faces) {
std::vector<geom::Geometry*>* geoms = new std::vector<geom::Geometry*>();
Copy link
Member

Choose a reason for hiding this comment

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

Why not use a std::unique_ptr<std::vector<geom::Geometry*>> here (and other similar locations). I'm guessing it's because the geometries would still be leaked on error, and GeometryFactory doesn't have a GeometryFactory::createMultiPolygon(std::vector<std::unique_ptr<Geometry>>) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes exactly. That would cause memory leaks. I considered adding createMultiPolygon(std::vector<std::unique_ptr>) but didn't want to make this pull request touch too many things

* Fully node given linework
*/
static std::unique_ptr<geom::Geometry>
GEOS_nodeLines(const geom::Geometry* geom)
Copy link
Member

Choose a reason for hiding this comment

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

How about something like nodeLineWithFirstCoordinate ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be just GEOSNode call. When I tried replacing it with GEOSNode in PostGIS it crashed painfully. Inside GEOS I expect it to be replaced with GEOSNode and GEOSNode fixed to not crash.

Copy link
Member

Choose a reason for hiding this comment

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

GEOSNode is in the C API; it's not callable here.

Copy link
Contributor

Choose a reason for hiding this comment

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

its C++ internals should be called then? not a new implementation. It's just a side effect that Union does the noding.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, there may be an other way to implement it. But I see no reason that Even should fix unticketed bugs as part of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed as nodeLineWithFirstCoordinate() as suggested.

GEOSNode() just calls geos::noding::GeometryNoder::node(). I tried this, but unfortunatelly this doesn't give the same results as the current implementation. For example it doesn't return POINT(0 0) for LINESTRING(0 0,0 0), but MULTILINESTRING((0 0,0 0))

@rouault rouault force-pushed the add_GEOSMakeValid_cpp branch 2 times, most recently from 53eef58 to 46afb99 Compare February 26, 2019 15:24
@rouault rouault changed the title Add BuildArea and MakeValid operations (fixes #952) Add PolygonizerExcludeHoles and MakeValid operations (fixes #952) Feb 26, 2019
@rouault
Copy link
Contributor Author

rouault commented Feb 28, 2019

OK, just pushed changes to rename to BuildArea/GEOSBuildArea (with git history cleaning)

and add GEOSMakeValid_r() (fixes libgeos#952)
@strk strk merged commit 5cf6893 into libgeos:master Feb 28, 2019
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.

None yet

5 participants