changeset 5137:04eb62eae722

River Axes and HWS_lines are now multiline
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 28 Feb 2013 12:58:25 +0100
parents ec3430d12d2e
children fc0cdcae8f07
files flys-backend/contrib/shpimporter/axis.py flys-backend/contrib/shpimporter/hws.py flys-backend/contrib/shpimporter/utils.py flys-backend/doc/schema/oracle-spatial_idx.sql flys-backend/doc/schema/postgresql-spatial.sql
diffstat 5 files changed, 27 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/axis.py	Thu Feb 28 12:48:27 2013 +0100
+++ b/flys-backend/contrib/shpimporter/axis.py	Thu Feb 28 12:58:25 2013 +0100
@@ -4,6 +4,7 @@
     import ogr
 
 from importer import Importer
+import utils
 
 NAME="Axis"
 TABLE_NAME="river_axes"
@@ -25,8 +26,10 @@
 
 
     def isGeometryValid(self, geomType):
-        return geomType == 2
-
+        return geomType in [ogr.wkbLineString,
+                            ogr.wkbLineString25D,
+                            ogr.wkbMultiLineString25D,
+                            ogr.wkbMultiLineString]
 
     def isShapeRelevant(self, name, path):
         return "achse" in name.lower()
@@ -50,5 +53,4 @@
         newFeat.SetField("river_id", riverId)
         newFeat.SetField("kind", kind)
 
-        return newFeat
-
+        return utils.convertToMultiLine(newFeat)
--- a/flys-backend/contrib/shpimporter/hws.py	Thu Feb 28 12:48:27 2013 +0100
+++ b/flys-backend/contrib/shpimporter/hws.py	Thu Feb 28 12:58:25 2013 +0100
@@ -180,7 +180,10 @@
         return "HWS_LINES"
 
     def isGeometryValid(self, geomType):
-        return geomType == ogr.wkbLineString or geomType == ogr.wkbLineString25D
+        return geomType in [ogr.wkbLineString,
+                            ogr.wkbLineString25D,
+                            ogr.wkbMultiLineString25D,
+                            ogr.wkbMultiLineString]
 
     def isShapeRelevant(self, name, path):
         shp = ogr.Open(path)
@@ -189,9 +192,10 @@
     def createNewFeature(self, featureDef, feat, **args):
         newFeat = HWSPoints.createNewFeature(self, featureDef, feat, **args)
         geometry = feat.GetGeometryRef()
-        geometry.SetCoordinateDimension(3)
+        if geometry.GetCoordinateDimension() == 2:
+            geometry.SetCoordinateDimension(3)
         newFeat.SetGeometry(geometry)
 
-        return newFeat
+        return utils.convertToMultiLine(newFeat)
 
 
--- a/flys-backend/contrib/shpimporter/utils.py	Thu Feb 28 12:48:27 2013 +0100
+++ b/flys-backend/contrib/shpimporter/utils.py	Thu Feb 28 12:58:25 2013 +0100
@@ -97,3 +97,14 @@
 def getWkbString(type):
     return WKB_MAP.get(type) or "Unknown"
 
+def convertToMultiLine(feature):
+    """
+    Converts a feature to a multiline feature.
+    """
+    geometry = feature.GetGeometryRef()
+    # SRS information is lost while forcing to multiline
+    srs = geometry.GetSpatialReference()
+    geometry = ogr.ForceToMultiLineString(geometry)
+    geometry.AssignSpatialReference(srs)
+    feature.SetGeometry(geometry)
+    return feature
--- a/flys-backend/doc/schema/oracle-spatial_idx.sql	Thu Feb 28 12:48:27 2013 +0100
+++ b/flys-backend/doc/schema/oracle-spatial_idx.sql	Thu Feb 28 12:58:25 2013 +0100
@@ -25,7 +25,7 @@
 -- CREATE INDEX hydr_boundaries_idx ON hydr_boundaries(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE');
 
 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=LINE');
+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');
--- a/flys-backend/doc/schema/postgresql-spatial.sql	Thu Feb 28 12:48:27 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-spatial.sql	Thu Feb 28 12:58:25 2013 +0100
@@ -9,7 +9,7 @@
     name     VARCHAR(64),
     path     VARCHAR(256)
 );
-SELECT AddGeometryColumn('river_axes', 'geom', 31467, 'LINESTRING', 2);
+SELECT AddGeometryColumn('river_axes', 'geom', 31467, 'MULTILINESTRING', 2);
 ALTER TABLE river_axes ALTER COLUMN id SET DEFAULT NEXTVAL('RIVER_AXES_ID_SEQ');
 
 
@@ -152,7 +152,7 @@
     status_date TIMESTAMP,
     description VARCHAR(256)
 );
-SELECT AddGeometryColumn('hws_lines', 'geom', 31467, 'LINESTRING', 3);
+SELECT AddGeometryColumn('hws_lines', 'geom', 31467, 'MULTILINESTRING', 3);
 -- TODO: dike_km_from dike_km_to, are they geometries?
 
 ALTER TABLE hws_lines ALTER COLUMN id SET DEFAULT NEXTVAL('HWS_LINES_ID_SEQ');

http://dive4elements.wald.intevation.org