mstaal
mstaal

Reputation: 630

How to make GML / JTS Geometry valid in Java?

I am using the JTS library for manipulating with some Geometry objects that arise from GML files. Some of the Geometry objects that I obtain are (however) invalid. I recall that the .NET class SqlGeometry has a MakeValid method for this purpose. Similarly, I know that PostGIS and many relational databases (like PostgreSQL and SQL Server) have built-in functionality for validating GMLs or Geometry structures. Sadly I have not been able to find any equivalent functionality in JTS or in the Java world in general. The closest thing I came across was the Geometry#buffer() method (from JTS) with 0 as an argument, but it does not seem to solve my problem. Does anyone know a proper MakeValid functionality in some Java library?

Upvotes: 1

Views: 915

Answers (1)

dr_jts
dr_jts

Reputation: 231

Unfortunately JTS does not yet have a MakeValid equivalent. Hopefully that can be contributed at some point. For now buffer(0) is the best option, although it can have issues with "figure-8" polygons.

Upvotes: 1

Related Questions