comparison flys-backend/contrib/shpimporter/hws.py @ 4881:9b03cf6b85c9

(importer) calculate freeboard and expect sql
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 25 Jan 2013 15:37:43 +0100
parents 37fa93f65971
children b457532dae63
comparison
equal deleted inserted replaced
4880:a5669cc576b4 4881:9b03cf6b85c9
83 return newFeat 83 return newFeat
84 84
85 class HWSPoints(Importer): 85 class HWSPoints(Importer):
86 fieldmap = { 86 fieldmap = {
87 "Name" : "name", 87 "Name" : "name",
88 "Freibord_m" : "freeboard",
89 "Quelle" : "source", 88 "Quelle" : "source",
90 "Anmerkung" : "description", 89 "Anmerkung" : "description",
91 "Stand" : "status_date", 90 "Stand" : "status_date",
92 "Verband" : "agency", 91 "Verband" : "agency",
93 "Deich_KM" : "dike_km", 92 "Deich_KM" : "dike_km",
94 "Bereich" : "range", 93 "Bereich" : "range",
94 "Höhe_SOLL" : "z_target",
95 "WSP_BfG100" : "rated_level",
96 "Hoehe_IST" : "z",
95 } 97 }
96 98
97 def getPath(self, base): 99 def getPath(self, base):
98 return "%s/%s" % (base, PATH) 100 return "%s/%s" % (base, PATH)
99 101
105 107
106 def isGeometryValid(self, geomType): 108 def isGeometryValid(self, geomType):
107 return geomType == 1 109 return geomType == 1
108 110
109 def isShapeRelevant(self, name, path): 111 def isShapeRelevant(self, name, path):
110 print "Checking relevancy of %s" % path
111 if "punkte" in os.path.basename(path).lower(): 112 if "punkte" in os.path.basename(path).lower():
112 return True 113 return True
113 else: 114 else:
114 return False 115 return False
115 116
116 def createNewFeature(self, featureDef, feat, **args): 117 def createNewFeature(self, featureDef, feat, **args):
117 newFeat = ogr.Feature(featureDef) 118 newFeat = ogr.Feature(featureDef)
118 geometry = feat.GetGeometryRef() 119 geometry = feat.GetGeometryRef()
119 geometry.SetCoordinateDimension(3) 120 geometry.SetCoordinateDimension(2)
120 121
121 utils.copyFields(feat, newFeat, self.fieldmap) 122 utils.copyFields(feat, newFeat, self.fieldmap)
122 123
123 newFeat.SetGeometry(geometry) 124 newFeat.SetGeometry(geometry)
124 125
159 newFeat.SetField("shore_side", False) 160 newFeat.SetField("shore_side", False)
160 161
161 if not self.IsFieldSet(feat, "Name"): 162 if not self.IsFieldSet(feat, "Name"):
162 newFeat.SetField("name", args['name']) 163 newFeat.SetField("name", args['name'])
163 164
164 # TODO: 165 if self.IsFieldSet(feat, "offiziell"):
165 # offical 166 offiziell = feat.GetField("offiziell")
167 if offiziell == "1" or offiziell == 1:
168 newFeat.SetField("offiziell", True)
169 else:
170 newFeat.SetField("offiziell", False)
171
172 if self.IsFieldSet(newFeat, "z") and \
173 self.IsFieldSet(newFeat, "rated_level"):
174 z = newFeat.GetFieldAsDouble("z")
175 rl = newFeat.GetFieldAsDouble("rated_level")
176 newFeat.SetField("freeboard", z - rl)
166 177
167 return newFeat 178 return newFeat
168 179
169 180

http://dive4elements.wald.intevation.org