Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/lines.py @ 2853:bd9e76e0b55d
Improved the python shapefile importer.
flys-backend/trunk@4313 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 27 Apr 2012 06:39:12 +0000 |
parents | |
children | b0132e1b9719 |
comparison
equal
deleted
inserted
replaced
2852:875a87b8489f | 2853:bd9e76e0b55d |
---|---|
1 import ogr | |
2 | |
3 from importer import Importer | |
4 | |
5 TABLE_NAME="lines" | |
6 PATH="Geodaesie/Linien" | |
7 | |
8 | |
9 class Line(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 | |
31 if self.IsFieldSet(feat, "river_id"): | |
32 newFeat.SetField("river_id", feat.GetField("river_id")) | |
33 else: | |
34 newFeat.SetField("river_id", self.river_id) | |
35 | |
36 if self.IsFieldSet(feat, "TYP"): | |
37 newFeat.SetField("kind", feat.GetFieldAsDouble("TYP")) | |
38 else: | |
39 return None | |
40 | |
41 if self.IsFieldSet(feat, "Z"): | |
42 newFeat.SetField("z", feat.GetFieldAsDouble("Z")) | |
43 else: | |
44 newFeat.SetField("z", 0) | |
45 | |
46 return newFeat | |
47 |