annotate flys-backend/contrib/shpimporter/hws.py @ 4932:60b026b4340e dami

Importer: Classify hochufer as Deich
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 31 Jan 2013 12:06:12 +0100
parents b457532dae63
children 03989fa957fc
rev   line source
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
1 # -*- coding: utf-8 -*-
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
2 import os
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
3
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
4 try:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
5 from osgeo import ogr
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
6 except ImportErrror:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
7 import ogr
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 from importer import Importer
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
10 import utils
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 PATH="Hydrologie/HW-Schutzanlagen"
3654
59ca5dab2782 Shape importer: use python's OptionParse to read user specific configuration from command line.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2862
diff changeset
13 NAME="HWS"
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
15 # Keep in sync with hws_kinds table:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
16 HWS_KIND = {
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
17 "Durchlass" : 1,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
18 "Damm" : 2,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
19 "Deich" : 2,
4932
60b026b4340e Importer: Classify hochufer as Deich
Andre Heinecke <aheinecke@intevation.de>
parents: 4884
diff changeset
20 "Hochufer" : 2,
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
21 "Graben" : 3,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
22 }
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
24 # Keep in sync with fed_states table:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
25 FED_STATES = {
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
26 "Bayern" : 1,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
27 "Hessen" : 2,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
28 "Niedersachsen" : 3,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
29 "Nordrhein-Westfalen" : 4,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
30 "Rheinland-Pfalz" : 5,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
31 "Saarland" : 6,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
32 "Schleswig-Holstein" : 7,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
33 "Brandenburg" : 8,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
34 "Mecklenburg-Vorpommern" : 9,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
35 "Thüringen" : 10,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
36 "Baden-Württemberg" : 11,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
37 "Sachsen-Anhalt" : 12,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
38 "Sachsen" : 13,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
39 "Berlin" : 14,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
40 "Bremen" : 15,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
41 "Hamburg" : 16,
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
42 }
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
43
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
44 class HWSLines(Importer):
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 def getPath(self, base):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 return "%s/%s" % (base, PATH)
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 def getTablename(self):
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
50 return "hws_lines"
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
3654
59ca5dab2782 Shape importer: use python's OptionParse to read user specific configuration from command line.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2862
diff changeset
52 def getName(self):
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
53 return "HWS_LINES"
3654
59ca5dab2782 Shape importer: use python's OptionParse to read user specific configuration from command line.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2862
diff changeset
54
2862
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 def isGeometryValid(self, geomType):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 return geomType == 2
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 def isShapeRelevant(self, name, path):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 return True
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 def createNewFeature(self, featureDef, feat, **args):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 newFeat = ogr.Feature(featureDef)
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 geometry = feat.GetGeometryRef()
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 geometry.SetCoordinateDimension(2)
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 newFeat.SetGeometry(geometry)
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 if self.IsFieldSet(feat, "river_id"):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 newFeat.SetField("river_id", feat.GetField("river_id"))
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 else:
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 newFeat.SetField("river_id", self.river_id)
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 if self.IsFieldSet(feat, "TYP"):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 newFeat.SetField("type", feat.GetField("TYP"))
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 if self.IsFieldSet(feat, "Bauart"):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 newFeat.SetField("hws_facility", feat.GetField("Bauart"))
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 if self.IsFieldSet(feat, "Name"):
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 newFeat.SetField("name", feat.GetField("name"))
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 else:
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 newFeat.SetField("name", args['name'])
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 return newFeat
998f1a7dcfde New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
86 class HWSPoints(Importer):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
87 fieldmap = {
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
88 "Name" : "name",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
89 "Quelle" : "source",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
90 "Anmerkung" : "description",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
91 "Stand" : "status_date",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
92 "Verband" : "agency",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
93 "Deich_KM" : "dike_km",
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
94 "Bereich" : "range",
4881
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
95 "Höhe_SOLL" : "z_target",
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
96 "WSP_BfG100" : "rated_level",
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
97 "Hoehe_IST" : "z",
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
98 }
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
99
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
100 def getPath(self, base):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
101 return "%s/%s" % (base, PATH)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
102
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
103 def getTablename(self):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
104 return "hws_points"
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
105
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
106 def getName(self):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
107 return "HWS_POINTS"
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
108
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
109 def isGeometryValid(self, geomType):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
110 return geomType == 1
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
111
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
112 def isShapeRelevant(self, name, path):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
113 if "punkte" in os.path.basename(path).lower():
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
114 return True
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
115 else:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
116 return False
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
117
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
118 def createNewFeature(self, featureDef, feat, **args):
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
119 newFeat = ogr.Feature(featureDef)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
120 geometry = feat.GetGeometryRef()
4881
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
121 geometry.SetCoordinateDimension(2)
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
122
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
123 self.copyFields(feat, newFeat, self.fieldmap)
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
124
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
125 newFeat.SetGeometry(geometry)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
126
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
127 newFeat.SetFID(feat.GetFID())
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
128
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
129 newFeat.SetField("ogr_fid", feat.GetFID())
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
130
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
131 if self.IsFieldSet(feat, "Art"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
132 self.handled("Art")
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
133 kind_id = HWS_KIND.get(feat.GetField("Art"))
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
134 if not kind_id:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
135 print ("Unbekannte Art: %s" % \
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
136 feat.GetField("Art"))
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
137 else:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
138 newFeat.SetField("kind_id", kind_id)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
139
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
140 if self.IsFieldSet(feat, "Bundesland"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
141 self.handled("Bundesland")
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
142 fed_id = FED_STATES.get(feat.GetField("Bundesland"))
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
143
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
144 if not fed_id:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
145 print ("Unbekanntes Bundesland: %s" % \
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
146 feat.GetField("Bundesland"))
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
147 else:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
148 newFeat.SetField("fed_state_id", fed_id)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
149
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
150 if self.IsFieldSet(feat, "river_id"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
151 self.handled("river_id")
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
152 if feat.GetField("river_id") != self.river_id:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
153 print ("River_id mismatch between shapefile and"
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
154 " importer parameter.")
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
155 newFeat.SetField("river_id", feat.GetField("river_id"))
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
156 else:
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
157 newFeat.SetField("river_id", self.river_id)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
158
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
159 if self.IsFieldSet(feat, "Ufer"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
160 self.handled("Ufer")
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
161 shoreString = feat.GetField("Ufer")
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
162 if "links" in shoreString.lower():
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
163 newFeat.SetField("shore_side", True)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
164 elif "rechts" in shoreString.lower():
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
165 newFeat.SetField("shore_side", False)
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
166
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
167 if not self.IsFieldSet(feat, "Name"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
168 self.handled("Name")
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
169 newFeat.SetField("name", args['name'])
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
170
4881
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
171 if self.IsFieldSet(feat, "offiziell"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
172 self.handled("offiziell")
4881
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
173 offiziell = feat.GetField("offiziell")
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
174 if offiziell == "1" or offiziell == 1:
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
175 newFeat.SetField("offiziell", True)
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
176 else:
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
177 newFeat.SetField("offiziell", False)
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
178
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
179 if self.IsFieldSet(newFeat, "z") and \
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
180 self.IsFieldSet(newFeat, "rated_level"):
4884
b457532dae63 Importer: Move copy fields into importer class and track imported/unimported fields
Andre Heinecke <aheinecke@intevation.de>
parents: 4881
diff changeset
181 self.handled("Freibord_m")
4881
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
182 z = newFeat.GetFieldAsDouble("z")
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
183 rl = newFeat.GetFieldAsDouble("rated_level")
9b03cf6b85c9 (importer) calculate freeboard and expect sql
Andre Heinecke <aheinecke@intevation.de>
parents: 4875
diff changeset
184 newFeat.SetField("freeboard", z - rl)
4875
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
185
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
186 return newFeat
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
187
37fa93f65971 (importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents: 3654
diff changeset
188

http://dive4elements.wald.intevation.org