Mercurial > mxd2map
changeset 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 | a4ab239509f1 |
children | cd55975ba0c4 |
files | ChangeLog src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java src/java/de/intevation/mxd/writer/LineStyleWriter.java |
diffstat | 3 files changed, 67 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jun 22 13:55:22 2011 +0200 +++ b/ChangeLog Thu Jun 23 13:27:30 2011 +0200 @@ -1,3 +1,11 @@ +2011-06-22 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java: + Read mark and gap values from cartographic line template. + + * src/java/de/intevation/mxd/writer/LineStyleWriter.java: + Create and write pattern from mark and gap values. + 2011-06-22 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/reader/ArrowMarkerSymbolReader.java,
--- a/src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java Wed Jun 22 13:55:22 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java Thu Jun 23 13:27:30 2011 +0200 @@ -9,6 +9,7 @@ import com.esri.arcgis.display.CartographicLineSymbol; import com.esri.arcgis.display.IRgbColor; import com.esri.arcgis.display.RgbColor; +import com.esri.arcgis.display.Template; import com.esri.arcgis.display.esriLineCapStyle; import com.esri.arcgis.display.esriLineJoinStyle; @@ -175,6 +176,25 @@ } //TODO Read further attributes depending on the Mapscript functionality: // Template, MarkerSymbol, LineDecorations + + try { + Template temp = (Template)symbol.getTemplate(); + double length = temp.getInterval(); + int count = temp.getPatternElementCount(); + symbolElement.setAttribute("pattern_count", String.valueOf(count)); + for (int j = 0; j < count; j++) { + double[] mark = new double[1]; + double[] gap = new double[1]; + temp.getPatternElement(j, mark, gap); + symbolElement.setAttribute( + "mark_" + j, + String.valueOf(mark[0])); + symbolElement.setAttribute("gap_" + j, String.valueOf(gap[0])); + } + } + catch(IOException ioe){ + logger.warn("Could not read pattern elements."); + } symbolElement.setAttribute("type", "line"); symbolElement.setAttribute("style", "carto");
--- 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")) {