Mercurial > dive4elements > river
annotate flys-backend/contrib/shpimporter/hws.py @ 4875:37fa93f65971
(importer) Add classes for hws_points and hws_lines
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 25 Jan 2013 10:41:59 +0100 |
parents | 59ca5dab2782 |
children | 9b03cf6b85c9 |
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, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
20 "Graben" : 3, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
21 } |
2862
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
4875
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
23 # 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
|
24 FED_STATES = { |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
25 "Bayern" : 1, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
26 "Hessen" : 2, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
27 "Niedersachsen" : 3, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
28 "Nordrhein-Westfalen" : 4, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
29 "Rheinland-Pfalz" : 5, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
30 "Saarland" : 6, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
31 "Schleswig-Holstein" : 7, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
32 "Brandenburg" : 8, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
33 "Mecklenburg-Vorpommern" : 9, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
34 "Thüringen" : 10, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
35 "Baden-Württemberg" : 11, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
36 "Sachsen-Anhalt" : 12, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
37 "Sachsen" : 13, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
38 "Berlin" : 14, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
39 "Bremen" : 15, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
40 "Hamburg" : 16, |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
41 } |
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 class HWSLines(Importer): |
2862
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 def getPath(self, base): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 return "%s/%s" % (base, PATH) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 def getTablename(self): |
4875
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
49 return "hws_lines" |
2862
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
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
|
51 def getName(self): |
4875
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
52 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
|
53 |
2862
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 def isGeometryValid(self, geomType): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 return geomType == 2 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 def isShapeRelevant(self, name, path): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 return True |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 def createNewFeature(self, featureDef, feat, **args): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 newFeat = ogr.Feature(featureDef) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 geometry = feat.GetGeometryRef() |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 geometry.SetCoordinateDimension(2) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 newFeat.SetGeometry(geometry) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 if self.IsFieldSet(feat, "river_id"): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 newFeat.SetField("river_id", feat.GetField("river_id")) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 else: |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 newFeat.SetField("river_id", self.river_id) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 if self.IsFieldSet(feat, "TYP"): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 newFeat.SetField("type", feat.GetField("TYP")) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 if self.IsFieldSet(feat, "Bauart"): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 newFeat.SetField("hws_facility", feat.GetField("Bauart")) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 if self.IsFieldSet(feat, "Name"): |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 newFeat.SetField("name", feat.GetField("name")) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 else: |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 newFeat.SetField("name", args['name']) |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 return newFeat |
998f1a7dcfde
New shape importers and schema modifications.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
4875
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
85 class HWSPoints(Importer): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
86 fieldmap = { |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
87 "Name" : "name", |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
88 "Freibord_m" : "freeboard", |
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", |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
95 } |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
96 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
97 def getPath(self, base): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
98 return "%s/%s" % (base, PATH) |
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 getTablename(self): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
101 return "hws_points" |
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 getName(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 isGeometryValid(self, geomType): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
107 return geomType == 1 |
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 isShapeRelevant(self, name, path): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
110 print "Checking relevancy of %s" % path |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
111 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
|
112 return True |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
113 else: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
114 return False |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
115 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
116 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
|
117 newFeat = ogr.Feature(featureDef) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
118 geometry = feat.GetGeometryRef() |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
119 geometry.SetCoordinateDimension(3) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
120 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
121 utils.copyFields(feat, newFeat, self.fieldmap) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
122 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
123 newFeat.SetGeometry(geometry) |
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.SetFID(feat.GetFID()) |
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.SetField("ogr_fid", 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 if self.IsFieldSet(feat, "Art"): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
130 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
|
131 if not kind_id: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
132 print ("Unbekannte Art: %s" % \ |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
133 feat.GetField("Art")) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
134 else: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
135 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
|
136 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
137 if self.IsFieldSet(feat, "Bundesland"): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
138 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
|
139 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
140 if not fed_id: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
141 print ("Unbekanntes Bundesland: %s" % \ |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
142 feat.GetField("Bundesland")) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
143 else: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
144 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
|
145 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
146 if self.IsFieldSet(feat, "river_id"): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
147 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
|
148 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
|
149 " importer parameter.") |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
150 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
|
151 else: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
152 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
|
153 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
154 if self.IsFieldSet(feat, "Ufer"): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
155 shoreString = feat.GetField("Ufer") |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
156 if "links" in shoreString.lower(): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
157 newFeat.SetField("shore_side", True) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
158 elif "rechts" in shoreString.lower(): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
159 newFeat.SetField("shore_side", False) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
160 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
161 if not self.IsFieldSet(feat, "Name"): |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
162 newFeat.SetField("name", args['name']) |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
163 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
164 # TODO: |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
165 # offical |
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 return newFeat |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
168 |
37fa93f65971
(importer) Add classes for hws_points and hws_lines
Andre Heinecke <aheinecke@intevation.de>
parents:
3654
diff
changeset
|
169 |