Hi Jeff,

The following code snippets should help...

Geometry geom = (Geometry) feature.getDefaultGeometry();

// this should always be true for a Geometry object from a shapefile
// (using the GeoTools Geometries enum
boolean isMulitPolygon = Geometries.get(geom) == Geometries.MULTIPOLYGON;

// need to allow for the possibility of multiple disjunct polygons
int numPolys = geom.getNumGeometries();
for (int ip = 0; ip < numPolys; ip++) {
    Polygon p = (Polygon) geom.getGeometryN(ip);

    // get the outer boundary like this
    LineString boundary = p.getExteriorRing();

    // check for holes
    boolean hasHoles = p.getNumInteriorRing() > 0;

    // if there are some holes, get the first one
    if (hasHoles) {
        LineString hole1 = p.getInteriorRingN(0);
    }
}

Hope this helps.

Michael
On 18 January 2011 14:16, Jeff Storey <jeff.sto...@nextcentury.com> wrote:
> I read a shapefile, and the geometry I read contains multiple polygons, some
> of which are holes. Is there an easy way to determine which are holes and
> which are not? Do I need to check if the vertices are clockwise or
> counterclockwise? Or is there a function in geotools which will
> automatically subtract out the holes and return a new polygon with the holes
> subtracted out?
>
>
>
> Thanks,
>
> Jeff
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Geotools-gt2-users mailing list
> Geotools-gt2-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to