[Schmitzm-commits] r80 - trunk/src/schmitzm/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Apr 22 15:47:56 CEST 2009
Author: alfonx
Date: 2009-04-22 15:47:55 +0200 (Wed, 22 Apr 2009)
New Revision: 80
Modified:
trunk/src/schmitzm/geotools/GTUtil.java
Log:
* Moved utility functions from AtlasStyler's Utilities.java to GTUtil.java The methods "isPoint(), isPolygon(), isLineString()" return boolean for given parameters of type FeatureSource, FeatureCollection or FeatureAttributeType.
Modified: trunk/src/schmitzm/geotools/GTUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/GTUtil.java 2009-04-22 13:24:35 UTC (rev 79)
+++ trunk/src/schmitzm/geotools/GTUtil.java 2009-04-22 13:47:55 UTC (rev 80)
@@ -17,6 +17,9 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import org.geotools.data.FeatureSource;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.GeometryAttributeType;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.Envelope2D;
import org.geotools.referencing.CRS;
@@ -27,6 +30,13 @@
import org.apache.log4j.Logger;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.MultiLineString;
+import com.vividsolutions.jts.geom.MultiPoint;
+import com.vividsolutions.jts.geom.MultiPolygon;
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.geom.Polygon;
+
/**
* Diese Klasse enthaelt allgemeine Funktionen fuer die Arbeit mit Geotools.
* @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
@@ -168,4 +178,81 @@
// Subset nur bzgl. des Bereichs in dem auch das Raster liegt
return JTS.getEnvelope2D(intersetionEnvJTS,crs);
}
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureSource}'s default
+ * Geometry contains polygons or multipolygons
+ */
+ public static boolean isPolygon(FeatureSource featureSource) {
+ return isPolygon(featureSource.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureCollection}'s
+ * default Geometry contains polygons or multipolygons
+ */
+ public static boolean isPolygon(FeatureCollection featureCollection) {
+ return isPolygon(featureCollection.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link GeometryAttributeType} is
+ * polygon or multipolygon
+ */
+ public static boolean isPolygon(GeometryAttributeType geometryAttributeType) {
+ return (geometryAttributeType.getBinding() == MultiPolygon.class || geometryAttributeType
+ .getBinding() == Polygon.class);
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureSource}'s default
+ * Geometry contains points or multipoints
+ */
+ public static boolean isPoint(FeatureSource featureSource) {
+ return isPoint(featureSource.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureCollection}'s
+ * default Geometry contains points or multipoints
+ */
+ public static boolean isPoint(FeatureCollection featureCollection) {
+ return isPoint(featureCollection.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link GeometryAttributeType} is
+ * point or multipoint
+ */
+ public static boolean isPoint(GeometryAttributeType geometryAttributeType) {
+ return (geometryAttributeType.getBinding() == Point.class || geometryAttributeType
+ .getBinding() == MultiPoint.class);
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureSource}'s default
+ * Geometry contains lines or multilines
+ */
+ public static boolean isLineString(FeatureSource featureSource) {
+ return isLineString(featureSource.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link FeatureCollection}'s
+ * default Geometry contains lines or multilines
+ */
+ public static boolean isLineString(FeatureCollection featureCollection) {
+ return isLineString(featureCollection.getSchema().getDefaultGeometry());
+ }
+
+ /**
+ * @return <code>true</code> if the given {@link GeometryAttributeType} is
+ * line of multiline
+ */
+ public static boolean isLineString(
+ GeometryAttributeType geometryAttributeType) {
+ return ((geometryAttributeType.getBinding() == LineString.class) || geometryAttributeType
+ .getBinding() == MultiLineString.class);
+ }
+
}
More information about the Schmitzm-commits
mailing list