Mercurial > dive4elements > river
comparison flys-backend/contrib/shpimporter/hws.py @ 2862:998f1a7dcfde
New shape importers and schema modifications.
flys-backend/trunk@4345 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 May 2012 06:58:00 +0000 |
parents | |
children | 59ca5dab2782 |
comparison
equal
deleted
inserted
replaced
2861:b0132e1b9719 | 2862:998f1a7dcfde |
---|---|
1 import ogr | |
2 | |
3 from importer import Importer | |
4 | |
5 TABLE_NAME="hws" | |
6 PATH="Hydrologie/HW-Schutzanlagen" | |
7 | |
8 | |
9 class HWS(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 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, "TYP"): | |
40 newFeat.SetField("type", feat.GetField("TYP")) | |
41 | |
42 if self.IsFieldSet(feat, "Bauart"): | |
43 newFeat.SetField("hws_facility", feat.GetField("Bauart")) | |
44 | |
45 if self.IsFieldSet(feat, "Name"): | |
46 newFeat.SetField("name", feat.GetField("name")) | |
47 else: | |
48 newFeat.SetField("name", args['name']) | |
49 | |
50 return newFeat | |
51 |