That makes sense, thanks for the explaination.  And yep, I'm using NTS.

On Wed, Mar 4, 2009 at 11:41 AM, Martin Davis <[email protected]>wrote:

> I notice you're using NTS (right?)...  The behaviour in JTS is slightly
> different - it returns a POLYGON EMPTY.
>
> Simplification always returns a geometry of the same type as the input
> geometry, and by default it attempts to ensure valid topology (by applying
>  a buffer(0) - which is a bit of a hack, I admit). This is why it returns an
> empty polygon.
>
> You can prevent the validity enforcement by using
> DouglasPeuckerSimplifier.setEnsureValid(false)
>
> AFAIK there's no clear standard on how to handle degenerate cases like this
> - different use cases might require different kinds of output.  You should
> check for degenerate input first and convert it according to your precise
> need.
>
> Jeff Adams wrote:
>
>> It shouldn't have been zero, although I don't actually know what it was
>> (It was due to a bug in my code, that has since been fixed).
>> However I just tried to reproduce it with a test case and simplify seems
>> to return an empty geometrycollection (which seems like resonable behavior,
>> although better behavior might be to produce a single point at the center).
>>  So perhaps I was mistaken about exactly what was going on...  It makes me
>> wonder if my code that calls simplify is not correct ;-).  I'll let you know
>> if I am able to reproduce this again.
>>
>> Here is my simple test case if you want to mess around with it:
>>
>>        [Test]
>>        public void TestSimplifyBadPoly()
>>        {
>>            Polygon p = new Polygon(new LinearRing(new ICoordinate[] {
>>                new Coordinate(1, 1), new Coordinate(1, 1),
>>                new Coordinate(1, 1), new Coordinate(1, 1),
>>                new Coordinate(1, 1)}));
>>            Console.Out.WriteLine("Bad polygon: " + p);
>>            IGeometry simpleP = DouglasPeuckerSimplifier.Simplify(p, 0.1);
>>            Console.Out.WriteLine("Simple bad polygon: " + simpleP);
>>            Assert.AreNotEqual(p, simpleP, "Simplify didn't do anything to
>> this invalid polygon.");
>>        }
>>
>>
>> On Tue, Mar 3, 2009 at 11:39 AM, Martin Davis 
>> <[email protected]<mailto:
>> [email protected]>> wrote:
>>
>>    What was your simplification tolerance?  If it was 0 as well, then
>>    nothing would be changed.
>>
>>    If not, this might be a bug - although this is a bit outside what
>>    would be considered as reasonable input to a simplification routine.
>>
>>    Jeff Adams wrote:
>>
>>        - Show quoted text -
>>        I have some code that creates "circle" polygons given a
>>        center, radius, and number of points.  The circle gets passed
>>        to some other code that happens to simplify the polygon (using
>>        DouglasPeucker).
>>
>>        I accidentally wound up calling this code with a radius of
>>        zero.  This produced a 46-point polygon where all the points
>>        were identical.  What was surprising to me is that the
>>        simplifier didn't seem to change it at all.  I would have
>>        expected it to return a single point, or throw an exception,
>>        or something.  Is this (doing nothing) the expected behavior?
>>
>>        Thanks,
>>        Jeff
>>
>>  ------------------------------------------------------------------------
>>
>>        _______________________________________________
>>        jts-devel mailing list
>>        [email protected]
>>        <mailto:[email protected]>
>>        http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>>
>>    --    Martin Davis
>>    Senior Technical Architect
>>    Refractions Research, Inc.
>>    (250) 383-3022
>>
>>    _______________________________________________
>>    jts-devel mailing list
>>    [email protected]
>>    <mailto:[email protected]>
>>    http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> jts-devel mailing list
>> [email protected]
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>>
> - Show quoted text -
>
> --
> Martin Davis
> Senior Technical Architect
> Refractions Research, Inc.
> (250) 383-3022
>
> _______________________________________________
> jts-devel mailing list
> [email protected]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel

Reply via email to