[MXD2map-commits] r298:1cbc278c956b
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 5 16:19:23 CEST 2012
details: http://hg.intevation.org/geospatial/mxd2map/rev/1cbc278c956b
changeset: 298:1cbc278c956b
user: Andre Heinecke <aheinecke at intevation.de>
date: Tue Sep 04 17:49:17 2012 +0200
description:
Whitespace Only: unify to 4 Space indention.
So that i can avoid whitespace problems while working on this
file.
diffstat:
src/java/de/intevation/mxd/writer/MapScriptWriter.java | 280 ++++++++--------
1 files changed, 140 insertions(+), 140 deletions(-)
diffs (433 lines):
diff -r ad05f72ef9e4 -r 1cbc278c956b src/java/de/intevation/mxd/writer/MapScriptWriter.java
--- 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();
More information about the MXD2map-commits
mailing list