# HG changeset patch # User Andre Heinecke # Date 1362052705 -3600 # Node ID 04eb62eae722ccda052c3daa4222dd8fb6c9d13e # Parent ec3430d12d2ec9fb88fcd50d319b494165e8475f River Axes and HWS_lines are now multiline diff -r ec3430d12d2e -r 04eb62eae722 flys-backend/contrib/shpimporter/axis.py --- 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) diff -r ec3430d12d2e -r 04eb62eae722 flys-backend/contrib/shpimporter/hws.py --- 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) diff -r ec3430d12d2e -r 04eb62eae722 flys-backend/contrib/shpimporter/utils.py --- 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 diff -r ec3430d12d2e -r 04eb62eae722 flys-backend/doc/schema/oracle-spatial_idx.sql --- 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'); diff -r ec3430d12d2e -r 04eb62eae722 flys-backend/doc/schema/postgresql-spatial.sql --- 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');