Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/uesg.py @ 3800:69d19995bc3c 2.9.1
merged flys-backend/2.9.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:48 +0200 |
parents | 59ca5dab2782 |
children | f1c01fecf194 |
comparison
equal
deleted
inserted
replaced
3786:4adc35aa655c | 3800:69d19995bc3c |
---|---|
1 import ogr | |
2 | |
3 from importer import Importer | |
4 | |
5 | |
6 TABLE_NAME="floodmaps" | |
7 PATH="Hydrologie/UeSG/Berechnung" | |
8 NAME="UESG" | |
9 | |
10 | |
11 class UESG(Importer): | |
12 | |
13 def getPath(self, base): | |
14 return "%s/%s" % (base, PATH) | |
15 | |
16 | |
17 def getTablename(self): | |
18 return TABLE_NAME | |
19 | |
20 | |
21 def getName(self): | |
22 return NAME | |
23 | |
24 | |
25 def isGeometryValid(self, geomType): | |
26 if geomType == 3 or geomType == 6: | |
27 return True | |
28 else: | |
29 return False | |
30 | |
31 | |
32 def getKind(self, path): | |
33 kind = 0 | |
34 if path.find("Berechnung") > 0: | |
35 kind = kind + 100 | |
36 | |
37 if path.find("Aktuell") > 0: | |
38 kind = kind + 10 | |
39 else: | |
40 kind = kind + 20 | |
41 | |
42 if path.find("Land") > 0: | |
43 kind = kind + 2 | |
44 else: | |
45 kind = kind + 1 | |
46 else: | |
47 kind = kind + 200 | |
48 | |
49 return kind | |
50 | |
51 | |
52 def createNewFeature(self, featureDef, feat, **args): | |
53 kind = self.getKind(args['path']) | |
54 | |
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 groupId = 2 | |
84 | |
85 newFeat.SetField("river_id", riverId) | |
86 newFeat.SetField("diff", diff) | |
87 newFeat.SetField("count", count) | |
88 newFeat.SetField("area", area) | |
89 newFeat.SetField("perimeter", perimeter) | |
90 newFeat.SetField("kind", kind) | |
91 newFeat.SetField("name", args['name']) | |
92 | |
93 return newFeat | |
94 |