Thanks Michael and Martin.

The buffer(0) worked for the situation where the holes were intersecting.
But the problem of the constructing a linear ring with self intersection
had to be dealt with in a different way, since it was the LinearRing that
was invalid. I ended up cutting off self intersecting loops, and the
algorithm picked them up as holes, so things are working smoothly now.

Cheers,
Rob


On Wed, Apr 30, 2014 at 1:21 PM, Martin Davis <[email protected]> wrote:

> Michael's suggestion is the easiet way to handle this situation, although
> it does have some pitfalls as noted in the FAQ:
>
> http://tsusiatsoftware.net/jts/jts-faq/jts-faq.html#G
>
>
> On Tue, Apr 29, 2014 at 5:36 PM, Michael Bedward <
> [email protected]> wrote:
>
>> Hi Rob,
>>
>> Doing poly.buffer(0) on that one seems to give what you are after.
>>
>> Michael
>>
>>
>> On 30 April 2014 07:44, Rob Emanuele <[email protected]> wrote:
>> > Hi JTS folk,
>> >
>> > This is Rob from the GeoTrellis team. We have an algorithm that performs
>> > vectorization against raster data that does a RegionGroup operation
>> over the
>> > raster and then vectorizes each region along the cell borders.
>> >
>> > We're wrapping JTS in scala code (you can find it here:
>> >
>> https://github.com/geotrellis/geotrellis/tree/master/feature/src/main/scala/geotrellis/feature
>> ).
>> > This is replacing some earlier wrapping work contained in GeoTrellis <=
>> > 0.9.X. One difference between the two wrappers is that the current
>> Polygon
>> > checks to see that the JTS geometry is valid in the constructor (as does
>> > each geometry type).
>> >
>> > This is causing one of our previous Vectorization unit tests to fail. In
>> > this case, the Raster looks like this:
>> >
>> >   X  X  X  X  X
>> >   X  P  P  P  X
>> >   X  P  X  P  X
>> >   X  X  P  P  X
>> >   X  X  X  X  X
>> >
>> > Where X represents NoData, and P represents a value (The letter choice
>> is
>> > arbitrary). The algorithm creates a vector who's border LineString goes
>> > around the perimeter of the region of P's.
>> >
>> > The problem is, the algorithm creates a border with two points being the
>> > same:
>> >    ______
>> >   |    __   |
>> >   |__| _|   |
>> >        | __ |
>> >
>> > (apologies for the very rough ASCII art, I hope it translates).
>> >
>> > So because the border intersects itself, it's considered an invalid
>> polygon.
>> > The algorithm could possibly changed to consider the outside perimeter
>> as
>> > the LineRing and the space in the middle as a hole; this would require
>> some
>> > significant changes to an already complex algorithm, and I'm not sure it
>> > could handle all of the edge cases.
>> >
>> > My question is, is there a way to solve this in JTS? To take a
>> LineString
>> > that is invalid for the border of the polygon, and separate it out into
>> a
>> > valid border and a hole, and to create a valid polygon from it, in a
>> generic
>> > way?
>> >
>> > Thanks,
>> > Rob
>> >
>> >
>> >
>> ------------------------------------------------------------------------------
>> > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> > Instantly run your Selenium tests across 300+ browser/OS combos.  Get
>> > unparalleled scalability from the best Selenium testing platform
>> available.
>> > Simple to use. Nothing to install. Get started now for free."
>> > http://p.sf.net/sfu/SauceLabs
>> > _______________________________________________
>> > Jts-topo-suite-user mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
>> Instantly run your Selenium tests across 300+ browser/OS combos.  Get
>> unparalleled scalability from the best Selenium testing platform
>> available.
>> Simple to use. Nothing to install. Get started now for free."
>> http://p.sf.net/sfu/SauceLabs
>> _______________________________________________
>> Jts-topo-suite-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>>
>
>
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user

Reply via email to