3
* The JTS Topology Suite is a collection of Java classes that
4
* implement the fundamental operations required to validate a given
5
* geo-spatial data set to a known topological specification.
7
* Copyright (C) 2001 Vivid Solutions
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
* For more information, contact:
27
* 2328 Government Street
32
* www.vividsolutions.com
34
package com.vividsolutions.jts.geom.util;
37
import com.vividsolutions.jts.geom.*;
40
* Extracts all the 2-dimensional ({@link Polygon}) components from a {@link Geometry}.
44
public class PolygonExtracter
45
implements GeometryFilter
48
* Returns the Polygon components from a single geometry.
49
* If more than one geometry is to be processed, it is more
50
* efficient to create a single {@link PolygonExtracterFilter} instance
51
* and pass it to multiple geometries.
53
public static List getPolygons(Geometry geom)
55
List comps = new ArrayList();
56
geom.apply(new PolygonExtracter(comps));
62
* Constructs a PolygonExtracterFilter with a list in which to store Polygons found.
64
public PolygonExtracter(List comps)
69
public void filter(Geometry geom)
71
if (geom instanceof Polygon) comps.add(geom);