comparison backend/contrib/shpimporter/uesg.py @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-backend/contrib/shpimporter/uesg.py@3f35d9db48c1
children 249b8766a178
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 try:
2 from osgeo import ogr
3 except ImportError:
4 import ogr
5
6 from importer import Importer
7 import os.path
8 import utils
9
10 TABLE_NAME="floodmaps"
11 PATH="Hydrologie/UeSG"
12 NAME="UESG"
13
14
15 class UESG(Importer):
16
17 def getPath(self, base):
18 return "%s/%s" % (base, PATH)
19
20
21 def getTablename(self):
22 return TABLE_NAME
23
24
25 def getName(self):
26 return NAME
27
28
29 def isGeometryValid(self, geomType):
30 return geomType in [ogr.wkbMultiPolygon,
31 ogr.wkbPolygon]
32
33 def getKind(self, path):
34 kind = 0
35 if path.find("Berechnung") > 0:
36 kind = kind + 100
37
38 if path.find("Aktuell") > 0:
39 kind = kind + 10
40 else:
41 kind = kind + 20
42
43 if path.find("Bundesl") > 0:
44 kind = kind + 2
45 else:
46 kind = kind + 1
47 else:
48 kind = kind + 200
49
50 return kind
51
52
53 def createNewFeature(self, featureDef, feat, **args):
54 kind = self.getKind(args['path'])
55 newFeat = ogr.Feature(featureDef)
56 newFeat.SetGeometry(feat.GetGeometryRef())
57
58 if self.IsFieldSet(feat, "river_id"):
59 riverId = feat.GetField(feat)
60 else:
61 riverId = self.river_id
62
63 if self.IsFieldSet(feat, "diff"):
64 diff = feat.GetFieldAsDouble("diff")
65 else:
66 diff = 0
67
68 if self.IsFieldSet(feat, "count"):
69 count = feat.GetFieldAsInteger("count")
70 else:
71 count = 0
72
73 if self.IsFieldSet(feat, "area"):
74 area = feat.GetFieldAsDouble("area")
75 else:
76 area = 0
77
78 if self.IsFieldSet(feat, "perimeter"):
79 perimeter = feat.GetFieldAsDouble("perimeter")
80 else:
81 perimeter = 0
82
83 if kind >= 200:
84 newFeat.SetField("source",
85 os.path.basename(os.path.dirname(args['path'])))
86
87
88 groupId = 2
89
90 newFeat.SetField("river_id", riverId)
91 newFeat.SetField("diff", diff)
92 newFeat.SetField("count", count)
93 newFeat.SetField("area", area)
94 newFeat.SetField("perimeter", perimeter)
95 newFeat.SetField("kind", kind)
96 newFeat.SetField("name", args['name'])
97
98 return utils.convertToMultiPolygon(newFeat)
99

http://dive4elements.wald.intevation.org