changeset 44:9b5fb5e5914d

Added expressions for mapserver classes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 18 Apr 2011 14:50:49 +0200
parents ef7ca23c4233
children 90d4de478f15
files ChangeLog src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java src/java/de/intevation/mxd/reader/SimpleRendererReader.java src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java src/java/de/intevation/mxd/writer/MapScriptWriter.java
diffstat 5 files changed, 79 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 15 15:44:54 2011 +0200
+++ b/ChangeLog	Mon Apr 18 14:50:49 2011 +0200
@@ -1,3 +1,14 @@
+2011-04-18  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java,
+	  src/java/de/intevation/mxd/reader/SimpleRendererReader.java,
+	  src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java:
+	  Create one renderer element in the dom for each mapserver class with its
+	  attributes and expression.
+
+	* src/java/de/intevation/mxd/writer/MapScriptWriter.java: Write the
+	  expression for the mapserver class.
+
 2011-04-15  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/java/de/intevation/mxd/ArcGISInitializer.java,
--- a/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java	Fri Apr 15 15:44:54 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java	Mon Apr 18 14:50:49 2011 +0200
@@ -6,6 +6,7 @@
 
 import com.esri.arcgis.carto.IFeatureRenderer;
 import com.esri.arcgis.carto.ClassBreaksRenderer;
+import com.esri.arcgis.display.ISymbol;
 
 import org.w3c.dom.Element;
 
@@ -68,31 +69,39 @@
     public Element read()
     throws IOException {
         logger.debug("read()");
-        Element rendererElement;
-        try {
-            rendererElement = util.addRenderer(layer);
-        }
-        catch(Exception e) {
-            e.printStackTrace();
-            return null;
-        }
 
-        rendererElement.setAttribute("class_count",
-                String.valueOf(renderer.getClassCount()));
-        for(int i = 0; i < renderer.getClassCount(); i++){
-            rendererElement.setAttribute("class_" + i,
-                renderer.esri_getClass(i));
-        }
+        for(int i = 0; i < renderer.getBreakCount(); i++){
+            Element rendererElement;
+            try {
+                rendererElement = util.addRenderer(layer);
+                rendererElement.setAttribute("break",
+                    String.valueOf(renderer.getBreak(i)));
+                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("break_count",
-            String.valueOf(renderer.getBreakCount()));
-        for(int i = 0; i < renderer.getBreakCount(); i++){
-            rendererElement.setAttribute("break_" + i,
-                String.valueOf(renderer.getBreak(i)));
+                }
+                rendererElement.setAttribute(
+                    "min_value",
+                    String.valueOf(renderer.getMinimumBreak()));
+                rendererElement.setAttribute("expression_operator", "<=");
+                ISymbol sym = renderer.getSymbol(i);
+                ISymbolReader symReader;
+                symReader = new SimpleFillSymbolReader(renderer.getSymbol(i));
+                symReader.setUtil(util);
+                symReader.setParent(rendererElement);
+                symReader.read();
+            }
+            catch(Exception e) {
+                e.printStackTrace();
+                return null;
+            }
         }
-
-        rendererElement.setAttribute("color_ramp", renderer.getColorRamp());
-        return rendererElement;
+        return layer;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Fri Apr 15 15:44:54 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Mon Apr 18 14:50:49 2011 +0200
@@ -77,16 +77,10 @@
         Element rendererElement;
         try {
             rendererElement = util.addRenderer(layer);
-        }
-        catch(Exception e) {
-            e.printStackTrace();
-            return null;
-        }
 
-        rendererElement.setAttribute("label", renderer.getLabel());
-        rendererElement.setAttribute("description", renderer.getDescription());
-        symbol = renderer.getSymbol();
-        try {
+            rendererElement.setAttribute("label", renderer.getLabel());
+            rendererElement.setAttribute("description", renderer.getDescription());
+            symbol = renderer.getSymbol();
             if(symbol instanceof SimpleMarkerSymbol){
                 ISymbolReader isr= new SimpleMarkerSymbolReader(symbol);
                 isr.setParent(rendererElement);
@@ -99,12 +93,12 @@
                 isr.setUtil(util);
                 isr.read();
             }
-            return rendererElement;
+            return layer;
         }
         catch(Exception e) {
             e.printStackTrace();
+            return null;
         }
-        return rendererElement;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Fri Apr 15 15:44:54 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Mon Apr 18 14:50:49 2011 +0200
@@ -75,31 +75,32 @@
             Element rendererElement;
             try {
                 rendererElement = util.addRenderer(layer);
+
+                String value = renderer.getValue(i);
+                rendererElement.setAttribute("name", renderer.esri_getClass(i));
+                rendererElement.setAttribute("description",
+                renderer.getDescription(value));
+                rendererElement.setAttribute("value", 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 symbol = renderer.getSymbol(value);
+                ISymbolReader symbolReader = new SimpleMarkerSymbolReader(symbol);
+                symbolReader.setUtil(util);
+                symbolReader.setParent(rendererElement);
+                symbolReader.read ();
             }
             catch(Exception e) {
                 e.printStackTrace();
                 return null;
             }
-            String value = renderer.getValue(i);
-            rendererElement.setAttribute("name", renderer.esri_getClass(i));
-            rendererElement.setAttribute("description",
-                renderer.getDescription(value));
-            rendererElement.setAttribute("value", value);
-            rendererElement.setAttribute("label", renderer.getLabel(value));
-
-            ISymbol symbol = renderer.getSymbol(value);
-            ISymbolReader symbolReader;
-            try {
-                 symbolReader = new SimpleMarkerSymbolReader(symbol);
-            }
-            catch(Exception e) {
-                e.printStackTrace();
-                return null;
-            }
-            symbolReader.setUtil(util);
-            symbolReader.setParent(rendererElement);
-            symbolReader.read ();
-
         }
         return layer;
     }
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Fri Apr 15 15:44:54 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Mon Apr 18 14:50:49 2011 +0200
@@ -208,6 +208,17 @@
             Element classElement = (Element)list.item(i);
             classObj co = new classObj(layer);
             co.setName(classElement.getAttribute("name"));
+            if(classElement.hasAttribute("field_count")) {
+                int count =
+                    Integer.parseInt(classElement.getAttribute("field_count"));
+                String exp = "";
+                for(int j = 0; j < count; j++) {
+                    //TODO Find a way to create Expressions.
+                    exp = "([" + classElement.getAttribute("expression_field_" + j);
+                    exp += "] = " + classElement.getAttribute("value") + ")";
+                }
+                co.setExpression(exp);
+            }
             //Write symbols and styles.
             writeSymbol(co, classElement);
         }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)