Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/lines.py @ 2861:b0132e1b9719
Added further shape importers and added the option to reproject shapes during the import process.
flys-backend/trunk@4342 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 May 2012 14:19:52 +0000 |
parents | bd9e76e0b55d |
children | 59ca5dab2782 |
comparison
equal
deleted
inserted
replaced
2860:2f874d14ac68 | 2861:b0132e1b9719 |
---|---|
15 def getTablename(self): | 15 def getTablename(self): |
16 return TABLE_NAME | 16 return TABLE_NAME |
17 | 17 |
18 | 18 |
19 def isGeometryValid(self, geomType): | 19 def isGeometryValid(self, geomType): |
20 return geomType == 2 | 20 return geomType == 2 or geomType == -2147483646 |
21 | 21 |
22 | 22 |
23 def isShapeRelevant(self, name, path): | 23 def isShapeRelevant(self, name, path): |
24 return True | 24 return True |
25 | 25 |
26 | 26 |
27 def createNewFeature(self, featureDef, feat, **args): | 27 def createNewFeature(self, featureDef, feat, **args): |
28 newFeat = ogr.Feature(featureDef) | 28 newFeat = ogr.Feature(featureDef) |
29 newFeat.SetGeometry(feat.GetGeometryRef()) | 29 geometry = feat.GetGeometryRef() |
30 geometry.SetCoordinateDimension(2) | |
31 | |
32 newFeat.SetGeometry(geometry) | |
33 newFeat.SetField("name", args['name']) | |
30 | 34 |
31 if self.IsFieldSet(feat, "river_id"): | 35 if self.IsFieldSet(feat, "river_id"): |
32 newFeat.SetField("river_id", feat.GetField("river_id")) | 36 newFeat.SetField("river_id", feat.GetField("river_id")) |
33 else: | 37 else: |
34 newFeat.SetField("river_id", self.river_id) | 38 newFeat.SetField("river_id", self.river_id) |
35 | 39 |
36 if self.IsFieldSet(feat, "TYP"): | 40 if self.IsFieldSet(feat, "TYP"): |
37 newFeat.SetField("kind", feat.GetFieldAsDouble("TYP")) | 41 newFeat.SetField("kind", feat.GetFieldAsDouble("TYP")) |
38 else: | 42 else: |
39 return None | 43 newFeat.SetField("kind", "DAMM") |
40 | 44 |
41 if self.IsFieldSet(feat, "Z"): | 45 if self.IsFieldSet(feat, "Z"): |
42 newFeat.SetField("z", feat.GetFieldAsDouble("Z")) | 46 newFeat.SetField("z", feat.GetFieldAsDouble("Z")) |
43 else: | 47 else: |
44 newFeat.SetField("z", 0) | 48 newFeat.SetField("z", 9999) |
45 | 49 |
46 return newFeat | 50 return newFeat |
47 | 51 |