[Schmitzm-commits] r523 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/feature schmitzm/geotools/gui schmitzm/geotools/styling skrueger

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 18 10:54:53 CET 2009


Author: alfonx
Date: 2009-11-18 10:54:52 +0100 (Wed, 18 Nov 2009)
New Revision: 523

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java
Log:
* Moved some methods from StylingUtil to FeatureUtil
* Added a new constructor to AttributeMetadata that automatically sets its weight

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-11-17 13:07:57 UTC (rev 522)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-11-18 09:54:52 UTC (rev 523)
@@ -91,6 +91,7 @@
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.Name;
 import org.opengis.filter.Filter;
 import org.opengis.filter.FilterFactory;
 import org.opengis.filter.FilterFactory2;
@@ -2028,7 +2029,66 @@
 		return 	getWrappedGeoObject((FeatureSource<SimpleFeatureType, SimpleFeature>) mapLayer
 				.getFeatureSource());
 	}
+	
 
+	/**
+	 * Checks whether the given attribute local name exists in the schema. If no
+	 * exact match is found, an ingnoreCase match is performed. If the schema
+	 * has no attributes, an exception is thrown.
+	 * 
+	 * @param schema
+	 *            SimpleFeatureType to check against
+	 * @param name
+	 *            localname of an attribte to look for
+	 * 
+	 * @return If no match is found, the first attribute is returned.
+	 */
+	public static Name findBestMatchingAttributeFallBackFirst(
+			SimpleFeatureType schema, String localName) {
+
+		Name bestmatch = findBestMatchingAttribute(schema, localName);
+
+		if (bestmatch == null)
+			return schema.getAttributeDescriptors().get(0).getName();
+		return bestmatch;
+	}
+
+	/**
+	 * Checks whether the given attribute local name exists in the schema. If no
+	 * exact match is found, an ingnoreCase match is performed. If the schema
+	 * has no attributes, an exception is thrown.
+	 * 
+	 * @param schema
+	 *            SimpleFeatureType to check against
+	 * @param name
+	 *            localname of an attribte to look for
+	 * 
+	 * @return If no match is found, <code>null</code> is returned.
+	 */
+	public static Name findBestMatchingAttribute(SimpleFeatureType schema,
+			String localName) {
+		List<AttributeDescriptor> attributeDescriptors = schema
+				.getAttributeDescriptors();
+		if (attributeDescriptors.size() == 0) {
+			LOGGER.error("The schmema has no attributes!");
+		}
+
+		// Checking for exact match
+		for (AttributeDescriptor d : attributeDescriptors) {
+			if (d.getName().getLocalPart().equals(localName))
+				return d.getName();
+		}
+		// Checking for irgnoreCase match
+		for (AttributeDescriptor d : attributeDescriptors) {
+			if (d.getName().getLocalPart().equalsIgnoreCase(localName)) {
+				LOGGER.error("Corrected attributeName '" + localName + "' to "
+						+ d.getName().getLocalPart());
+				return d.getName();
+			}
+		}
+		return null;
+	}
+
 	// /**
 	// * Extrahiert alle Geometrien aus einer FeatureCollection. Fuer jedes
 	// * Geometry-Attribut der FeatureCollection wird eine GeometrieCollection
@@ -2081,5 +2141,6 @@
 	// gcArr[i] = (GeometryCollection)gcVec.elementAt(i);
 	// return gcArr;
 	// }
+	
 
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-17 13:07:57 UTC (rev 522)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-18 09:54:52 UTC (rev 523)
@@ -404,7 +404,6 @@
 	 * Macht nichts, wenn {@code null} uebergeben wird.
 	 * 
 	 * <br>
-	 * A refresh of the map is NOT called.
 	 * 
 	 * @param layer
 	 *            ein Layer
@@ -412,7 +411,6 @@
 	public void zoomToLayer(MapLayer layer) {
 		if (layer == null)
 			return;
-		// This action ususally takes some time..
 		try {
 
 			// BB umrechnen von Layer-CRS in Map-CRS
@@ -1223,7 +1221,7 @@
 	 *            zu ueberpruefendes Layer
 	 */
 	public static boolean isGridCoverageLayer(MapLayer layer) {
-		return (MapLayerUtils.isGridLayer(layer).get(MapLayerUtils.IS_GRID_KEY) == Boolean.TRUE);
+		return (MapLayerUtils.isGridLayer(layer));
 	}
 
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-11-17 13:07:57 UTC (rev 522)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-11-18 09:54:52 UTC (rev 523)
@@ -1084,7 +1084,8 @@
 		Style exportStyle = removeSelectionFeatureTypeStyle(origStyle);
 
 		if (!isStyleDifferent(exportStyle, exportFile)) {
-//			LOGGER.debug("Style " + exportFile + " didn't change, not saving.");
+			// LOGGER.debug("Style " + exportFile +
+			// " didn't change, not saving.");
 			return false;
 		}
 
@@ -1123,17 +1124,19 @@
 
 		return cleanStyle;
 	}
-	
 
 	/**
-	 * Returns <code>null</code> or any {@link FeatureTypeStyle} that is SELECTION related.
+	 * Returns <code>null</code> or any {@link FeatureTypeStyle} that is
+	 * SELECTION related.
 	 * 
 	 * @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
 	 */
-	public static FeatureTypeStyle getSelectionFeatureTypeStyle(final Style style) {
-		
-		if (style == null) return null;
+	public static FeatureTypeStyle getSelectionFeatureTypeStyle(
+			final Style style) {
 
+		if (style == null)
+			return null;
+
 		// Remove any selection-FeatureTypeStyle from the new Style
 		for (int ii = 0; ii < style.featureTypeStyles().size(); ii++) {
 
@@ -2436,38 +2439,48 @@
 			};
 
 			public void visit(LineSymbolizer sym) {
-				sym.setGeometryPropertyName(findBestMatchingAttribute(schema,
-						sym.getGeometryPropertyName()).getLocalPart());
+				sym
+						.setGeometryPropertyName(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+								schema, sym.getGeometryPropertyName())
+								.getLocalPart());
 				super.visit(sym);
 			}
 
 			public void visit(PolygonSymbolizer sym) {
-				sym.setGeometryPropertyName(findBestMatchingAttribute(schema,
-						sym.getGeometryPropertyName()).getLocalPart());
+				sym
+						.setGeometryPropertyName(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+								schema, sym.getGeometryPropertyName())
+								.getLocalPart());
 				super.visit(sym);
 			}
 
 			public void visit(PointSymbolizer sym) {
-				sym.setGeometryPropertyName(findBestMatchingAttribute(schema,
-						sym.getGeometryPropertyName()).getLocalPart());
+				sym
+						.setGeometryPropertyName(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+								schema, sym.getGeometryPropertyName())
+								.getLocalPart());
 				super.visit(sym);
 			}
 
 			public void visit(TextSymbolizer sym) {
-				sym.setGeometryPropertyName(findBestMatchingAttribute(schema,
-						sym.getGeometryPropertyName()).getLocalPart());
+				sym
+						.setGeometryPropertyName(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+								schema, sym.getGeometryPropertyName())
+								.getLocalPart());
 
 				if (sym.getLabel() instanceof PropertyName) {
 					PropertyName propertyname = (PropertyName) sym.getLabel();
-					sym.setLabel(ff.property(findBestMatchingAttribute(schema,
-							propertyname.getPropertyName())));
+					sym.setLabel(ff
+							.property(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+									schema, propertyname.getPropertyName())));
 				}
 
 				if (sym.getPriority() instanceof PropertyName) {
 					PropertyName propertyname = (PropertyName) sym
 							.getPriority();
-					sym.setPriority(ff.property(findBestMatchingAttribute(
-							schema, propertyname.getPropertyName())));
+					sym.setPriority(ff
+							.property(FeatureUtil.findBestMatchingAttributeFallBackFirst(
+									schema, propertyname.getPropertyName())));
 				}
 
 				super.visit(sym);
@@ -2480,41 +2493,5 @@
 		return (Style) dsv.getCopy();
 	}
 
-	/**
-	 * Checks whether the given attribute local name exists in the schema. If no
-	 * exact match is found, an ingnoreCase match is performed. If no match is
-	 * found, the first attribute is returned. If the schema has no attributes,
-	 * an exception is thrown.
-	 * 
-	 * @param schema
-	 *            SimpleFeatureType to check against
-	 * @param name
-	 *            localname of an attribte to look for
-	 */
-	public static Name findBestMatchingAttribute(SimpleFeatureType schema,
-			String name) {
 
-		List<AttributeDescriptor> attributeDescriptors = schema
-				.getAttributeDescriptors();
-		if (attributeDescriptors.size() == 0) {
-			LOGGER.error("The schmema has no attributes!");
-		}
-
-		// Checking for exact match
-		for (AttributeDescriptor d : attributeDescriptors) {
-			if (d.getName().getLocalPart().equals(name))
-				return d.getName();
-		}
-		// Checking for irgnoreCase match
-		for (AttributeDescriptor d : attributeDescriptors) {
-			if (d.getName().getLocalPart().equalsIgnoreCase(name)) {
-				LOGGER.error("Corrected attributeName '" + name + "' to "
-						+ d.getName().getLocalPart());
-				return d.getName();
-			}
-		}
-
-		return attributeDescriptors.get(0).getName();
-	}
-
 }

Modified: branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java	2009-11-17 13:07:57 UTC (rev 522)
+++ branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java	2009-11-18 09:54:52 UTC (rev 523)
@@ -231,6 +231,11 @@
 		this(attDesc.getName());
 	}
 
+	public AttributeMetadata(AttributeDescriptor attDesc, int weight) {
+		this(attDesc.getName());
+		setWeight(weight);
+	}
+
 	public boolean isVisible() {
 		return visible;
 	}



More information about the Schmitzm-commits mailing list