Mercurial > dive4elements > river
comparison backend/contrib/shpimporter/gauges.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/gauges.py@c5187ab9f571 |
children |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 try: | |
2 from osgeo import ogr | |
3 except ImportError: | |
4 import ogr | |
5 | |
6 from importer import Importer | |
7 | |
8 TABLE_NAME="gauge_location" | |
9 PATH="Hydrologie/Streckendaten" | |
10 NAME="Gauge locations" | |
11 | |
12 | |
13 class GaugeLocation(Importer): | |
14 | |
15 def getPath(self, base): | |
16 return "%s/%s" % (base, PATH) | |
17 | |
18 | |
19 def getTablename(self): | |
20 return TABLE_NAME | |
21 | |
22 | |
23 def getName(self): | |
24 return NAME | |
25 | |
26 | |
27 def isGeometryValid(self, geomType): | |
28 return geomType == 1 | |
29 | |
30 | |
31 def isShapeRelevant(self, name, path): | |
32 return True | |
33 | |
34 | |
35 def createNewFeature(self, featureDef, feat, **args): | |
36 newFeat = ogr.Feature(featureDef) | |
37 geometry = feat.GetGeometryRef() | |
38 geometry.SetCoordinateDimension(2) | |
39 | |
40 newFeat.SetGeometry(geometry) | |
41 | |
42 if self.IsFieldSet(feat, "river_id"): | |
43 newFeat.SetField("river_id", feat.GetField("river_id")) | |
44 else: | |
45 newFeat.SetField("river_id", self.river_id) | |
46 | |
47 if self.IsFieldSet(feat, "Name"): | |
48 newFeat.SetField("name", feat.GetField("name")) | |
49 elif self.IsFieldSet(feat, "MPNAAM"): | |
50 newFeat.SetField("name", feat.GetField("MPNAAM")) | |
51 else: | |
52 newFeat.SetField("name", args['name']) | |
53 | |
54 return newFeat | |
55 |