comparison backend/contrib/shpimporter/fixpoints.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/fixpoints.py@c0ff14d03f1f
children
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 try:
2 from osgeo import ogr, osr
3 except ImportError:
4 import ogr, osr
5
6 from importer import Importer
7 import logging
8 logger = logging.getLogger("Fixpoints")
9 fixpoints_no_km_logged=False
10
11 TABLE_NAME="fixpoints"
12 PATH="Geodaesie/Festpunkte"
13 NAME="Fixpoints"
14
15
16 class Fixpoint(Importer):
17
18 def getPath(self, base):
19 return "%s/%s" % (base, PATH)
20
21
22 def getTablename(self):
23 return TABLE_NAME
24
25
26 def getName(self):
27 return NAME
28
29
30 def isGeometryValid(self, geomType):
31 return geomType == 1
32
33
34 def isShapeRelevant(self, name, path):
35 return True
36
37
38 def createNewFeature(self, featureDef, feat, **args):
39 newFeat = ogr.Feature(featureDef)
40
41 geometry = feat.GetGeometryRef()
42 geometry.SetCoordinateDimension(2)
43 newFeat.SetGeometry(geometry)
44
45 newFeat.SetField("name", args['name'])
46
47 if self.IsFieldSet(feat, "river_id"):
48 newFeat.SetField("river_id", feat.GetField("river_id"))
49 else:
50 newFeat.SetField("river_id", self.river_id)
51
52 if self.IsFieldSet(feat, "KM"):
53 newFeat.SetField("km", feat.GetFieldAsDouble("KM"))
54 elif self.IsFieldSet(feat, "ELBE_KM"):
55 newFeat.SetField("km", feat.GetFieldAsDouble("ELBE_KM"))
56 else:
57 global fixpoints_no_km_logged
58 if not fixpoints_no_km_logged:
59 logger.error("Could not find KM attribute")
60 fixpoints_no_km_logged = True
61 return None
62
63 if self.IsFieldSet(feat, "X"):
64 newFeat.SetField("x", feat.GetFieldAsDouble("X"))
65
66 if self.IsFieldSet(feat, "Y"):
67 newFeat.SetField("y", feat.GetFieldAsDouble("Y"))
68
69 if self.IsFieldSet(feat, "HPGP"):
70 newFeat.SetField("HPGP", feat.GetField("HPGP"))
71 elif self.IsFieldSet(feat, "ART"):
72 newFeat.SetField("HPGP", feat.GetField("ART"))
73
74 return newFeat
75

http://dive4elements.wald.intevation.org