diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 252:eae3fe89e669

Added raster layer support.
author raimund renkert <raimund.renkert@intevation.de>
date Mon, 15 Aug 2011 12:07:09 +0200
parents 4c59d8c36418
children cedb23deb057
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Fri Aug 12 16:08:57 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Mon Aug 15 12:07:09 2011 +0200
@@ -301,14 +301,19 @@
             String type = layerElement.getAttribute("type");
             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("");
             }
             else if (type.equals("polygon")) {
                 layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON);
+                layer.setTileitem("");
             }
-            layer.setTileitem("");
+	    else if(type.equals("raster")) {
+	        layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER);
+	    }
 
             //The layer datasource.
             String con_type = layerElement.getAttribute("connection_type");
@@ -323,7 +328,7 @@
                 datasource = datasource.replaceAll("\\\\", "/");
                 layer.setData(datasource);
             }
-            else if(con_type.equals("SDE")) {
+            else if(con_type.equals("SDE") && !type.equals("raster")) {
                 // The data source is a sde database.
                 logger.info(
                     "SDE datasource found." +
@@ -391,7 +396,45 @@
                     }
                 }
             }
-            layer.setTemplate("PleaseInsertAValidTemplateForGFI");
+	    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 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);
+                if(layerElement.hasAttribute("definition_query") &&
+                   !layerElement.getAttribute("definition_query").equals("")) {
+                        layer.setFilter("where " +
+                        layerElement.getAttribute("definition_query"));
+                }
+	    }
+	    if(!type.equals("raster")) {
+                layer.setTemplate("PleaseInsertAValidTemplateForGFI");
+	    }
 
             // Create labelitem
             NodeList labels = layerElement.getElementsByTagName("label");
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)