Mercurial > mxd2map
changeset 194:216105271856
Merged with Stephans commits.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 16:27:49 +0200 |
parents | 8ced5ff9113d (diff) 43f1cbdcd597 (current diff) |
children | 123ebb293f3a 5350621a0294 |
files | ChangeLog |
diffstat | 5 files changed, 107 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jul 20 15:53:01 2011 +0200 +++ b/ChangeLog Wed Jul 20 16:27:49 2011 +0200 @@ -24,6 +24,35 @@ 2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + * build.xml: + Added target "jar-norevision" to create a jar file without the + revision hash. + +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/writer/SymbolWriter.java: + Lookup symbol font in fontset and print out a warning if the font is + missing. + +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/writer/MarkerStyleWriter.java: + Added offset attributes to marker style symbols. + +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/writer/MapScriptWriter.java: + Do not write layer with empty CLASS objects. + +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/writer/MapScriptWriter.java: + Added string manipulator that replaces german umlauts and trims a + string. + Use this validator for mapserver relevant names and strings. + +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + * src/java/de/intevation/mxd/reader/MapScriptWriter.java: Add quotes to expression if the value is a string.
--- a/build.xml Wed Jul 20 15:53:01 2011 +0200 +++ b/build.xml Wed Jul 20 16:27:49 2011 +0200 @@ -32,7 +32,7 @@ </exec> </target> - <target name="init" depends="revision"> + <target name="init"> <!-- create the time stamp --> <tstamp/> <!-- create the build directory structure used by compile --> @@ -59,7 +59,7 @@ </copy> </target> - <target name="jar" depends="compile"> + <target name="jar" depends="compile,revision"> <mkdir dir="${dist.dir}" /> <jar jarfile="${dist.dir}/mxd2map-${hash}.jar" compress="true" basedir="${class.dir}"> <manifest> @@ -69,6 +69,16 @@ </jar> </target> + <target name="jar-norevision" depends="compile"> + <mkdir dir="${dist.dir}" /> + <jar jarfile="${dist.dir}/mxd2map.jar" compress="true" basedir="${class.dir}"> + <manifest> + <attribute name="Main-Class" value="de.intevation.mxd.Converter"/> + <attribute name="Class-Path" value="lib/log4j-1.2.16.jar lib/mapscript.jar lib/jargs.jar"/> + </manifest> + </jar> + </target> + <target name="usage"> <echo message="Execute 'ant -projecthelp' for the build file help"/> <echo message="Execute 'ant -help' for Ant help"/>
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Jul 20 15:53:01 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Jul 20 16:27:49 2011 +0200 @@ -190,15 +190,20 @@ for(int i = 0; i < list.getLength(); i++) { Element layerElement = (Element)list.item(i); layerObj layer = new layerObj(map); + NodeList renderer = layerElement.getElementsByTagName("renderer"); + if (renderer.getLength() == 0) { + continue; + } //The layer name. String lname = layerElement.getAttribute("name"); lname = lname.replaceAll(" ", ""); - layer.setName(lname); + layer.setName(validateString(lname)); layer.setUnits(units.swigValue()); - layer.setMetaData("wms_title", layerElement.getAttribute("name")); + layer.setMetaData("wms_title", validateString(lname)); if(layerElement.hasAttribute("group")) { - layer.setGroup(layerElement.getAttribute("group")); + String group = layerElement.getAttribute("group"); + layer.setGroup(validateString(group)); } //The layer status. @@ -332,8 +337,10 @@ Element classElement = (Element)list.item(i); classObj co = new classObj(layer); String name = classElement.getAttribute("label"); + name = validateString(name); if (name.equals("")) { name = layerElement.getAttribute("name"); + name = validateString(name); if (list.getLength() > 1) { name += "-" + i; } @@ -558,4 +565,21 @@ } return expression; } + + /** + * Replaces german umlauts and removes leading and trailing whitespaces. + * + * @param s String + */ + private String validateString (String s) { + if (s.equals("")) { + return ""; + } + String tmp = s.trim(); + tmp = tmp.replace ("ö", "oe"); + tmp = tmp.replace ("ä", "ae"); + tmp = tmp.replace ("ü", "ue"); + tmp = tmp.replace ("ß", "ss"); + return tmp; + } }
--- a/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java Wed Jul 20 15:53:01 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MarkerStyleWriter.java Wed Jul 20 16:27:49 2011 +0200 @@ -100,6 +100,32 @@ logger.warn("Error setting outline width."); } } + + if (symbolElement.hasAttribute("x_offset")) { + try { + double val = + Double.parseDouble(symbolElement.getAttribute("x_offset")); + double r = Math.round(val); + style.setOffsetx(r); + } + catch (NumberFormatException nfe) { + logger.warn("Error setting the symbol x-offset"); + } + } + if (symbolElement.hasAttribute("y_offset")) { + try { + double val = + Double.parseDouble(symbolElement.getAttribute("y_offset")); + double r = Math.round(val); + //In ArcGIS positive y offset values move the symbol upwards, + //in Mapserver positive values move downwards. + r = -r; + style.setOffsety(r); + } + catch (NumberFormatException nfe) { + logger.warn("Error setting the symbol y-offset."); + } + } String symType = symbolElement.getAttribute("style"); if(symType.equals("point") || symType.equals("arrow") ||
--- a/src/java/de/intevation/mxd/writer/SymbolWriter.java Wed Jul 20 15:53:01 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/SymbolWriter.java Wed Jul 20 16:27:49 2011 +0200 @@ -11,6 +11,8 @@ import edu.umn.gis.mapscript.symbolSetObj; import edu.umn.gis.mapscript.lineObj; import edu.umn.gis.mapscript.pointObj; +import edu.umn.gis.mapscript.fontSetObj; +import edu.umn.gis.mapscript.hashTableObj; import edu.umn.gis.mapscript.MS_SYMBOL_TYPE; import java.io.File; @@ -154,6 +156,17 @@ String font = symbolElement.getAttribute("font"); //Remove all blank character to match the mapserver fonts.txt. font = font.replaceAll(" ", ""); + fontSetObj fso = this.map.getFontset(); + hashTableObj fonts = fso.getFonts(); + String mapFont = fonts.get(font,""); + if (mapFont == null || mapFont.equals("")) { + logger.warn( + "Could not find font " + font + " in font set. " + + "Setting FreeSans as symbol font." + + "Please add " + font + " to fonts.txt and replace the alias " + + "in symbol \"" + symbolElement.getAttribute("name") + "\"."); + font = "FreeSans"; + } symbol.setName(symbolElement.getAttribute("name")); symbol.setFont(font); symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());