[Schmitzm-commits] r733 - trunk/src/schmitzm/geotools/feature

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Feb 28 19:13:59 CET 2010


Author: alfonx
Date: 2010-02-28 19:13:58 +0100 (Sun, 28 Feb 2010)
New Revision: 733

Modified:
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
Log:
AtlasStyler SLD parsing: Improved validation & correction of property names used in a Style against the existing Schema.

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-02-28 16:52:35 UTC (rev 732)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-02-28 18:13:58 UTC (rev 733)
@@ -1686,7 +1686,7 @@
 	 * 
 	 * @param geomType
 	 *            LineString.class, Point.class or Polygon.class from com.jts...
-	 *            
+	 * 
 	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
 	 *         Kr&uuml;ger</a>
 	 */
@@ -1695,7 +1695,7 @@
 		// Create the only attribute
 		final AttributeDescriptor geometryAttribut = AttributeTypeFactory
 				.newAttributeType("the_geom", geomType);
-		
+
 		// Create the FeatureType with the only attribute
 		final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
 		builder.setCRS(crs);
@@ -2151,7 +2151,7 @@
 		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
@@ -2162,7 +2162,8 @@
 	 * @param name
 	 *            localname of an attribte to look for
 	 * 
-	 * @return If no match is found, the first numeric attribute is returned.If no numeric attribute exists returns null;
+	 * @return If no match is found, the first numeric attribute is returned.If
+	 *         no numeric attribute exists returns null;
 	 */
 	public static Name findBestMatchingAttributeFallBackFirstNumeric(
 			SimpleFeatureType schema, String localName) {
@@ -2177,7 +2178,6 @@
 		return bestmatch;
 	}
 
-
 	/**
 	 * @return A list of numerical field names (withouth any null or "")
 	 */
@@ -2216,7 +2216,6 @@
 		return numericalFieldNames;
 	}
 
-
 	/**
 	 * 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
@@ -2247,13 +2246,19 @@
 	 * @param schema
 	 *            SimpleFeatureType to check against
 	 * @param name
-	 *            localname of an attribte to look for
+	 *            localname of an attribte to look for. If <code>null</code>,
+	 *            <code>null</code> is returned.
 	 * 
 	 * @return If no match is found, <code>null</code> is returned.
 	 */
-	public static org.opengis.feature.type.Name findBestMatchingAttribute(SimpleFeatureType schema,
-			String localName) {
-//		asdads _ _ _ 
+	public static org.opengis.feature.type.Name findBestMatchingAttribute(
+			SimpleFeatureType schema, String localName) {
+
+		if (localName == null) {
+			return null;
+		}
+
+		// asdads _ _ _
 		List<AttributeDescriptor> attributeDescriptors = schema
 				.getAttributeDescriptors();
 		if (attributeDescriptors.size() == 0) {
@@ -2273,14 +2278,16 @@
 				return d.getName();
 			}
 		}
+
 		// Checking for irgnoreCase match with empty spaces converted to _
 		for (AttributeDescriptor d : attributeDescriptors) {
-			if (d.getName().getLocalPart().replace(" ", "_").equalsIgnoreCase(localName.replace(" ", "_"))) {
+			if (d.getName().getLocalPart().replace(" ", "_").equalsIgnoreCase(
+					localName.replace(" ", "_"))) {
 				LOGGER.error("Corrected attributeName '" + localName + "' to "
 						+ d.getName().getLocalPart());
 				return d.getName();
 			}
-		}		
+		}
 		return null;
 	}
 



More information about the Schmitzm-commits mailing list