Mercurial > mxd2map
changeset 130:5991c1f90f91
Added data source "SDE" to writer.
author | vc11884admin@VC11884.win.bsh.de |
---|---|
date | Mon, 20 Jun 2011 16:01:17 +0200 |
parents | 0b119169618f |
children | cd18c61cbcf6 |
files | ChangeLog src/java/de/intevation/mxd/reader/FeatureLayerReader.java src/java/de/intevation/mxd/writer/MapScriptWriter.java |
diffstat | 3 files changed, 64 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Jun 20 12:20:48 2011 +0200 +++ b/ChangeLog Mon Jun 20 16:01:17 2011 +0200 @@ -1,3 +1,11 @@ +2011-06-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/reader/FeatureLayerReader.java: + Read additional information for sde data connections. + + * src/java/de/intevation/mxd/writer/MapscriptWriter.java: + Write sde data connection information to mapfile. + 2011-06-20 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/writer/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/reader/FeatureLayerReader.java Mon Jun 20 12:20:48 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/FeatureLayerReader.java Mon Jun 20 16:01:17 2011 +0200 @@ -197,6 +197,20 @@ } } } + layerElement.setAttribute( + "join_table", + layer.getRelationshipClass() + .getOriginClass().getAliasName()); + layerElement.setAttribute( + "join_field", + layer.getRelationshipClass().getOriginPrimaryKey()); + layerElement.setAttribute( + "join_table_target", + layer.getRelationshipClass() + .getDestinationClass().getAliasName()); + layerElement.setAttribute( + "join_field_target", + layer.getRelationshipClass().getOriginForeignKey()); } } catch(Exception e) {
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Mon Jun 20 12:20:48 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Mon Jun 20 16:01:17 2011 +0200 @@ -16,6 +16,7 @@ import edu.umn.gis.mapscript.MS_UNITS; import edu.umn.gis.mapscript.MS_LAYER_TYPE; +import edu.umn.gis.mapscript.MS_CONNECTION_TYPE; import de.intevation.mxd.utils.XMLUtils; @@ -39,6 +40,7 @@ private Document root; private mapObj map; private String mapFilename; + private String MS_BINDIR = "c:/ms_6.1-dev/bin"; public MapScriptWriter() { map = new mapObj(""); @@ -179,14 +181,47 @@ layer.setTileitem(""); //The layer datasource. - String datasource = ""; - if(layerElement.hasAttribute("workspace")) { - datasource = layerElement.getAttribute("workspace"); - datasource += File.separator; - } - datasource += layerElement.getAttribute("data_source"); - layer.setData(datasource); + String con_type = layerElement.getAttribute("connection_type"); + if(con_type.equals("local")) { + String datasource = ""; + if(layerElement.hasAttribute("workspace")) { + datasource = layerElement.getAttribute("workspace"); + datasource += File.separator; + } + 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"); + 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"); + layer.setProcessing("ATTRIBUTE_QUALIFIED=TRUE"); + layer.setProcessing( + "JOINTABLE=" + + layerElement.getAttribute("join_table")); + layer.setFilter( + "where " + + layerElement.getAttribute("definition_query") + + " AND " + + layerElement.getAttribute("join_table_target") + "." + + layerElement.getAttribute("join_field_target") + "=" + + layerElement.getAttribute("join_table") + "." + + layerElement.getAttribute("join_field")); + } layer.setTemplate("PleaseInsertAValidTemplateForGFI"); //Write classes. writeClass(layer, layerElement);