changeset 246:87e92debc53f

Added extent and projection as ows metadata to the mapfile.
author raimund renkert <raimund.renkert@intevation.de>
date Wed, 10 Aug 2011 13:18:53 +0200
parents 2eeeae07aaa2
children 30e10eb9ac68
files ChangeLog src/java/de/intevation/mxd/reader/FeatureLayerReader.java src/java/de/intevation/mxd/writer/MapScriptWriter.java
diffstat 3 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 09 17:42:31 2011 +0200
+++ b/ChangeLog	Wed Aug 10 13:18:53 2011 +0200
@@ -1,3 +1,12 @@
+2011-08-09  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/reader/FeatureLayerReader.java:
+	  Read layer extent from mxd.
+
+	* src/java/de/intevation/mxd/writer/MapScriptWriter.java:
+	  Write layer extent, map extent and projection as metadata to
+	  the mapfile.
+
 2011-08-09  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	* src/java/de/intevation/mxd/writer/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/reader/FeatureLayerReader.java	Tue Aug 09 17:42:31 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/FeatureLayerReader.java	Wed Aug 10 13:18:53 2011 +0200
@@ -29,6 +29,8 @@
 import com.esri.arcgis.geodatabase.FeatureClassName;
 import com.esri.arcgis.system.IName;
 import com.esri.arcgis.system.IPropertySet;
+import com.esri.arcgis.geometry.Envelope;
+
 import org.w3c.dom.Element;
 
 import de.intevation.mxd.utils.MapToXMLUtils;
@@ -209,6 +211,26 @@
         }
 
         try {
+            Envelope rect = (Envelope)layer.getExtent();
+            layerElement.setAttribute(
+                "extent_min_x",
+                String.valueOf(rect.getXMin ()));
+            layerElement.setAttribute(
+                "extent_max_x",
+                String.valueOf(rect.getXMax()));
+            layerElement.setAttribute(
+                "extent_y_min",
+                String.valueOf(rect.getYMin()));
+            layerElement.setAttribute(
+                "extent_y_max",
+                String.valueOf(rect.getYMax()));
+        }
+        catch(IOException ioe) {
+            logger.warn(
+                "Could not read extent from layer "
+                + layer.getName() + ".");
+        }
+        try {
             String datatype = layer.getDataSourceType();
             if(layer.getWorkspace().getType() == 0) {
                 layerElement.setAttribute("connection_type", "local");
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Tue Aug 09 17:42:31 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Aug 10 13:18:53 2011 +0200
@@ -162,6 +162,13 @@
             Double.parseDouble(mapNode.getAttribute("extent_max_x")),
             Double.parseDouble(mapNode.getAttribute("extent_max_y")));
 
+	map.setMetaData(
+	    "ows_extent",
+	    mapNode.getAttribute("extent_min_x") + ", " +
+	    mapNode.getAttribute("extent_min_y") + ", " +
+	    mapNode.getAttribute("extent_max_x") + ", " +
+	    mapNode.getAttribute("extent_max_y"));
+
         //Set the units and projection.
         int proj = Integer.parseInt(mapNode.getAttribute("projection"));
         if(proj != 0) {
@@ -196,6 +203,10 @@
             units = MS_UNITS.MS_METERS;
         }
         map.setUnits(units);
+
+	String srs = map.getMetaData("ows_srs");
+	srs += " EPSG:" + mapNode.getAttribute("projection");
+	map.setMetaData("ows_srs", srs);
     }
 
     /**
@@ -243,6 +254,17 @@
 	    }
             layer.setMetaData("wms_title", ulname);
 
+	    if(layerElement.hasAttribute("extent_min_x") &&
+	       layerElement.hasAttribute("extent_max_x") &&
+	       layerElement.hasAttribute("extent_min_y") &&
+	       layerElement.hasAttribute("extent_max_y")) {
+	        layer.setMetaData(
+		    "ows_extent",
+		    layerElement.getAttribute("extent_min_x") + ", " +
+		    layerElement.getAttribute("extent_min_y") + ", " +
+		    layerElement.getAttribute("extent_max_x") + ", " +
+		    layerElement.getAttribute("extent_max_y"));
+	    }
             //The layer status.
             String stat = layerElement.getAttribute("status");
             if (stat.equals("on")) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)