[Schmitzm-commits] r1046 - in branches/2.2.x/src/skrueger: . geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 22 14:10:53 CEST 2010


Author: mojays
Date: 2010-09-22 14:10:52 +0200 (Wed, 22 Sep 2010)
New Revision: 1046

Modified:
   branches/2.2.x/src/skrueger/AttributeMetaDataAttributeTypeFilter.java
   branches/2.2.x/src/skrueger/geotools/AttributeMetadataMap.java
   branches/2.2.x/src/skrueger/geotools/StyledFeatureCollection.java
   branches/2.2.x/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
Log:
BugFix: deal with "auto-put" behavior of AttributeMetadataMapImpl.get(.) in AttributeMetaDataAttributeTypeFilter, so that "the_geom" is never (automatically) inserted in the AMD
StyledFeatureCollection: check for geometry attribute by FeatureUtil.isGeometryAttribute(.)

Modified: branches/2.2.x/src/skrueger/AttributeMetaDataAttributeTypeFilter.java
===================================================================
--- branches/2.2.x/src/skrueger/AttributeMetaDataAttributeTypeFilter.java	2010-09-22 11:55:59 UTC (rev 1045)
+++ branches/2.2.x/src/skrueger/AttributeMetaDataAttributeTypeFilter.java	2010-09-22 12:10:52 UTC (rev 1046)
@@ -77,10 +77,21 @@
     // are treated as visible
     if ( attrMetaDataMap == null )
       return NO_GEOMETRY.accept(type);
-
+    
+    // no geometry attributes at all
+    if ( !NO_GEOMETRY.accept(type) )
+      return false;
+    
+    // Auto-Insert-Behavior of AttributeMetaDataMapImpl.get(.) constrains
+    // us to first check the containing of the attribute in the, so that we
+    // do not accidentally insert an attribute to the map (especially
+    // "the_geom"!!!)
+    // --> if meta data is not specified, do not except it by the filter
+    if ( !attrMetaDataMap.containsKey(type.getName()) )
+        return false;
+    
+    // Check the visible property of meta data
     final AttributeMetadataImpl metaData = attrMetaDataMap.get(type.getName());
-    return NO_GEOMETRY.accept(type)  // no geometry attributes at all
-        && metaData != null               // meta data must be present for column
-        && metaData.isVisible();          // attribute must be visible
+    return  metaData.isVisible(); 
   }
 }

Modified: branches/2.2.x/src/skrueger/geotools/AttributeMetadataMap.java
===================================================================
--- branches/2.2.x/src/skrueger/geotools/AttributeMetadataMap.java	2010-09-22 11:55:59 UTC (rev 1045)
+++ branches/2.2.x/src/skrueger/geotools/AttributeMetadataMap.java	2010-09-22 12:10:52 UTC (rev 1046)
@@ -161,5 +161,14 @@
 		}
 		return list;
 	}
+	
+	/**
+	 * Just for debuggung. Simply returns {@code super.put(.)}.
+	 * TODO: remove this method.
+	 */
+	@Override
+	public AMD_IMPL put(Name key, AMD_IMPL value) {
+	  return super.put(key, value);
+	};
 
 }

Modified: branches/2.2.x/src/skrueger/geotools/StyledFeatureCollection.java
===================================================================
--- branches/2.2.x/src/skrueger/geotools/StyledFeatureCollection.java	2010-09-22 11:55:59 UTC (rev 1045)
+++ branches/2.2.x/src/skrueger/geotools/StyledFeatureCollection.java	2010-09-22 12:10:52 UTC (rev 1046)
@@ -320,7 +320,7 @@
 		SimpleFeatureType ftype = fc.getSchema();
 		for (int i = 0; i < ftype.getAttributeCount(); i++) {
 			AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i);
-			if (aDesc != ftype.getGeometryDescriptor())
+			if ( !FeatureUtil.isGeometryAttribute(aDesc) )
 				metaDataMap.put(aDesc.getName(), new AttributeMetadataImpl( new NameImpl( aDesc.getName().getNamespaceURI(), aDesc.getName().getLocalPart()), 
 						true, // visible
 						new Translation(aDesc.getLocalName()), // Column name

Modified: branches/2.2.x/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- branches/2.2.x/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2010-09-22 11:55:59 UTC (rev 1045)
+++ branches/2.2.x/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2010-09-22 12:10:52 UTC (rev 1046)
@@ -127,7 +127,7 @@
 		this.filter = filter;
 		this.amdMap = amdm;
 		this.amdMapVisibleOnly = amdMap.sortedValuesVisibleOnly();
-
+		
 		FeatureCollection<SimpleFeatureType, SimpleFeature> fc = null;
 		if (fs != null) {
 
@@ -136,7 +136,7 @@
 			final SimpleFeatureType schema = fs.getSchema();
 			Query query = new DefaultQuery(schema.getTypeName(), filter);
 			if (amdm != null) {
-				LinkedHashSet<String> visibleAttrNames = new LinkedHashSet<String>();
+              LinkedHashSet<String> visibleAttrNames = new LinkedHashSet<String>();
 
 				// Add the column with the geometry (usually "the_geom") always
 				String geomColumnLocalName = schema.getGeometryDescriptor()



More information about the Schmitzm-commits mailing list