comparison backend/contrib/shpimporter/jetties.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/jetties.py@91b14ade2149
children
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 # -*- coding: utf-8 -*-
2 import os
3
4 try:
5 from osgeo import ogr
6 except ImportError:
7 import ogr
8
9 from importer import Importer
10 import utils
11
12 import logging
13 logger = logging.getLogger("Jetties")
14
15 PATH="Geodaesie/Bauwerke"
16 NAME="Jetties"
17
18 # strings need to be lowercase
19 # buhnenkopf 0
20 # buhnenfuß 1
21 # buhnenwurzel 2
22 JETTY_KIND = {
23 "bkl" : 0,
24 "bkr" : 0,
25 "bk" : 0,
26 "bfl" : 1,
27 "bfr" : 1,
28 "bf" : 1,
29 "bwl" : 2,
30 "bwr" : 2,
31 "bw" : 2,
32 }
33
34 class Jetties(Importer):
35 fieldmap = {
36 "^station$" : "km",
37 "^km$" : "km",
38 "^wsv-km$" : "km",
39 "^z$" : "z",
40 "^H[oeö]{0,2}he$" : "z",
41 "^m+NHN$" : "z",
42 }
43
44 def getPath(self, base):
45 return "%s/%s" % (base, PATH)
46
47 def getTablename(self):
48 return "jetties"
49
50 def getName(self):
51 return "JETTIES"
52
53 def isGeometryValid(self, geomType):
54 return geomType == ogr.wkbPoint or geomType == ogr.wkbPoint25D
55
56 def isShapeRelevant(self, name, path):
57 if not path.endswith("Buhnen.shp"):
58 return False
59 shp = ogr.Open(path)
60 return self.isGeometryValid(shp.GetLayerByName(name).GetGeomType())
61
62 def createNewFeature(self, featureDef, feat, **args):
63 newFeat = ogr.Feature(featureDef)
64 geometry = feat.GetGeometryRef()
65 geometry.SetCoordinateDimension(2)
66
67 self.copyFields(feat, newFeat, self.fieldmap)
68
69 newFeat.SetGeometry(geometry)
70
71 newFeat.SetField("river_id", self.river_id)
72
73 artname = self.searchField("^type$")
74 if self.IsFieldSet(feat, artname):
75 self.handled(artname)
76 kind_id = JETTY_KIND.get(feat.GetField(artname).lower())
77 if kind_id == None:
78 logger.warn("Unknown Type: %s" % \
79 feat.GetField(artname))
80 else:
81 newFeat.SetField("kind_id", kind_id)
82
83 return newFeat
84

http://dive4elements.wald.intevation.org