Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/uesg.py @ 5296:55122db34cd0
merge
author | Bettina Gruenbauer <bettina@intevation.de> |
---|---|
date | Thu, 14 Mar 2013 12:53:36 +0100 |
parents | 3f35d9db48c1 |
children |
comparison
equal
deleted
inserted
replaced
5295:ee7b0306b2bf | 5296:55122db34cd0 |
---|---|
2 from osgeo import ogr | 2 from osgeo import ogr |
3 except ImportError: | 3 except ImportError: |
4 import ogr | 4 import ogr |
5 | 5 |
6 from importer import Importer | 6 from importer import Importer |
7 | 7 import os.path |
8 import utils | |
8 | 9 |
9 TABLE_NAME="floodmaps" | 10 TABLE_NAME="floodmaps" |
10 PATH="Hydrologie/UeSG" | 11 PATH="Hydrologie/UeSG" |
11 NAME="UESG" | 12 NAME="UESG" |
12 | 13 |
24 def getName(self): | 25 def getName(self): |
25 return NAME | 26 return NAME |
26 | 27 |
27 | 28 |
28 def isGeometryValid(self, geomType): | 29 def isGeometryValid(self, geomType): |
29 if geomType == 3 or geomType == 6: | 30 return geomType in [ogr.wkbMultiPolygon, |
30 return True | 31 ogr.wkbPolygon] |
31 else: | |
32 return False | |
33 | |
34 | 32 |
35 def getKind(self, path): | 33 def getKind(self, path): |
36 kind = 0 | 34 kind = 0 |
37 if path.find("Berechnung") > 0: | 35 if path.find("Berechnung") > 0: |
38 kind = kind + 100 | 36 kind = kind + 100 |
52 return kind | 50 return kind |
53 | 51 |
54 | 52 |
55 def createNewFeature(self, featureDef, feat, **args): | 53 def createNewFeature(self, featureDef, feat, **args): |
56 kind = self.getKind(args['path']) | 54 kind = self.getKind(args['path']) |
57 | |
58 newFeat = ogr.Feature(featureDef) | 55 newFeat = ogr.Feature(featureDef) |
59 newFeat.SetGeometry(feat.GetGeometryRef()) | 56 newFeat.SetGeometry(feat.GetGeometryRef()) |
60 | 57 |
61 if self.IsFieldSet(feat, "river_id"): | 58 if self.IsFieldSet(feat, "river_id"): |
62 riverId = feat.GetField(feat) | 59 riverId = feat.GetField(feat) |
81 if self.IsFieldSet(feat, "perimeter"): | 78 if self.IsFieldSet(feat, "perimeter"): |
82 perimeter = feat.GetFieldAsDouble("perimeter") | 79 perimeter = feat.GetFieldAsDouble("perimeter") |
83 else: | 80 else: |
84 perimeter = 0 | 81 perimeter = 0 |
85 | 82 |
83 if kind >= 200: | |
84 newFeat.SetField("source", | |
85 os.path.basename(os.path.dirname(args['path']))) | |
86 | |
87 | |
86 groupId = 2 | 88 groupId = 2 |
87 | 89 |
88 newFeat.SetField("river_id", riverId) | 90 newFeat.SetField("river_id", riverId) |
89 newFeat.SetField("diff", diff) | 91 newFeat.SetField("diff", diff) |
90 newFeat.SetField("count", count) | 92 newFeat.SetField("count", count) |
91 newFeat.SetField("area", area) | 93 newFeat.SetField("area", area) |
92 newFeat.SetField("perimeter", perimeter) | 94 newFeat.SetField("perimeter", perimeter) |
93 newFeat.SetField("kind", kind) | 95 newFeat.SetField("kind", kind) |
94 newFeat.SetField("name", args['name']) | 96 newFeat.SetField("name", args['name']) |
95 | 97 |
96 return newFeat | 98 return utils.convertToMultiPolygon(newFeat) |
97 | 99 |