[MXD2map-commits] r311:c8b8f887ef80
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 14 11:54:12 CEST 2012
details: http://hg.intevation.org/geospatial/mxd2map/rev/c8b8f887ef80
changeset: 311:c8b8f887ef80
user: Andre Heinecke <aheinecke at intevation.de>
date: Fri Sep 14 11:54:03 2012 +0200
description:
Add write support for Fgdb layers and make it possible
to remove a prefix from the expressions. The expressions
returned by arcgis for Fgdb data contain the data source
name as a prefix. Mapserver does not need it and does not
match those expressions so they have to be removed
diffstat:
ChangeLog | 6 ++
src/java/de/intevation/mxd/writer/MapScriptWriter.java | 43 +++++++++++++----
2 files changed, 39 insertions(+), 10 deletions(-)
diffs (138 lines):
diff -r be441fa4bed0 -r c8b8f887ef80 ChangeLog
--- a/ChangeLog Fri Sep 14 11:50:40 2012 +0200
+++ b/ChangeLog Fri Sep 14 11:54:03 2012 +0200
@@ -1,3 +1,9 @@
+2012-09-14 Andre Heinecke <aheinecke at intevation.de>
+
+ * src/java/de/intevation/mxd/writer/MapScriptWriter.java:
+ Add write support fpr Fgdb and allow removing a prefix
+ for expressions.
+
2012-09-14 Andre Heinecke <aheinecke at intevation.de>
* src/java/de/intevation/mxd/reader/MXDReader.java:
diff -r be441fa4bed0 -r c8b8f887ef80 src/java/de/intevation/mxd/writer/MapScriptWriter.java
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Fri Sep 14 11:50:40 2012 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Fri Sep 14 11:54:03 2012 +0200
@@ -527,6 +527,10 @@
layer.setConnectionType(MS_CONNECTION_TYPE.MS_WMS.swigValue(), "");
layer.setMetaData("wms_name",
layerElement.getAttribute("wms_name"));
+ } else if(con_type.equals("ogr")) {
+ layer.setConnectionType(MS_CONNECTION_TYPE.MS_OGR.swigValue(), "");
+ layer.setConnection(layerElement.getAttribute("connection"));
+ layer.setData(layerElement.getAttribute("data_source"));
}
if(!type.equals("raster")) {
layer.setTemplate("PleaseInsertAValidTemplateForGFI");
@@ -544,6 +548,14 @@
String expr = label.getAttribute("expression");
expr = expr.replaceAll("\\[", "");
expr = expr.replaceAll("\\]", "");
+ if (con_type == "ogr") {
+ // ogr expression fields come prefixed from arcgis
+ // the prefix has to be removed in order to work with
+ // mapserver
+ String unwantedPrefix = layerElement.getAttribute("data") + ".";
+ logger.debug("Removing expression Prefix: " + unwantedPrefix);
+ expr = expr.replace(unwantedPrefix, "");
+ }
if(!prefix.equals("")) {
expr = prefix + "." + expr;
}
@@ -593,7 +605,8 @@
//Create definition expression.
if(classElement.hasAttribute("field_count")) {
- co.setExpression(createExpression(classElement, i));
+ String unwantedPrefix = layerElement.getAttribute("data") + ".";
+ co.setExpression(createExpression(classElement, i, unwantedPrefix));
}
//Write symbols and styles.
@@ -701,8 +714,10 @@
*
* @param ce DOM elementcontaining the class expression information.
* @param index Index to determine the correct expression operator.
+ * @param prefixToRemove A string that will be removed from the start of
+ * expression fields.
*/
- private String createExpression(Element ce, int index) {
+ private String createExpression(Element ce, int index, String prefixToRemove) {
String expression = "(";
int count = 0;
try {
@@ -723,7 +738,8 @@
pre = prefix + ".";
}
expression += "[" + pre;
- expression += ce.getAttribute("expression_field_0") + "]";
+ expression += ce.getAttribute("expression_field_0").replace(
+ prefixToRemove, "") + "]";
if(ce.hasAttribute("min_value")) {
if(index == 0) {
expression += " >= " + ce.getAttribute("min_value");
@@ -732,7 +748,8 @@
expression += " > " + ce.getAttribute("min_value");
}
expression += " AND [" + pre;
- expression += ce.getAttribute("expression_field_0");
+ expression += ce.getAttribute("expression_field_0").replace(
+ prefixToRemove, "");
expression += "]";
}
expression += " " + ce.getAttribute("expression_operator");
@@ -740,13 +757,15 @@
}
catch(NumberFormatException nfe) {
//The expression value is a strings.
- String exp = ce.getAttribute("expression_field_0");
+ String exp = ce.getAttribute("expression_field_0").replace(
+ prefixToRemove, "");
String pre = "";
if (!prefix.equals("") && !exp.startsWith(prefix)) {
pre = prefix + ".";
}
expression += "\"[" + pre;
- expression += ce.getAttribute("expression_field_0") + "]\"";
+ expression += ce.getAttribute("expression_field_0").replace(
+ prefixToRemove, "") + "]\"";
expression += " " + ce.getAttribute("expression_operator");
expression += " \"" + ce.getAttribute("value") + "\")";
}
@@ -761,13 +780,15 @@
//If no exception is thrown, the expression values are
//numbers.
Double.parseDouble(ce.getAttribute("value_" + i));
- String exp = ce.getAttribute("expression_field_" + i);
+ String exp = ce.getAttribute("expression_field_" + i).replace(
+ prefixToRemove, "");
String pre = "";
if (!prefix.equals("") && !exp.startsWith(prefix)) {
pre = prefix + ".";
}
expression += "[" + pre;
- expression += ce.getAttribute("expression_field_" + i);
+ expression += ce.getAttribute("expression_field_" + i).replace(
+ prefixToRemove, "");
expression += "]";
expression += " " + ce.getAttribute("expression_operator");
expression += " " + ce.getAttribute("value_" + i);
@@ -780,13 +801,15 @@
}
catch (NumberFormatException nfe) {
//The expression values are strings.
- String exp = ce.getAttribute("expression_field_" + i);
+ String exp = ce.getAttribute("expression_field_" + i).replace(
+ prefixToRemove, "");
String pre = "";
if (!prefix.equals("") && !exp.startsWith(prefix)) {
pre = prefix + ".";
}
expression += "\"[" + pre;
- expression += ce.getAttribute("expression_field_" + i);
+ expression += ce.getAttribute("expression_field_" + i).replace(
+ prefixToRemove, "");
expression += "]\"";
expression += " " + ce.getAttribute("expression_operator");
expression += " \"" + ce.getAttribute("value_" + i);
More information about the MXD2map-commits
mailing list