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]>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]
>> 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]
> 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