[Schmitzm-commits] r658 - in branches/2.0-RC2/src/skrueger: . geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 3 16:32:23 CET 2010


Author: alfonx
Date: 2010-02-03 16:32:21 +0100 (Wed, 03 Feb 2010)
New Revision: 658

Modified:
   branches/2.0-RC2/src/skrueger/AttributeMetadata.java
   branches/2.0-RC2/src/skrueger/geotools/AttributeMetadataMap.java
   branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java
Log:
NODATA values defined in AttributeMetadata are now stored and loadedd from XML

Modified: branches/2.0-RC2/src/skrueger/AttributeMetadata.java
===================================================================
--- branches/2.0-RC2/src/skrueger/AttributeMetadata.java	2010-02-03 13:44:00 UTC (rev 657)
+++ branches/2.0-RC2/src/skrueger/AttributeMetadata.java	2010-02-03 15:32:21 UTC (rev 658)
@@ -30,10 +30,12 @@
 package skrueger;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.geotools.feature.NameImpl;
+import org.geotools.feature.Feature.NULL;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.Name;
 
@@ -75,9 +77,9 @@
 	/**
 	 * Allows to define general NODATA values for an attribute. e.g. -9999 can
 	 * be set and will always be interpreted as NULL internally and will usually
-	 * be ignored. TODO not implemented yet
+	 * be ignored. This overcomes the problem, that 
 	 **/
-	protected List<Object> nodataValues = new ArrayList<Object>();
+	protected HashSet<Object> nodataValues = new HashSet<Object>();
 
 	/** Translation of the attribute's title **/
 	protected Translation title = new Translation();
@@ -137,8 +139,27 @@
 		this.visible = visible;
 		this.unit = unit;
 	}
+	
 
 	/**
+	 * Creates an {@link AttributeMetadata} object with the following
+	 * information
+	 * 
+	 * @param colIdx
+	 *            The column index of this attribute in the underlying
+	 *            table/dbf/etc...
+	 * @param visible
+	 *            Shall this attribute be displayed or hidden from the user?
+	 * @param unit
+	 *            {@link String} of the unit that the information is in
+	 */
+	public AttributeMetadata(final Name name, final Boolean visible, final String unit) {
+		this.setName(name);
+		this.visible = visible;
+		this.unit = unit;
+	}
+
+	/**
 	 * Creates a new visible {@link AttributeMetadata}
 	 */
 	public AttributeMetadata(final Name name, final List<String> langs) {
@@ -256,7 +277,7 @@
 		return name;
 	}
 
-	public List<Object> getNodataValues() {
+	public HashSet<Object> getNodataValues() {
 		return nodataValues;
 	}
 
@@ -319,7 +340,7 @@
 		this.name = name;
 	}
 
-	public void setNodataValues(final List<Object> nodataValues) {
+	public void setNodataValues(final HashSet<Object> nodataValues) {
 		this.nodataValues = nodataValues;
 	}
 
@@ -364,4 +385,21 @@
 		sb.append("title="+getTitle().toString());
 		return sb.toString();
 	}
+
+	/**
+	 * Takes any value object and checks it againsts the NODATA values. If the
+	 * value equals a NODATA value, <code>null</code> is returned. Otherwise the
+	 * same object is returned.
+	 * 
+	 * Note: This method is called often.
+	 */
+	public Object fiterNodata(final Object value) {
+
+		// contains.. hash
+		for (final Object nodataValue : getNodataValues()) {
+			if (nodataValue.equals(value))
+				return null;
+		}
+		return value;
+	}
 }

Modified: branches/2.0-RC2/src/skrueger/geotools/AttributeMetadataMap.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/AttributeMetadataMap.java	2010-02-03 13:44:00 UTC (rev 657)
+++ branches/2.0-RC2/src/skrueger/geotools/AttributeMetadataMap.java	2010-02-03 15:32:21 UTC (rev 658)
@@ -34,7 +34,11 @@
 	 **/
 	private final List<String> langs;
 
-	@Deprecated
+	/**
+	 @Deprecated Use another constructor. AttributeMetadataMap is based on {@link Translation} and
+	 *             would like to know how many languages are supported, so the
+	 *             needed defaults can be created.
+	 */
 	public AttributeMetadataMap() {
 		langs = new ArrayList<String>();
 		langs.add(Translation.getActiveLang());

Modified: branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java	2010-02-03 13:44:00 UTC (rev 657)
+++ branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java	2010-02-03 15:32:21 UTC (rev 658)
@@ -307,6 +307,11 @@
 	 * 
 	 * @param element
 	 *            {@link Element} to parse
+	 *            
+	 *            TODO Since GP 1.3 the {@link AttributeMetadata} class has more
+	 *            attributes which are not used by Xulu/ISDSS. GP
+	 *            exports/imports the AMD via AMLExporter and AMLImporter
+	 *            classes. (SK, 3.2.2010)	 *            
 	 */
 	public static AttributeMetadataMap parseAttributeMetaDataMap(
 			final Element element) {
@@ -339,6 +344,11 @@
 	 * 
 	 * @param amd
 	 *            meta data for one attribute
+	 * 
+	 *            TODO Since GP 1.3 the {@link AttributeMetadata} class has more
+	 *            attributes which are not used by Xulu/ISDSS. GP
+	 *            exports/imports the AMD via AMLExporter and AMLImporter
+	 *            classes. (SK, 3.2.2010)
 	 */
 	public static Element createAttributeMetaDataElement(
 			final AttributeMetadata amd) {



More information about the Schmitzm-commits mailing list