Yep, this definitely sounds like a bug. Probably the
GeometryTransformer class needs another parameter to be told to provide
the behaviour desired by DPS.
Do you have a test case you can provide?
Joshua Portway wrote:
Hi,
I've been having problems with the DouglasPeuckerSimplifier returning
empty geometry sometimes when it shouldn't and I think I've tracked it
down.
The problem happens when simplifying a polygon which contains a hole,
when the simplification of the hole causes it to collapse into a
linestring instead of a linear ring (in
GeometryTransformer.transformLinearRing)
The transformPolygon method of GeometryTransformer then builds a
GeometryCollection containing a LinearRing (the original polygon
shell) and a LineString (the now-collapsed hole). It does this because
the "isAllValidLinearRings" flag gets set to false.
At the end of the simplification the algorithm uses a buffer(0)
operation to build the new geometry - as part of this the the
offsetCurveSetBuilder class looks at the input geometry and in the
case of a zero-distance buffer it ignores LineStrings and LinearRings.
It simply returns having discarded all the geometry - so the result of
the whole operation is an empty Geometry.
It seems to me that the bug is in the transformPolygon method of
GeometryTransformer, and could therefore have very wide ranging
effects, not limited to this particular issue. If, during the
transformation of a polygon a hole degenerates into a line string it
probably shouldn't invalidate the entire polygon - it just means the
hole has disappeared. Rather than Building a GeometryCollection with a
LinearRing and the degenerate hole it should build a
GeometryCollection containing a POLYGON (the shell + any remaining
valid holes) and the now-degenerate hole geometry (eg. a POLY and a
LINESTRING).
This solution would seem to produce the most consistent results in
most circumstances - I would assume that if a hole in a polygon
degenerates into a LineString then it should simply stop being treated
as a hole, but the shell of the polygon should be respected. In the
manifestation of this bug that I'm getting the buffer operation would
then discard the linestring and return the polygon correctly.
Does this make sense or am I misunderstanding something here ?
Joshua Portway
------------------------------------------------------------------------
_______________________________________________
jts-devel mailing list
jts-devel@lists.jump-project.org
http://lists.refractions.net/mailman/listinfo/jts-devel
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
_______________________________________________
jts-devel mailing list
jts-devel@lists.jump-project.org
http://lists.refractions.net/mailman/listinfo/jts-devel