[MXD2map-commits] r337:ee77a3ae0201

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 6 12:08:29 CET 2012


details:   http://hg.intevation.org/geospatial/mxd2map/rev/ee77a3ae0201

changeset: 337:ee77a3ae0201

user:      Andre Heinecke <aheinecke at intevation.de>

date:      Tue Nov 06 12:05:26 2012 +0100

description:
* src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java:
    Log as UniqueValueRendererReader, add support for default class,
    Fix splitting of values.


diffstat:

 ChangeLog                                                        |   8 +-
 src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java |  79 +++++----
 2 files changed, 47 insertions(+), 40 deletions(-)

diffs (124 lines):

diff -r a46adb3697fa -r ee77a3ae0201 ChangeLog
--- 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 at intevation.de>
+2012-11-06  Andre Heinecke <aheinecke at 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 at intevation.de>
 
 	* src/java/de/intevation/mxd/reader/WMSLayerReader.java:
 	Do not write WMS Verstions in the map file that mapserver
diff -r a46adb3697fa -r ee77a3ae0201 src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java
--- 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 {
+                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);
+                    }
+                    else {
+                        rendererElement.setAttribute("value", value);
+                    }
 
-            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++;
+                    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("value_" + j, value);
+                    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();


More information about the MXD2map-commits mailing list