changeset 142:f98d2759e494

Merged with Stephans commits.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 27 Jun 2011 16:23:51 +0200
parents 0ebaec057f15 (current diff) 8f30f7e802d6 (diff)
children ad3f540fd1c3
files ChangeLog
diffstat 5 files changed, 76 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 24 10:29:44 2011 +0200
+++ b/ChangeLog	Mon Jun 27 16:23:51 2011 +0200
@@ -1,3 +1,16 @@
+2011-06-27  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/writer/MapScriptWriter.java:
+	  Write symbol styles in reverse order to the mapfile.
+
+	* src/java/de/intevation/mxd/writer/LineStyleWriter.java,
+	  src/java/de/intevation/mxd/writer/MarkerStyleWriter.java:
+	  Create the symbol first, then set symbolname for style.
+
+	* src/java/de/intevation/mxd/writer/SymbolWriter.java:
+	  Test if symbol exists. If not exists, write new symbol with new
+	  name.
+
 2011-06-24  Stephan Holl  <stephan.holl@intevation.de>
 
 	* INSTALL.txt: added a hint how to install the converter and its
@@ -9,6 +22,7 @@
 
 2011-06-24  Stephan Holl  <stephan.holl@intevation.de>
 
+
 	* doku/Makefile, doku/source/conf.py, doku/source/index.rst,
 	doku/source/restrictions.rst: New. added stub for creating a
 	documentation.
--- a/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Fri Jun 24 10:29:44 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Mon Jun 27 16:23:51 2011 +0200
@@ -69,7 +69,13 @@
             style.setSize((int)Double.parseDouble(
                 symbolElement.getAttribute("size")));
         }
+        String type = symbolElement.getAttribute("type");
+        if(type.equals("marker")) {
+            SymbolWriter sw = new SymbolWriter(this.map, this.cl);
+            sw.write(symbolElement);
+        }
         String name = symbolElement.getAttribute("name");
+        style.setSymbolByName(map, name);
         symbolObj sym = symbolSet.getSymbolByName(name);
 
         //The following lines are for dashed and/or dotted lines.
@@ -136,13 +142,9 @@
             }
         }
 
-        String type = symbolElement.getAttribute("type");
 
-        if(type.equals("marker")) {
-            style.setSymbolByName(map, name);
-            SymbolWriter sw = new SymbolWriter(this.map, this.cl);
-            sw.write(symbolElement);
-        }
+
+
         return false;
     }
 }
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Fri Jun 24 10:29:44 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Mon Jun 27 16:23:51 2011 +0200
@@ -265,7 +265,7 @@
             }
             //Write symbols and styles.
             NodeList l = classElement.getChildNodes();
-            for (int j = 0; j < l.getLength(); j++) {
+            for (int j = l.getLength() - 1; j >= 0; j--) {
                 Element elem = (Element)l.item(j);
 
                 String type = layerElement.getAttribute("type");
--- a/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java	Fri Jun 24 10:29:44 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java	Mon Jun 27 16:23:51 2011 +0200
@@ -72,10 +72,6 @@
             style.setOutlinewidth(Double.parseDouble(
                 symbolElement.getAttribute("outline_size")));
         }
-
-        String name = symbolElement.getAttribute("name");
-        style.setSymbolByName(map, name);
-
         String symType = symbolElement.getAttribute("style");
         if(symType.equals("point") ||
            symType.equals("arrow") ||
@@ -86,6 +82,10 @@
         else {
             return false;
         }
+        String name = symbolElement.getAttribute("name");
+        style.setSymbolByName(map, name);
+
+
         return true;
     }
 }
--- a/src/java/de/intevation/mxd/writer/SymbolWriter.java	Fri Jun 24 10:29:44 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/SymbolWriter.java	Mon Jun 27 16:23:51 2011 +0200
@@ -54,8 +54,19 @@
             writeArrow(sym, symbolElement);
         }
         else if (symType.equals("char")) {
-            //TODO Does not work at all...  waiting for fix.
-            writeCharacter(sym, symbolElement);
+            int exists = symbolExists(symbolElement);
+            if(exists == -1) {
+                String old = symbolElement.getAttribute("name");
+                symbolElement.setAttribute(
+                    "name",
+                    old + symbolSet.getNumsymbols() + 1);
+                writeCharacter(sym, symbolElement);
+            }
+            else {
+                symbolElement.setAttribute(
+                    "name",
+                    symbolSet.getSymbol(exists).getName());
+            }
         }
         else if (type.equals("line")) {
             writeHatch(sym);
@@ -106,6 +117,7 @@
         String font = symbolElement.getAttribute("font");
         //Remove all blank character to match the mapserver fonts.txt.
         font = font.replaceAll(" ", "");
+        symbol.setName(symbolElement.getAttribute("name"));
         symbol.setFont(font);
         symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());
         symbol.setAntialias(1);
@@ -140,5 +152,40 @@
         }
         symbols.save(path);
     }
+
+    private int symbolExists (Element elem) {
+        symbolSetObj symbolSet = map.getSymbolset();
+        for (int i = 0; i < symbolSet.getNumsymbols(); i++) {
+            symbolObj sym = symbolSet.getSymbol(i);
+            int stype = sym.getType();
+            String etype = elem.getAttribute("style");
+            if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue () &&
+                etype.equals("point")) {
+                return i;   
+            }
+            else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue () &&
+                    etype.equals("arrow")) {
+                return i;        
+            }
+            else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue () &&
+                    etype.equals("char")) {
+                String font = elem.getAttribute("font");
+                font = font.replaceAll(" ", "");
+                String c = elem.getAttribute("char");
+                c = "&#" + c + ";";
+                if (font.equals(sym.getFont()) &&
+                    c.equals(sym.getCharacter())) {
+                    return i;
+                }
+
+            }
+            else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_HATCH.swigValue () &&
+                    etype.equals("hatch")) {
+                return i;        
+            }
+
+        }
+        return -1;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)