[Dive4elements-commits] [PATCH 2 of 2] merge

Wald Commits scm-commit at wald.intevation.org
Thu Mar 14 12:54:19 CET 2013


# HG changeset patch
# User Bettina Gruenbauer <bettina at intevation.de>
# Date 1363262016 -3600
# Node ID 55122db34cd0d0f7632153cefb80f257a81e7714
# Parent  ee7b0306b2bf11b9fde8175c7cd82ebafcb25293
# Parent  3f35d9db48c120e97f2e2f3bfbd31fdcb94b72fe
merge

diff -r ee7b0306b2bf -r 55122db34cd0 flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Thu Mar 14 12:53:36 2013 +0100
@@ -175,14 +175,15 @@
         logger.debug("MainValuesArtifact.initialize");
         FLYSArtifact winfo = (FLYSArtifact) artifact;
         RangeAccess rangeAccess = new RangeAccess(winfo, null);
-        double [] locations = rangeAccess.getLocations();
+        double [] locations = rangeAccess.getKmRange();
+
         if (locations != null) {
             double location = locations[0];
             addData("ld_locations", new DefaultStateData("ld_locations", null, null,
                     String.valueOf(location)));
         }
         else {
-            logger.warn("No location for mainvalues given.");
+            logger.error("No location for mainvalues given.");
         }
         importData(winfo, "river");
     }
@@ -247,7 +248,13 @@
         // TODO use helper to get location as double
         String locationStr = getDataAsString("ld_locations");
 
-        if (river == null || locationStr == null) {
+        if (river == null) {
+            logger.error("River is null");
+            return null;
+        }
+
+        if (locationStr == null) {
+            logger.error("Locationstr is null");
             return null;
         }
 
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/contrib/shpimporter/uesg.py
--- a/flys-backend/contrib/shpimporter/uesg.py	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-backend/contrib/shpimporter/uesg.py	Thu Mar 14 12:53:36 2013 +0100
@@ -4,7 +4,8 @@
     import ogr
 
 from importer import Importer
-
+import os.path
+import utils
 
 TABLE_NAME="floodmaps"
 PATH="Hydrologie/UeSG"
@@ -26,11 +27,8 @@
 
 
     def isGeometryValid(self, geomType):
-        if geomType == 3 or geomType == 6:
-            return True
-        else:
-            return False
-
+        return geomType in [ogr.wkbMultiPolygon,
+                            ogr.wkbPolygon]
 
     def getKind(self, path):
         kind = 0
@@ -54,7 +52,6 @@
 
     def createNewFeature(self, featureDef, feat, **args):
         kind  = self.getKind(args['path'])
-
         newFeat = ogr.Feature(featureDef)
         newFeat.SetGeometry(feat.GetGeometryRef())
 
@@ -83,6 +80,11 @@
         else:
             perimeter = 0
 
+        if kind >= 200:
+            newFeat.SetField("source",
+                    os.path.basename(os.path.dirname(args['path'])))
+
+
         groupId = 2
 
         newFeat.SetField("river_id", riverId)
@@ -93,5 +95,5 @@
         newFeat.SetField("kind", kind)
         newFeat.SetField("name", args['name'])
 
-        return newFeat
+        return utils.convertToMultiPolygon(newFeat)
 
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/contrib/shpimporter/utils.py
--- a/flys-backend/contrib/shpimporter/utils.py	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-backend/contrib/shpimporter/utils.py	Thu Mar 14 12:53:36 2013 +0100
@@ -108,3 +108,15 @@
     geometry.AssignSpatialReference(srs)
     feature.SetGeometry(geometry)
     return feature
+
+def convertToMultiPolygon(feature):
+    """
+    Converts a feature to a multiline feature.
+    """
+    geometry = feature.GetGeometryRef()
+    # SRS information is lost while forcing to multiline
+    srs = geometry.GetSpatialReference()
+    geometry = ogr.ForceToMultiPolygon(geometry)
+    geometry.AssignSpatialReference(srs)
+    feature.SetGeometry(geometry)
+    return feature
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/doc/schema/oracle-spatial.sql
--- a/flys-backend/doc/schema/oracle-spatial.sql	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-backend/doc/schema/oracle-spatial.sql	Thu Mar 14 12:53:36 2013 +0100
@@ -373,3 +373,30 @@
         SELECT GAUGE_LOCATION_ID_SEQ.nextval INTO :new.id FROM dual;
     END;
 /
+
+
+CREATE TABLE jetty_kinds(
+    id 	     NUMBER PRIMARY KEY NOT NULL,
+    name     VARCHAR(64)
+);
+INSERT INTO jetty_kinds VALUES (0, 'Buhnenkopf');
+INSERT INTO jetty_kinds VALUES (1, 'Buhnenfuß');
+INSERT INTO jetty_kinds VALUES (2, 'Buhnenwurzel');
+
+CREATE SEQUENCE JETTIES_ID_SEQ;
+CREATE TABLE jetties (
+    OGR_FID     NUMBER(38),
+    GEOM        MDSYS.SDO_GEOMETRY,
+    id          NUMBER PRIMARY KEY NOT NULL,
+    river_id 	NUMBER(38) REFERENCES rivers(id) ON DELETE CASCADE,
+    path       	VARCHAR(256),
+    kind_id    	NUMBER(38) REFERENCES jetty_kinds(id),
+    km 		NUMBER(7,3),
+    z        NUMBER(38,12)
+);
+INSERT INTO USER_SDO_GEOM_METADATA VALUES ('jetties', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467);
+CREATE OR REPLACE TRIGGER jetties_trigger BEFORE INSERT ON jetties FOR EACH ROW
+    BEGIN
+        SELECT JETTIES_ID_SEQ.nextval INTO :new.id FROM dual;
+    END;
+/
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/doc/schema/oracle-spatial_idx.sql
--- a/flys-backend/doc/schema/oracle-spatial_idx.sql	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-backend/doc/schema/oracle-spatial_idx.sql	Thu Mar 14 12:53:36 2013 +0100
@@ -12,7 +12,7 @@
 
 -- TODO: index prevents importing on 11g.
 -- Error: "Ebenendimensionalitat stimmt nicht mit Geometrie-Dimensionen uberein"
--- CREATE INDEX river_axes_spatial_idx ON river_axes(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE');
+-- CREATE INDEX river_axes_spatial_idx ON river_axes(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTILINE');
 
 -- TODO: index prevents importing on 11g.
 -- Error: "Ebenendimensionalitat stimmt nicht mit Geometrie-Dimensionen uberein"
@@ -26,7 +26,11 @@
 
 CREATE INDEX hws_points_spatial_idx ON hws_points(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT');
 CREATE INDEX hws_lines_spatial_idx ON hws_lines(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTILINE');
+
 CREATE INDEX floodmaps_spatial_idx ON floodmaps(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTIPOLYGON');
+
 CREATE INDEX gauge_location_idx ON gauge_location(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT');
 CREATE INDEX hydr_boundaries_poly_idx ON hydr_boundaries_poly(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTIPOLYGON');
 
+CREATE INDEX jetties_idx ON jetties(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT');
+
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/doc/schema/postgresql-setup.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/doc/schema/postgresql-setup.sh	Thu Mar 14 12:53:36 2013 +0100
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# $1: user name and password for new DB (equals DB name)
+# $2: path to directory with schema-scripts
+# $3: host
+
+# run as user postgres (postgresql super-user)
+# it is assumed that the owner of the DB has the same name as the DB!
+
+# create PostGIS-DB
+createuser -S -D -R $1
+createdb $1
+createlang plpgsql $1
+# Appears e.g. as /usr/share/postgresql/contrib/postgis-1.5/ on other systems.
+psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
+psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
+psql -d $1 -c "ALTER USER $1 WITH PASSWORD '$1';"
+psql -d $1 -c "GRANT ALL ON geometry_columns TO $1; GRANT ALL ON geography_columns TO $1; GRANT ALL ON spatial_ref_sys TO $1;"
+
+# add credentials to .pgpass (or create .pgpass)
+echo "*:*:$1:$1:$1" >> ~/.pgpass
+chmod 0600 ~/.pgpass
+
+# apply schema-scripts
+psql -d $1 -U $1 -h $3 -f $2/postgresql.sql
+psql -d $1 -U $1 -h $3 -f $2/postgresql-spatial.sql
+psql -d $1 -U $1 -h $3 -f $2/postgresql-minfo.sql
diff -r ee7b0306b2bf -r 55122db34cd0 flys-backend/doc/schema/postgresql-spatial.sql
--- a/flys-backend/doc/schema/postgresql-spatial.sql	Thu Mar 14 12:49:41 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-spatial.sql	Thu Mar 14 12:53:36 2013 +0100
@@ -112,8 +112,8 @@
     river_id int REFERENCES rivers(id) ON DELETE CASCADE,
     -- XXX Should we use the ranges table instead?
     name             VARCHAR(64),
-    range_id         INT REFERENCES ranges(id);
-    time_interval_id INT REFERENCES time_intervals(id);
+    range_id         INT REFERENCES ranges(id),
+    time_interval_id INT REFERENCES time_intervals(id),
     projection       VARCHAR(32),
     srid	    int  NOT NULL,
     elevation_state  VARCHAR(32),
@@ -300,4 +300,26 @@
 SELECT AddGeometryColumn('gauge_location','geom',31467,'POINT',2);
 ALTER TABLE gauge_location ALTER COLUMN id SET DEFAULT NEXTVAL('GAUGE_LOCATION_ID_SEQ');
 
+
+CREATE TABLE jetty_kinds(
+    id int PRIMARY KEY NOT NULL,
+    name VARCHAR(64)
+);
+INSERT INTO jetty_kinds VALUES (0, 'Buhnenkopf');
+INSERT INTO jetty_kinds VALUES (1, 'Buhnenfuß');
+INSERT INTO jetty_kinds VALUES (2, 'Buhnenwurzel');
+
+CREATE SEQUENCE JETTIES_ID_SEQ;
+CREATE TABLE jetties (
+    id         int PRIMARY KEY NOT NULL,
+    river_id   int REFERENCES rivers(id) ON DELETE CASCADE,
+    path       VARCHAR(256),
+    kind_id    int REFERENCES jetty_kinds(id),
+    km         FLOAT8,
+    z	       FLOAT8
+);
+SELECT AddGeometryColumn('jetties','geom',31467,'POINT',2);
+ALTER TABLE jetties ALTER COLUMN id SET DEFAULT NEXTVAL('JETTIES_ID_SEQ');
+
+
 COMMIT;


More information about the Dive4elements-commits mailing list