comparison backend/contrib/shpimporter/crosssectiontracks.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/crosssectiontracks.py@88e3473a3846
children
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
8 TABLE_NAME="cross_section_tracks"
9 PATH="Geodaesie/Querprofile"
10 NAME="Crosssections"
11
12
13 class CrosssectionTrack(Importer):
14
15 def getPath(self, base):
16 return "%s/%s" % (base, PATH)
17
18
19 def getTablename(self):
20 return TABLE_NAME
21
22
23 def getName(self):
24 return NAME
25
26
27 def isGeometryValid(self, geomType):
28 return geomType == 2
29
30
31 def isShapeRelevant(self, name, path):
32 return True
33
34
35 def createNewFeature(self, featureDef, feat, **args):
36 newFeat = ogr.Feature(featureDef)
37 newFeat.SetGeometry(feat.GetGeometryRef())
38 newFeat.SetField("name", args['name'])
39
40 if args['path'].lower().endswith("/qps.shp") and \
41 not "sonstige" in args['path'].lower():
42 newFeat.SetField("kind_id", 1) # offical
43 else:
44 newFeat.SetField("kind_id", 0) # misc
45
46 if self.IsFieldSet(feat, "river_id"):
47 newFeat.SetField("river_id", feat.GetField("river_id"))
48 else:
49 newFeat.SetField("river_id", self.river_id)
50
51 if self.IsFieldSet(feat, "KILOMETER"):
52 newFeat.SetField("km", feat.GetFieldAsDouble("KILOMETER"))
53 elif self.IsFieldSet(feat, "KM"):
54 newFeat.SetField("km", feat.GetFieldAsDouble("KM"))
55 elif self.IsFieldSet(feat, "STATION"):
56 newFeat.SetField("km", feat.GetFieldAsDouble("STATION"))
57 else:
58 return None
59
60 if self.IsFieldSet(feat, "ELEVATION"):
61 newFeat.SetField("z", feat.GetFieldAsDouble("ELEVATION"))
62 else:
63 newFeat.SetField("z", 0)
64
65 return newFeat
66

http://dive4elements.wald.intevation.org