changeset 1845:06c157848c8f

Made the floodmap compatible with an Oracle database. flys-artifacts/trunk@3189 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Nov 2011 10:48:51 +0000
parents 06cf1009301d
children 6deed62a2468
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/mapserver/dbconnection.include flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSQPSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java
diffstat 7 files changed, 62 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Nov 09 10:48:51 2011 +0000
@@ -1,3 +1,21 @@
+2011-11-09  Ingo Weinzierl <ingo@intevation.de>
+
+	 * doc/conf/mapserver/dbconnection.include: Adapted connection params for
+	   using an oracle database.
+
+	* src/main/java/de/intevation/flys/artifacts/WMSQPSArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java:
+	  Added Oracle support for Mapserver's DATA attribute. Oracle doesn't allow
+	  a "USING UNIQUE id" string in this attribute which is required by Postgis.
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
+	  Modified the geometry type of "talaue.shp" from MultiPolygon to Polygon.
+
+	* src/main/java/de/intevation/flys/utils/FLYSUtils.java: Added a function
+	  which returns true, if the backend uses an Oracle db instance. Otherwise,
+	  it returns false.
+
 2011-11-08  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Fix flys/issue406 (Themestyle-editor: themes for "other.wkms" and
--- a/flys-artifacts/doc/conf/mapserver/dbconnection.include	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/doc/conf/mapserver/dbconnection.include	Wed Nov 09 10:48:51 2011 +0000
@@ -1,2 +1,2 @@
-CONNECTIONTYPE postgis
-CONNECTION "dbname='flys3' host='czech-republic.atlas.intevation.de' port=5432 user='flys' password='flys' sslmode=disable"
+CONNECTIONTYPE oraclespatial
+CONNECTION "flys26/flys26@czech-republic.atlas.intevation.de"
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java	Wed Nov 09 10:48:51 2011 +0000
@@ -138,8 +138,14 @@
 
         @Override
         protected String getDataString() {
-            // TODO SRID
-            return "geom FROM river_axes USING UNIQUE id USING SRID 31466";
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM river_axes USING SRID " + srid;
+            }
+            else {
+                return "geom FROM river_axes USING UNIQUE id USING SRID " + srid;
+            }
         }
 
         @Override
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java	Wed Nov 09 10:48:51 2011 +0000
@@ -149,7 +149,15 @@
 
         @Override
         protected String getDataString() {
-            return "geom FROM river_axes_km USING UNIQUE id USING SRID 31466";
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM river_axes_km USING SRID " + srid;
+            }
+            else {
+                return "geom FROM river_axes_km " +
+                       "USING UNIQUE id USING SRID " + srid;
+            }
         }
 
         @Override
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSQPSArtifact.java	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSQPSArtifact.java	Wed Nov 09 10:48:51 2011 +0000
@@ -150,9 +150,15 @@
 
         @Override
         protected String getDataString() {
-            // TODO SRID
-            return "geom FROM cross_section_tracks " +
-                   "USING UNIQUE id USING SRID 31466";
+            String srid = getSrid();
+
+            if (FLYSUtils.isUsingOracle()) {
+                return "geom FROM cross_section_tracks USING SRID " + srid;
+            }
+            else {
+                return "geom FROM cross_section_tracks " +
+                       "USING UNIQUE id USING SRID " + srid;
+            }
         }
 
         @Override
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Wed Nov 09 10:48:51 2011 +0000
@@ -10,7 +10,6 @@
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.LineString;
-import com.vividsolutions.jts.geom.MultiPolygon;
 import com.vividsolutions.jts.geom.Polygon;
 
 import org.apache.log4j.Logger;
@@ -589,7 +588,7 @@
         Floodplain plain = Floodplain.getFloodplain(river);
 
         SimpleFeatureType ft = GeometryUtils.buildFeatureType(
-            "talaue", srs, MultiPolygon.class);
+            "talaue", srs, Polygon.class);
 
         SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
         builder.add(plain.getGeom());
@@ -601,7 +600,7 @@
 
         boolean t = GeometryUtils.writeShapefile(
             talaueShape,
-            GeometryUtils.buildFeatureType("talaue", srs, MultiPolygon.class),
+            GeometryUtils.buildFeatureType("talaue", srs, Polygon.class),
             collection);
 
         if (t) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Tue Nov 08 12:06:43 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Wed Nov 09 10:48:51 2011 +0000
@@ -11,6 +11,9 @@
 
 import org.w3c.dom.Document;
 
+import org.hibernate.SessionFactory;
+import org.hibernate.impl.SessionFactoryImpl;
+
 import gnu.trove.TDoubleArrayList;
 
 import de.intevation.artifacts.Artifact;
@@ -19,6 +22,8 @@
 import de.intevation.artifacts.common.utils.Config;
 import de.intevation.artifacts.common.utils.XMLUtils;
 
+import de.intevation.flys.backend.SessionFactoryProvider;
+
 import de.intevation.flys.artifacts.context.FLYSContext;
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
@@ -114,6 +119,15 @@
     }
 
 
+    public static boolean isUsingOracle() {
+        SessionFactory sf = SessionFactoryProvider.getSessionFactory();
+
+        String d = SessionFactoryProvider.getDriver((SessionFactoryImpl) sf);
+
+        return d != null ? d.indexOf("Oracle") >= 0 : false;
+    }
+
+
     public static KM_MODE getKmRangeMode(FLYSArtifact flys) {
         String mode = flys.getDataAsString("ld_mode");
 

http://dive4elements.wald.intevation.org