[Schmitzm-commits] r1159 - in trunk/src: schmitzm/geotools/feature schmitzm/swing skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 22 19:56:29 CEST 2010


Author: alfonx
Date: 2010-10-22 19:56:28 +0200 (Fri, 22 Oct 2010)
New Revision: 1159

Modified:
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
   trunk/src/schmitzm/swing/SwingUtil.java
   trunk/src/skrueger/geotools/StyledFS.java
   trunk/src/skrueger/geotools/StyledLayerInterface.java
Log:
First and very basic support for WFS in AtlasStyler

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-10-21 17:11:30 UTC (rev 1158)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-10-22 17:56:28 UTC (rev 1159)
@@ -87,6 +87,7 @@
 import org.geotools.resources.coverage.FeatureUtilities;
 import org.geotools.styling.Graphic;
 import org.geotools.styling.Mark;
+import org.geotools.styling.Rule;
 import org.geotools.styling.Style;
 import org.geotools.styling.StyleBuilder;
 import org.geotools.styling.Symbolizer;
@@ -106,6 +107,7 @@
 
 import schmitzm.geotools.FilterUtil;
 import schmitzm.geotools.GTUtil;
+import schmitzm.geotools.gui.GeoPositionLabel;
 import schmitzm.io.IOUtil;
 import schmitzm.lang.LangUtil;
 import schmitzm.lang.ResourceProvider;
@@ -150,7 +152,7 @@
 		return attrType instanceof GeometryAttributeType
 				|| attrType instanceof GeometryDescriptor;
 	}
-	
+
 	/**
 	 * This is a cheap and not good hack to extract the names of attributes used
 	 * in a ECQL expression. This is not the way to do it, but a try.
@@ -258,7 +260,9 @@
 		/** Line or LineString */
 		LINE,
 		/** Polygon */
-		POLYGON
+		POLYGON,
+		/** Not specified, possible when parsing WFS describe feature type **/
+		ANY
 	}
 
 	/**
@@ -314,6 +318,11 @@
 		else if (Polygon.class.isAssignableFrom(geometryType)
 				|| MultiPolygon.class.isAssignableFrom(geometryType))
 			return GeometryForm.POLYGON;
+		else if (com.vividsolutions.jts.geom.Geometry.class
+				.isAssignableFrom(geometryType)) {
+			// TODO This happens with some "special" WFS services and has to be ahndeletd much nicer
+			return GeometryForm.POLYGON;
+		}
 
 		// Aus anderem, doppelem alten code
 		// if (geometryAttrib != null
@@ -449,14 +458,27 @@
 	 *            GeometryAttributeType
 	 */
 	public static Style createDefaultStyle(GeometryForm geoForm) {
-		Style style;
+		Style style = null;
 		if (geoForm == GeometryForm.POLYGON)
 			style = createPolygonStyle(Color.ORANGE, Color.BLACK, 1);
 		else if (geoForm == GeometryForm.POINT)
 			style = createPointStyle(Color.RED);
+		else if (geoForm == GeometryForm.LINE)
+			style = createLineStyle(Color.BLUE, 1);
 		else
-			style = createLineStyle(Color.BLUE, 1);
+		// if (geoForm == GeometryForm.ANY)
+		{
 
+			// Create a defautl Style including the polygon and point default
+			// style.
+			style = createPolygonStyle(Color.ORANGE, Color.BLACK, 1);
+
+			Rule rule = createPointStyle(Color.RED).featureTypeStyles().get(0)
+					.rules().get(0);
+			style.featureTypeStyles().get(0).rules().add(rule);
+
+		}
+
 		// if (geometryAttrib != null
 		// && (com.vividsolutions.jts.geom.Polygon.class
 		// .isAssignableFrom(geometryAttrib.getType().getBinding()) ||
@@ -2010,6 +2032,11 @@
 			values = getDefaultAttributeValues(schema);
 
 		try {
+			
+			if (schema.getGeometryDescriptor().getType().isAbstract()) {
+				System.err.println("sdsdsds");
+			}
+			
 			SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
 			sampleFeature = builder.buildFeature("createSampleFeature_"
 					+ new Random().nextInt(), values);

Modified: trunk/src/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/src/schmitzm/swing/SwingUtil.java	2010-10-21 17:11:30 UTC (rev 1158)
+++ trunk/src/schmitzm/swing/SwingUtil.java	2010-10-22 17:56:28 UTC (rev 1159)
@@ -78,6 +78,7 @@
 
 import schmitzm.lang.LangUtil;
 import schmitzm.lang.ResourceProvider;
+import skrueger.swing.AtlasDialog;
 
 /**
  * Diese Klasse beinhaltet statische Hilfsfunktionen fuer das Arbeiten mit
@@ -1452,4 +1453,5 @@
 			throw new RuntimeException("Not on EDT!");
 		}
 	}
+
 }

Modified: trunk/src/skrueger/geotools/StyledFS.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFS.java	2010-10-21 17:11:30 UTC (rev 1158)
+++ trunk/src/skrueger/geotools/StyledFS.java	2010-10-22 17:56:28 UTC (rev 1159)
@@ -76,7 +76,7 @@
 	 * A unique ID which identifies the Layer in the Atlas. It's more important
 	 * than it should be ;-)
 	 */
-	private String id;
+	final private String id;
 
 	private Style style;
 
@@ -101,14 +101,21 @@
 	 * @param sldFile
 	 *            may be <code>null</code>. Otherwise the SLD {@link File} to
 	 *            import and associate with this {@link StyledFS}
+	 * 
+	 * @param id
+	 *            <code>null</code> is allowed and will autogenerate an id
 	 */
 	public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
-			File sldFile) {
+			File sldFile, String id) {
 
 		this.fs = fs;
 
-		id = StyledFS.class.getSimpleName()
-				+ new Random(new Date().getTime()).nextInt(10000000);
+		if (id == null) {
+			this.id = StyledFS.class.getSimpleName()
+					+ new Random(new Date().getTime()).nextInt(10000000);
+		} else {
+			this.id = id;
+		}
 
 		this.sldFile = sldFile;
 
@@ -133,9 +140,14 @@
 	}
 
 	public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs) {
-		this(fs, null);
+		this(fs, (File) null, null);
 	}
 
+	public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
+			String id) {
+		this(fs, null, id);
+	}
+
 	public void dispose() {
 	}
 
@@ -160,7 +172,7 @@
 
 				crs = fs.getSchema().getGeometryDescriptor()
 						.getCoordinateReferenceSystem();
-				
+
 				if (crs == null) {
 					LOGGER.warn("Could not determine the CRS of " + getTitle()
 							+ ". Using default "
@@ -282,8 +294,8 @@
 				// with Translations ;-)
 				AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
 						new NameImpl(attDesc.getName().getNamespaceURI(),
-								attDesc.getName().getLocalPart()), map
-								.getLanguages());
+								attDesc.getName().getLocalPart()),
+						map.getLanguages());
 				if (String.class.isAssignableFrom(attDesc.getType()
 						.getBinding())) {
 					// For Strings we add the "" as NODATA values
@@ -348,7 +360,10 @@
 		// return fc.subCollection(filter);
 
 		try {
-			return getFeatureSource().getFeatures(filter);
+			if (filter != Filter.INCLUDE)
+				return getFeatureSource().getFeatures(filter);
+			else
+				return getFeatureSource().getFeatures();
 		} catch (IOException e) {
 			throw new RuntimeException(e);
 		}
@@ -389,4 +404,12 @@
 
 	}
 
+	public void setTitle(String title) {
+		setTitle(new Translation(title));
+	}
+
+	public void setDesc(String desc) {
+		setDesc(new Translation(desc));
+	}
+
 }

Modified: trunk/src/skrueger/geotools/StyledLayerInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledLayerInterface.java	2010-10-21 17:11:30 UTC (rev 1158)
+++ trunk/src/skrueger/geotools/StyledLayerInterface.java	2010-10-22 17:56:28 UTC (rev 1159)
@@ -157,5 +157,5 @@
 	 */
 	public void uncache();
 
-
+//	public String getLegendHtml();
 }



More information about the Schmitzm-commits mailing list