Mercurial > mxd2map
changeset 298:1cbc278c956b
Whitespace Only: unify to 4 Space indention.
So that i can avoid whitespace problems while working on this
file.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 04 Sep 2012 17:49:17 +0200 (2012-09-04) |
parents | ad05f72ef9e4 |
children | c4fb04f6422f |
files | src/java/de/intevation/mxd/writer/MapScriptWriter.java |
diffstat | 1 files changed, 140 insertions(+), 140 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Mon Sep 03 17:26:02 2012 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Tue Sep 04 17:49:17 2012 +0200 @@ -79,7 +79,7 @@ */ public MapScriptWriter() { map = new mapObj(""); - msutils = new MapScriptUtils(); + msutils = new MapScriptUtils(); mapFilename = ""; } @@ -94,7 +94,7 @@ public MapScriptWriter(String templ, String filename) { String path = System.getProperty("user.dir"); map = new mapObj(templ); - msutils = new MapScriptUtils(); + msutils = new MapScriptUtils(); File f = new File(filename); mapFilename = filename; if(f.isAbsolute()) { @@ -134,15 +134,15 @@ //Write the map attributes. writeMap(); //Write the layers. - boolean ret = writeLayer(); + boolean ret = writeLayer(); //Save the map. - if (ret) { + if (ret) { mapObj cloneMap = map.cloneMap(); cloneMap.save(mapFilename); logger.info("Mapfile created: " + mapFilename); return true; - } - return false; + } + return false; } /** @@ -168,14 +168,14 @@ Double.parseDouble(mapNode.getAttribute("extent_max_x")), Double.parseDouble(mapNode.getAttribute("extent_max_y"))); - map.setMetaData( - "ows_extent", - mapNode.getAttribute("extent_min_x") + ", " + - mapNode.getAttribute("extent_min_y") + ", " + - mapNode.getAttribute("extent_max_x") + ", " + - mapNode.getAttribute("extent_max_y")); + map.setMetaData( + "ows_extent", + mapNode.getAttribute("extent_min_x") + ", " + + mapNode.getAttribute("extent_min_y") + ", " + + mapNode.getAttribute("extent_max_x") + ", " + + mapNode.getAttribute("extent_max_y")); - map.setSize(800, 600); + map.setSize(800, 600); //Set the units and projection. int proj = Integer.parseInt(mapNode.getAttribute("projection")); @@ -219,32 +219,32 @@ } map.setUnits(units); - String mproj = mapNode.getAttribute("projection"); - if(mproj != null && !mproj.equals("") && ! mproj.equals("0")) { - MapScriptUtils msu = new MapScriptUtils(); - String wmssrs = msu.getMetaData(map, "wms_srs"); - String owssrs = msu.getMetaData(map, "ows_srs"); - if(wmssrs.indexOf(mproj) < 0) { - if(wmssrs.equals("")) { - wmssrs = "EPSG:"; - } - else { - wmssrs += " EPSG:"; - } - wmssrs += mproj; - } - if(owssrs.indexOf(mproj) < 0) { - if(owssrs.equals("")) { - owssrs = "EPSG:"; - } - else { - owssrs += " EPSG:"; - } + String mproj = mapNode.getAttribute("projection"); + if(mproj != null && !mproj.equals("") && ! mproj.equals("0")) { + MapScriptUtils msu = new MapScriptUtils(); + String wmssrs = msu.getMetaData(map, "wms_srs"); + String owssrs = msu.getMetaData(map, "ows_srs"); + if(wmssrs.indexOf(mproj) < 0) { + if(wmssrs.equals("")) { + wmssrs = "EPSG:"; + } + else { + wmssrs += " EPSG:"; + } + wmssrs += mproj; + } + if(owssrs.indexOf(mproj) < 0) { + if(owssrs.equals("")) { + owssrs = "EPSG:"; + } + else { + owssrs += " EPSG:"; + } owssrs += mproj; - } + } map.setMetaData("ows_srs", owssrs); - map.setMetaData("wms_srs", wmssrs); - } + map.setMetaData("wms_srs", wmssrs); + } } /** @@ -261,78 +261,78 @@ Element layerElement = (Element)list.item(i); layerObj layer = new layerObj(map); NodeList renderer = layerElement.getElementsByTagName("renderer"); - if (renderer.getLength() == 0) { - map.removeLayer(layer.getIndex()); - logger.warn( - "Skipping empty layer " + - layerElement.getAttribute("name")); - continue; - } + if (renderer.getLength() == 0) { + map.removeLayer(layer.getIndex()); + logger.warn( + "Skipping empty layer " + + layerElement.getAttribute("name")); + continue; + } //The layer name. - String group = ""; + String group = ""; if(layerElement.hasAttribute("group")) { - group = layerElement.getAttribute("group"); - String[] splitted = group.split("/"); - String cleangroup = ""; - for(int j = 0; j < splitted.length; j++) { - if(!splitted[j].equals("")) { - splitted[j] = msutils.replaceUmlauts(splitted[j]); - cleangroup += "/" + - msutils.removeSpecialChars(splitted[j]); - } - } - group = cleangroup; + group = layerElement.getAttribute("group"); + String[] splitted = group.split("/"); + String cleangroup = ""; + for(int j = 0; j < splitted.length; j++) { + if(!splitted[j].equals("")) { + splitted[j] = msutils.replaceUmlauts(splitted[j]); + cleangroup += "/" + + msutils.removeSpecialChars(splitted[j]); + } + } + group = cleangroup; } - String lname = layerElement.getAttribute("name"); - lname = msutils.removeSpecialChars(lname); - lname = msutils.replaceUmlauts(lname); - String ulname = group.replaceAll("/", ".") + "." + lname; - if(ulname.startsWith(".")) { - ulname = ulname.substring(1); - } + String lname = layerElement.getAttribute("name"); + lname = msutils.removeSpecialChars(lname); + lname = msutils.replaceUmlauts(lname); + String ulname = group.replaceAll("/", ".") + "." + lname; + if(ulname.startsWith(".")) { + ulname = ulname.substring(1); + } layer.setName(ulname); layer.setUnits(units.swigValue()); - if(!group.equals("")) { + if(!group.equals("")) { layer.setMetaData("wms_layer_group", group); - } + } layer.setMetaData("wms_title", ulname); - // Projection metadata. - String mproj = mapNode.getAttribute("projection"); - if(mproj != null && !mproj.equals("") && !mproj.equals("0")) { - String wmssrs = layer.getMetaData("wms_srs"); - String owssrs = layer.getMetaData("ows_srs"); + // Projection metadata. + String mproj = mapNode.getAttribute("projection"); + if(mproj != null && !mproj.equals("") && !mproj.equals("0")) { + String wmssrs = layer.getMetaData("wms_srs"); + String owssrs = layer.getMetaData("ows_srs"); if(wmssrs == null) { - wmssrs = "EPSG:"; - } - else { - wmssrs += " EPSG:"; - } - if(owssrs == null) { - owssrs = "EPSG:"; - } - else { - owssrs += " EPSG:"; - } - wmssrs += mproj; - owssrs += mproj; - layer.setMetaData("wms_srs", wmssrs); - layer.setMetaData("ows_srs", owssrs); - } + wmssrs = "EPSG:"; + } + else { + wmssrs += " EPSG:"; + } + if(owssrs == null) { + owssrs = "EPSG:"; + } + else { + owssrs += " EPSG:"; + } + wmssrs += mproj; + owssrs += mproj; + layer.setMetaData("wms_srs", wmssrs); + layer.setMetaData("ows_srs", owssrs); + } - // The layer extent metadata. - if(layerElement.hasAttribute("extent_min_x") && - layerElement.hasAttribute("extent_max_x") && - layerElement.hasAttribute("extent_min_y") && - layerElement.hasAttribute("extent_max_y")) { - layer.setMetaData( - "ows_extent", - layerElement.getAttribute("extent_min_x") + ", " + - layerElement.getAttribute("extent_min_y") + ", " + - layerElement.getAttribute("extent_max_x") + ", " + - layerElement.getAttribute("extent_max_y")); - } + // The layer extent metadata. + if(layerElement.hasAttribute("extent_min_x") && + layerElement.hasAttribute("extent_max_x") && + layerElement.hasAttribute("extent_min_y") && + layerElement.hasAttribute("extent_max_y")) { + layer.setMetaData( + "ows_extent", + layerElement.getAttribute("extent_min_x") + ", " + + layerElement.getAttribute("extent_min_y") + ", " + + layerElement.getAttribute("extent_max_x") + ", " + + layerElement.getAttribute("extent_max_y")); + } //The layer status. String stat = layerElement.getAttribute("status"); if (stat.equals("on")) { @@ -364,7 +364,7 @@ if(type.equals("point")) { layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT); layer.setTileitem(""); - } + } else if (type.equals("line")) { layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE); layer.setTileitem(""); @@ -373,9 +373,9 @@ layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON); layer.setTileitem(""); } - else if(type.equals("raster")) { - layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER); - } + else if(type.equals("raster")) { + layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER); + } //The layer datasource. String con_type = layerElement.getAttribute("connection_type"); @@ -398,25 +398,25 @@ layer.setConnectionType( MS_CONNECTION_TYPE.MS_PLUGIN.swigValue(), MS_BINDIR + "/ms/plugins/msplugin_sde_93.dll"); - String database_auth = layerElement.getAttribute("database"); - if (database_auth.equals("") || database_auth == null) { - logger.warn("Could not set the database connection user." + - " Setting to \"sde\" as default."); - database_auth = "sde"; - } + String database_auth = layerElement.getAttribute("database"); + if (database_auth.equals("") || database_auth == null) { + logger.warn("Could not set the database connection user." + + " Setting to \"sde\" as default."); + database_auth = "sde"; + } - String port = layerElement.getAttribute("instance"); + String port = layerElement.getAttribute("instance"); StringBuffer strBuff = new StringBuffer(); char c; - + for (int j = 0; j < port.length() ; j++) { c = port.charAt(j); - + if(Character.isDigit(c)) { strBuff.append(c); } } - + layer.setConnection( layerElement.getAttribute("server") + "," + "port:" + strBuff.toString() + "," + @@ -429,13 +429,13 @@ layer.setProcessing("CLOSE_CONNECTION=defer"); layer.setProcessing("ATTRIBUTE_QUALIFIED=TRUE"); if(layerElement.hasAttribute("join_table")) { - logger.info( - "The layer " + - layer.getName() + - " contains a jointable attribute." + - " Please verify the attribute parameters."); - String join = layerElement.getAttribute("join_table"); - + logger.info( + "The layer " + + layer.getName() + + " contains a jointable attribute." + + " Please verify the attribute parameters."); + String join = layerElement.getAttribute("join_table"); + layer.setProcessing( "JOINTABLE=" + layerElement.getAttribute("join_table")); @@ -458,45 +458,45 @@ } } } - else if(con_type.equals("SDE") && type.equals("raster")) { + else if(con_type.equals("SDE") && type.equals("raster")) { // The data source is a sde database. logger.info( "SDE datasource found." + " Please edit password in mapfile."); - String database_auth = layerElement.getAttribute("database"); - if (database_auth.equals("") || database_auth == null) { - logger.warn("Could not set the database connection user." + - " Setting to \"sde\" as default."); - database_auth = "sde"; - } + String database_auth = layerElement.getAttribute("database"); + if (database_auth.equals("") || database_auth == null) { + logger.warn("Could not set the database connection user." + + " Setting to \"sde\" as default."); + database_auth = "sde"; + } - String port = layerElement.getAttribute("instance"); + String port = layerElement.getAttribute("instance"); StringBuffer strBuff = new StringBuffer(); char c; - + for (int j = 0; j < port.length() ; j++) { c = port.charAt(j); if(Character.isDigit(c)) { strBuff.append(c); } } - + layer.setData( "SDE:" + layerElement.getAttribute("server") + "," + strBuff + - "," + layerElement.getAttribute("database") + - "," + layerElement.getAttribute("user") + - ",<PASSWORD>," + layerElement.getAttribute("dataset")); - layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER); + "," + layerElement.getAttribute("database") + + "," + layerElement.getAttribute("user") + + ",<PASSWORD>," + layerElement.getAttribute("dataset")); + layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER); if(layerElement.hasAttribute("definition_query") && !layerElement.getAttribute("definition_query").equals("")) { layer.setFilter("where " + layerElement.getAttribute("definition_query")); } - } - if(!type.equals("raster")) { + } + if(!type.equals("raster")) { layer.setTemplate("PleaseInsertAValidTemplateForGFI"); - } + } // Create labelitem NodeList labels = layerElement.getElementsByTagName("label"); @@ -514,7 +514,7 @@ //Write classes. writeClass(layer, layerElement); } - return true; + return true; } /** @@ -534,10 +534,10 @@ Element classElement = (Element)list.item(i); classObj co = new classObj(layer); String name = classElement.getAttribute("label"); - name = msutils.replaceUmlauts(name); + name = msutils.replaceUmlauts(name); if (name.equals("")) { name = layerElement.getAttribute("name"); - name = msutils.replaceUmlauts(name); + name = msutils.replaceUmlauts(name); if (list.getLength() > 1) { name += "-" + i; } @@ -709,7 +709,7 @@ expression += "\"[" + pre; expression += ce.getAttribute("expression_field_0") + "]\""; expression += " " + ce.getAttribute("expression_operator"); - expression += " \"" + ce.getAttribute("value") + "\")"; + expression += " \"" + ce.getAttribute("value") + "\")"; } catch(Exception e) { e.printStackTrace();