changeset 337:ee77a3ae0201

* src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java: Log as UniqueValueRendererReader, add support for default class, Fix splitting of values.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 06 Nov 2012 12:05:26 +0100
parents a46adb3697fa
children b3048df06b66
files ChangeLog src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java
diffstat 2 files changed, 47 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 05 16:28:36 2012 +0100
+++ b/ChangeLog	Tue Nov 06 12:05:26 2012 +0100
@@ -1,4 +1,10 @@
-2012-10-26  Andre Heinecke <aheinecke@intevation.de>
+2012-11-06  Andre Heinecke <aheinecke@intevation.de>
+
+	* src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java:
+	Log as UniqueValueRendererReader, add support for default class,
+	Fix splitting of values.
+
+_2012-10-26  Andre Heinecke <aheinecke@intevation.de>
 
 	* src/java/de/intevation/mxd/reader/WMSLayerReader.java:
 	Do not write WMS Verstions in the map file that mapserver
--- a/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Mon Nov 05 16:28:36 2012 +0100
+++ b/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Tue Nov 06 12:05:26 2012 +0100
@@ -42,7 +42,7 @@
      * The logger.
      */
     private static final Logger logger =
-        Logger.getLogger(FeatureLayerReader.class);
+        Logger.getLogger(UniqueValueRendererReader.class);
 
     /**
      * Private Member.
@@ -91,13 +91,10 @@
      * @return The parent XML node.
      */
     public Element read() {
-        logger.debug("read()");
         int count = 0;
         try {
             count = renderer.getClassCount();
-            if(renderer.isUseDefaultSymbol()) {
-                count--;
-            }
+            logger.debug("Renderer with " + count + " classes.");
         }
         catch(IOException ioe) {
             logger.error(
@@ -107,43 +104,47 @@
         }
         for(int i = 0; i < count; i++) {
             Element rendererElement = util.addRenderer(layer);
-
+            ISymbol sym;
             try {
-                String value = renderer.getValue(i);
-                value = value.replaceAll(", ", ",");
-                if(value.indexOf(",") > 0) {
-                    int j = 0;
-                    while(value.indexOf(",") > 0) {
-                        String v = value.substring(0, value.indexOf(","));
-                        rendererElement.setAttribute("value_" + j, v);
-                        value = value.substring(
-                            value.indexOf(",") + 1,
-                            value.length());
-                        j++;
+                if (!renderer.isUseDefaultSymbol() || i != count - 1) {
+                    // When a default symbol exists the last class is the default class
+                    String value = renderer.getValue(i);
+                    String fieldSep = renderer.getFieldDelimiter();
+                    if(value.indexOf(fieldSep) > 0) {
+                        int j = 0;
+                        while(value.indexOf(fieldSep) > 0) {
+                            String v = value.substring(0, value.indexOf(fieldSep));
+                            rendererElement.setAttribute("value_" + j, v);
+                            value = value.substring(
+                                    value.indexOf(fieldSep) + fieldSep.length(),
+                                    value.length());
+                            j++;
+                        }
+                        rendererElement.setAttribute("value_" + j, value);
                     }
-                    rendererElement.setAttribute("value_" + j, value);
+                    else {
+                        rendererElement.setAttribute("value", value);
+                    }
+
+                    value = renderer.getValue(i);
+                    rendererElement.setAttribute("name", renderer.esri_getClass(i));
+                    rendererElement.setAttribute("description",
+                            renderer.getDescription(value));
+
+                    rendererElement.setAttribute("label", renderer.getLabel(value));
+                    rendererElement.setAttribute(
+                            "field_count",
+                            String.valueOf(renderer.getFieldCount()));
+                    for(int j = 0; j < renderer.getFieldCount(); j++) {
+                        rendererElement.setAttribute(
+                                "expression_field_" + j,
+                                renderer.getField(j));
+                    }
+                    rendererElement.setAttribute("expression_operator", "=");
+                    sym = renderer.getSymbol(value);
+                } else {
+                    sym = renderer.getDefaultSymbol();
                 }
-                else {
-                    rendererElement.setAttribute("value", value);
-                }
-
-                value = renderer.getValue(i);
-                rendererElement.setAttribute("name", renderer.esri_getClass(i));
-                rendererElement.setAttribute("description",
-                    renderer.getDescription(value));
-
-                rendererElement.setAttribute("label", renderer.getLabel(value));
-                rendererElement.setAttribute(
-                    "field_count",
-                    String.valueOf(renderer.getFieldCount()));
-                for(int j = 0; j < renderer.getFieldCount(); j++) {
-                    rendererElement.setAttribute(
-                        "expression_field_" + j,
-                        renderer.getField(j));
-                }
-                rendererElement.setAttribute("expression_operator", "=");
-
-                ISymbol sym = renderer.getSymbol(value);
                 MarkerSymbolReader markerReader = new MarkerSymbolReader();
                 LineSymbolReader lineReader = new LineSymbolReader();
                 FillSymbolReader fillReader = new FillSymbolReader();
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)