Mercurial > dive4elements > river
comparison backend/contrib/shpimporter/km.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/km.py@a5291a126e24 |
children | 6a63456b99d9 |
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="river_axes_km" | |
9 PATH="Geodaesie/Flussachse+km" | |
10 NAME="KMS" | |
11 | |
12 | |
13 class KM(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 == 1 | |
29 | |
30 | |
31 def isShapeRelevant(self, name, path): | |
32 return name.lower() == "km" | |
33 | |
34 | |
35 def createNewFeature(self, featureDef, feat, **args): | |
36 newFeat = ogr.Feature(featureDef) | |
37 | |
38 geometry = feat.GetGeometryRef() | |
39 geometry.SetCoordinateDimension(2) | |
40 newFeat.SetGeometry(geometry) | |
41 | |
42 newFeat.SetField("name", args['name']) | |
43 | |
44 if self.IsFieldSet(feat, "river_id"): | |
45 newFeat.SetField("river_id", feat.GetField("river_id")) | |
46 else: | |
47 newFeat.SetField("river_id", self.river_id) | |
48 | |
49 if self.IsDoubleFieldSet(feat, "km"): | |
50 newFeat.SetField("km", feat.GetFieldAsDouble("km")) | |
51 elif self.IsDoubleFieldSet(feat, "KM"): | |
52 newFeat.SetField("km", feat.GetFieldAsDouble("KM")) | |
53 else: | |
54 return None | |
55 | |
56 return newFeat | |
57 |