Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 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 | 02df1dbc2166 |
line wrap: on
line diff
--- 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);