Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/catchments.py @ 3471:e4250c6e1538 2.8.1
merged flys-backend/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:40 +0200 |
parents | 998f1a7dcfde |
children | 59ca5dab2782 |
comparison
equal
deleted
inserted
replaced
3468:f37e7e8907cb | 3471:e4250c6e1538 |
---|---|
1 import ogr | |
2 | |
3 from importer import Importer | |
4 | |
5 TABLE_NAME="catchment" | |
6 PATH="Hydrologie/Einzugsgebiet" | |
7 | |
8 | |
9 class Catchment(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 == 3 or geomType == 6 | |
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 geometry = feat.GetGeometryRef() | |
30 geometry.SetCoordinateDimension(2) | |
31 | |
32 newFeat.SetGeometry(geometry) | |
33 | |
34 if self.IsFieldSet(feat, "river_id"): | |
35 newFeat.SetField("river_id", feat.GetField("river_id")) | |
36 else: | |
37 newFeat.SetField("river_id", self.river_id) | |
38 | |
39 if self.IsFieldSet(feat, "Name"): | |
40 newFeat.SetField("name", feat.GetField("name")) | |
41 else: | |
42 newFeat.SetField("name", args['name']) | |
43 | |
44 if self.IsFieldSet(feat, "AREA"): | |
45 newFeat.SetField("area", feat.GetField("area")) | |
46 | |
47 return newFeat | |
48 |