Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 137:cd55975ba0c4
Done some minor reformatings.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 23 Jun 2011 16:59:29 +0200 |
parents | acc9e5430177 |
children | 8f30f7e802d6 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Thu Jun 23 13:27:30 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Thu Jun 23 16:59:29 2011 +0200 @@ -148,8 +148,8 @@ layerObj layer = new layerObj(map); //The layer name. - String lname = layerElement.getAttribute("name"); - lname = lname.replaceAll(" ", ""); + String lname = layerElement.getAttribute("name"); + lname = lname.replaceAll(" ", ""); layer.setName(lname); layer.setMetaData("wms_title", layerElement.getAttribute("name")); @@ -184,7 +184,7 @@ layer.setTileitem(""); //The layer datasource. - String con_type = layerElement.getAttribute("connection_type"); + String con_type = layerElement.getAttribute("connection_type"); if(con_type.equals("local")) { String datasource = ""; if(layerElement.hasAttribute("workspace")) { @@ -193,29 +193,29 @@ } datasource += layerElement.getAttribute("data_source"); layer.setData(datasource); - } - else if(con_type.equals("SDE")) { - logger.info( - "SDE datasource found." + - " Please edit password in mapfile."); - layer.setConnectionType( - MS_CONNECTION_TYPE.MS_PLUGIN.swigValue(), - MS_BINDIR + "/ms/plugins/msplugin_sde_93.dll"); + } + else if(con_type.equals("SDE")) { + logger.info( + "SDE datasource found." + + " Please edit password in mapfile."); + layer.setConnectionType( + MS_CONNECTION_TYPE.MS_PLUGIN.swigValue(), + MS_BINDIR + "/ms/plugins/msplugin_sde_93.dll"); layer.setConnection( - layerElement.getAttribute("server") + "," + - "port:" + layerElement.getAttribute("instance") + "," + - layerElement.getAttribute("database") + "," + - layerElement.getAttribute("user") + ",<PASSWORD>"); - layer.setData( - layerElement.getAttribute("data_source") + - ",SHAPE," + - layerElement.getAttribute("version")); - layer.setProcessing("CLOSE_CONNECTION=defer"); + layerElement.getAttribute("server") + "," + + "port:" + layerElement.getAttribute("instance") + "," + + layerElement.getAttribute("database") + "," + + layerElement.getAttribute("user") + ",<PASSWORD>"); + layer.setData( + layerElement.getAttribute("data_source") + + ",SHAPE," + + layerElement.getAttribute("version")); + layer.setProcessing("CLOSE_CONNECTION=defer"); layer.setProcessing("ATTRIBUTE_QUALIFIED=TRUE"); - if(layerElement.hasAttribute("join_table")) { + if(layerElement.hasAttribute("join_table")) { layer.setProcessing( - "JOINTABLE=" + - layerElement.getAttribute("join_table")); + "JOINTABLE=" + + layerElement.getAttribute("join_table")); layer.setFilter( "where " + layerElement.getAttribute("definition_query") + @@ -224,11 +224,11 @@ layerElement.getAttribute("join_field_target") + "=" + layerElement.getAttribute("join_table") + "." + layerElement.getAttribute("join_field")); - } - else { - prefix = layerElement.getAttribute("data_source"); - } - } + } + else { + prefix = layerElement.getAttribute("data_source"); + } + } layer.setTemplate("PleaseInsertAValidTemplateForGFI"); //Write classes. writeClass(layer, layerElement); @@ -261,7 +261,7 @@ } co.setName (name); if(classElement.hasAttribute("field_count")) { - co.setExpression(createExpression(classElement)); + co.setExpression(createExpression(classElement)); } //Write symbols and styles. NodeList l = classElement.getChildNodes(); @@ -287,48 +287,48 @@ private String createExpression(Element ce) { - String expression = "("; - int count = 0; - try { - count = Integer.parseInt(ce.getAttribute("field_count")); - } - catch(NumberFormatException nfe) { - return ""; - } - if(count == 1) { + String expression = "("; + int count = 0; + try { + count = Integer.parseInt(ce.getAttribute("field_count")); + } + catch(NumberFormatException nfe) { + return ""; + } + if(count == 1) { try { Double.parseDouble(ce.getAttribute("value")); - String exp = ce.getAttribute("expression_field_0"); - String pre = ""; - if (!prefix.equals("") && !exp.startsWith(prefix)) { + String exp = ce.getAttribute("expression_field_0"); + String pre = ""; + if (!prefix.equals("") && !exp.startsWith(prefix)) { pre = prefix + "."; - } - expression += "[" + pre; - expression += ce.getAttribute("expression_field_0") + "]"; - if(ce.hasAttribute("min_value")) { + } + expression += "[" + pre; + expression += ce.getAttribute("expression_field_0") + "]"; + if(ce.hasAttribute("min_value")) { expression += " > " + ce.getAttribute("min_value"); - expression += " AND ["; - expression += ce.getAttribute("expression_field_0")+ "]"; - } - expression += " " + ce.getAttribute("expression_operator"); - expression += " " + ce.getAttribute("value") + ")"; - } - catch(NumberFormatException nfe) { - String exp = ce.getAttribute("expression_field_0"); - String pre = ""; - if (!prefix.equals("") && !exp.startsWith(prefix)) { + expression += " AND ["; + expression += ce.getAttribute("expression_field_0")+ "]"; + } + expression += " " + ce.getAttribute("expression_operator"); + expression += " " + ce.getAttribute("value") + ")"; + } + catch(NumberFormatException nfe) { + String exp = ce.getAttribute("expression_field_0"); + String pre = ""; + if (!prefix.equals("") && !exp.startsWith(prefix)) { pre = prefix + "."; - } - expression += "\"[" + pre; - expression += ce.getAttribute("expression_field_0") + "]\""; - expression += " " + ce.getAttribute("expression_operator"); - expression += " \"" + ce.getAttribute("value") + "\")"; - } - catch(Exception e) { - e.printStackTrace(); - } - } - else { + } + expression += "\"[" + pre; + expression += ce.getAttribute("expression_field_0") + "]\""; + expression += " " + ce.getAttribute("expression_operator"); + expression += " \"" + ce.getAttribute("value") + "\")"; + } + catch(Exception e) { + e.printStackTrace(); + } + } + else { for (int i = 0; i < count; i++) { try { Double.parseDouble(ce.getAttribute("value_" + i)); @@ -341,15 +341,15 @@ expression += ce.getAttribute("expression_field_" + i) + "]"; expression += " " + ce.getAttribute("expression_operator"); expression += " " + ce.getAttribute("value_" + i); - if (i < count - 1) { - expression += " AND "; - } - else { - expression += ")"; - } - } - catch (NumberFormatException nfe) { - String exp = ce.getAttribute("expression_field_" + i); + if (i < count - 1) { + expression += " AND "; + } + else { + expression += ")"; + } + } + catch (NumberFormatException nfe) { + String exp = ce.getAttribute("expression_field_" + i); String pre = ""; if (!prefix.equals("") && !exp.startsWith(prefix)) { pre = prefix + "."; @@ -358,97 +358,16 @@ expression += ce.getAttribute("expression_field_" + i) + "]\""; expression += " " + ce.getAttribute("expression_operator"); expression += " " + ce.getAttribute("value_" + i); - if (i < count - 1) { - expression += " AND "; - } - else { - expression += ")"; - } - } - } - } - return expression; - } - - - - - - - - - - - - - - - - - - - - - - - private String createDoubleExpression (Element classElement, int count) { - String exp = ""; - String op = classElement.getAttribute("expression_operator"); - String op1 = ""; - String op2 = ""; - if (op.equals("<=")) { - op1 = ">="; - op2 = op; - for(int j = 0; j < count; j++) { - if (classElement.getAttribute("min_value").equals( - classElement.getAttribute("value"))) { - exp = "([" + - classElement.getAttribute( - "expression_field_" + j) + - "] == " + - classElement.getAttribute("value") + - ")"; - } - else { - exp = "(["; - exp += classElement.getAttribute( - "expression_field_" + j); - exp += "] " + op1; - exp += " " + classElement.getAttribute("min_value"); - exp += " AND [" + classElement.getAttribute( - "expression_field_" + j); - exp += "] " + op2 + " "; - exp += classElement.getAttribute("value"); - exp += ")"; + if (i < count - 1) { + expression += " AND "; + } + else { + expression += ")"; + } } } } - else if (op.equals("=")) { - op1 = op; - for(int j = 0; j < count; j++) { - exp = "([" + - classElement.getAttribute("expression_field_" + j) + - "] == " + - classElement.getAttribute("value") + ")"; - } - } - return exp; - } - - private String createStringExpression (Element classElement, int count) { - String exp = ""; - String op = classElement.getAttribute("expression_operator"); - if (op.equals("=")) { - for(int j = 0; j < count; j++) { - exp = "(\"["; - exp += classElement.getAttribute( - "expression_field_" + j); - exp += "]\" " + op; - exp += " \"" + classElement.getAttribute("value"); - exp += "\")"; - } - } - return exp; + return expression; } }