[geos-devel] Holes in holes

Frederik Ramm frederik at remote.org
Tue Nov 24 05:53:57 EST 2009


Hi,

    I'm trying to create a polygon with a hole that has a hole (think: 
forest with a clearing but a patch of trees in the middle of that 
clearing).

I must admit that I am slightly insecure on the question whether this is 
something that the OGC simple features spec supports; their definition 
of a polygon seems to be "something that has a closed outer ring and 
0..n interior rings", but I cannot find information on whether those 
interior rings may contain each other or not.

GEOS is of the opinion that a polygon made of three concentric rings, 
the inner two being "interior" rings, is invalid, as per this snippet:

     LinearRing *a = (LinearRing *) reader->read("LINEARRING(0 0, 10 0, 
10 10, 0 10, 0 0)");
     Geometry *b = reader->read("LINEARRING(1 1, 9 1, 9 9, 1 9, 1 1)");
     Geometry *c = reader->read("LINEARRING(2 2, 2 8, 8 8, 8 2, 2 2)");
     vector<Geometry *> v;
     v.push_back(b);
     v.push_back(c);
     Geometry *p = global_factory->createPolygon(a, &v);
     cout << "valid: " << p->isValid() << endl;

If I modify the above to create a multipolygon, consisting of the 
"forest with a hole" as polygon #1 and the "patch of trees inside the 
hole" as polygon #2, GEOS tells me that this geometry is valid:

Is this the correct way to describe what I want - is a polygon with a 
hole in a hole always a multipolygon? Is the resulting structure really 
a valid multipolygon?

Bye
Frederik




More information about the geos-devel mailing list