diff src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 136:7632850b9520

Convert cartographic line template to mapfile pattern.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 23 Jun 2011 13:27:30 +0200
parents cd18c61cbcf6
children 8f30f7e802d6
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Wed Jun 22 13:55:22 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Thu Jun 23 13:27:30 2011 +0200
@@ -97,6 +97,45 @@
                 style.setPattern(vals);
             }
         }
+        else if(symbolElement.hasAttribute("pattern_count")) {
+            int count = 0;
+            try {
+                count = Integer.parseInt(
+                            symbolElement.getAttribute("pattern_count"));
+                double[] vals = new double[10];
+                double move = 0.0;
+                int pos = 0;
+                for(int i = 0; i < count; i++) {
+                    double mark =
+                        Double.parseDouble(symbolElement.getAttribute("mark_" + i));
+                    double gap =
+                        Double.parseDouble(symbolElement.getAttribute("gap_" + i));
+                    if(i == 0 && mark == 0.0) {
+                        move = gap;
+                    }
+                    else if(i == count - 1 && move > 0.0) {
+                       vals[pos++] = mark;
+                       vals[pos++] = gap + move;
+                    }
+                    else {
+                        vals[pos++] = mark;
+                        vals[pos++] = gap;
+                    }
+                }
+                if(move > 0.0) {
+                    style.setPatternlength((count*2) -2);
+                }
+                else {
+                    style.setPatternlength(count*2);
+                }
+                style.setPattern(vals);
+
+            }
+            catch(NumberFormatException nfe) {
+                logger.warn("Could not write PATTERN.");
+            }
+        }
+
         String type = symbolElement.getAttribute("type");
 
         if(type.equals("marker")) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)