comparison flys-backend/contrib/shpimporter/crosssectiontracks.py @ 2877:f0a67bc0e777 2.7

merged flys-backend/2.7
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:31 +0200
parents 6442b30d80ec
children 59ca5dab2782
comparison
equal deleted inserted replaced
2793:6310b1582f2d 2877:f0a67bc0e777
1 import ogr
2
3 from importer import Importer
4
5 TABLE_NAME="cross_section_tracks"
6 PATH="Geodaesie/Querprofile"
7
8
9 class CrosssectionTrack(Importer):
10
11 def getPath(self, base):
12 return "%s/%s" % (base, PATH)
13
14
15 def getTablename(self):
16 return TABLE_NAME
17
18
19 def isGeometryValid(self, geomType):
20 return geomType == 2
21
22
23 def isShapeRelevant(self, name, path):
24 return True
25
26
27 def createNewFeature(self, featureDef, feat, **args):
28 newFeat = ogr.Feature(featureDef)
29 newFeat.SetGeometry(feat.GetGeometryRef())
30 newFeat.SetField("name", args['name'])
31
32 if self.IsFieldSet(feat, "river_id"):
33 newFeat.SetField("river_id", feat.GetField("river_id"))
34 else:
35 newFeat.SetField("river_id", self.river_id)
36
37 if self.IsFieldSet(feat, "KILOMETER"):
38 newFeat.SetField("km", feat.GetFieldAsDouble("KILOMETER"))
39 elif self.IsFieldSet(feat, "KM"):
40 newFeat.SetField("km", feat.GetFieldAsDouble("KM"))
41 elif self.IsFieldSet(feat, "STATION"):
42 newFeat.SetField("km", feat.GetFieldAsDouble("STATION"))
43 else:
44 return None
45
46 if self.IsFieldSet(feat, "ELEVATION"):
47 newFeat.SetField("z", feat.GetFieldAsDouble("ELEVATION"))
48 else:
49 newFeat.SetField("z", 0)
50
51 return newFeat
52

http://dive4elements.wald.intevation.org