Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/fixpoints.py @ 3689:c938e568c4a2 2.9
merged flys-backend/2.9
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:44 +0200 |
parents | 59ca5dab2782 |
children | f1c01fecf194 |
comparison
equal
deleted
inserted
replaced
3651:06a65baae494 | 3689:c938e568c4a2 |
---|---|
1 import ogr, osr | |
2 | |
3 from importer import Importer | |
4 | |
5 TABLE_NAME="fixpoints" | |
6 PATH="Geodaesie/Festpunkte" | |
7 NAME="Fixpoints" | |
8 | |
9 | |
10 class Fixpoint(Importer): | |
11 | |
12 def getPath(self, base): | |
13 return "%s/%s" % (base, PATH) | |
14 | |
15 | |
16 def getTablename(self): | |
17 return TABLE_NAME | |
18 | |
19 | |
20 def getName(self): | |
21 return NAME | |
22 | |
23 | |
24 def isGeometryValid(self, geomType): | |
25 return geomType == 1 | |
26 | |
27 | |
28 def isShapeRelevant(self, name, path): | |
29 return True | |
30 | |
31 | |
32 def createNewFeature(self, featureDef, feat, **args): | |
33 newFeat = ogr.Feature(featureDef) | |
34 geometry = feat.GetGeometryRef() | |
35 | |
36 newFeat.SetGeometry(geometry) | |
37 newFeat.SetField("name", args['name']) | |
38 | |
39 if self.IsFieldSet(feat, "river_id"): | |
40 newFeat.SetField("river_id", feat.GetField("river_id")) | |
41 else: | |
42 newFeat.SetField("river_id", self.river_id) | |
43 | |
44 if self.IsFieldSet(feat, "KM"): | |
45 newFeat.SetField("km", feat.GetFieldAsDouble("KM")) | |
46 elif self.IsFieldSet(feat, "ELBE_KM"): | |
47 newFeat.SetField("km", feat.GetFieldAsDouble("ELBE_KM")) | |
48 else: | |
49 return None | |
50 | |
51 if self.IsFieldSet(feat, "X"): | |
52 newFeat.SetField("x", feat.GetFieldAsDouble("X")) | |
53 | |
54 if self.IsFieldSet(feat, "Y"): | |
55 newFeat.SetField("y", feat.GetFieldAsDouble("Y")) | |
56 | |
57 if self.IsFieldSet(feat, "HPGP"): | |
58 newFeat.SetField("HPGP", feat.GetField("HPGP")) | |
59 | |
60 return newFeat | |
61 |