source: trunk/data/konvert/postnas_0.6/atkis_rp_rendering/processing/kacheln.sh @ 147

Revision 114, 6.0 KB checked in by tobias.dick, 12 years ago (diff)

Initiale Dateien um per PostNAS importierte ATKIS Daten für ein Online Rendering aufzubereiten. Die Scripte erzeugen pro darzustellender Objektart bis zu 6 Generalisierungsstufen. Die Parameter können in den Shellscripten angepasst werden. Die Visualisierung kann z.B. über den Mapserver erfolgen. Der Bildaufbau sollte in jeder Stufe unter einer Sekunde benötigen. Die Laufzeit der Scripte beträgt auf einem single core 2.0GHz Prozessor ca 2.5 Stunden.

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3source psql.conf
4
5# Die zu verarbeitendenden Tabellen
6# gefolgt vom entsprechenden Geometrietyp
7#
8#       TODO: saubere Array-Struktur ...
9
10#       PROBLEM: unterschiedliche (Anzahl) Spalten:
11#       wenn alles pauschal prozessiert wird,
12#       werden alle Spalten abgesehen von 'wkb_geometry' und
13#       'widmung' nicht berÃŒcksichtigt!
14#       Workaround: auxfields...
15
16tables=('map_wald_g0')
17geomtype=('ST_Polygon')
18auxfields=('')
19
20tables+=('map_wald_g1')
21geomtype+=('ST_Polygon')
22auxfields+=('')
23
24tables+=('map_wald_g2')
25geomtype+=('ST_Polygon')
26auxfields+=('')
27
28tables+=('map_wald_g3')
29geomtype+=('ST_Polygon')
30auxfields+=('')
31
32tables+=('map_wald_g4')
33geomtype+=('ST_Polygon')
34auxfields+=('')
35
36tables+=('map_wald_g5')
37geomtype+=('ST_Polygon')
38auxfields+=('')
39
40tables+=('map_wald_g6')
41geomtype+=('ST_Polygon')
42auxfields+=('')
43
44tables+=('map_fluesse_g0')
45geomtype+=('ST_Polygon')
46auxfields+=('')
47
48tables+=('map_fluesse_g1')
49geomtype+=('ST_Polygon')
50auxfields+=('')
51
52tables+=('map_fluesse_g2')
53geomtype+=('ST_Polygon')
54auxfields+=('')
55
56tables+=('map_fluesse_g3')
57geomtype+=('ST_Polygon')
58auxfields+=('')
59
60tables+=('map_fluesse_g4')
61geomtype+=('ST_Polygon')
62auxfields+=('')
63
64tables+=('map_fluesse_g5')
65geomtype+=('ST_Polygon')
66auxfields+=('')
67
68tables+=('map_fluesse_g6')
69geomtype+=('ST_Polygon')
70auxfields+=('')
71
72tables+=('map_baeche_g0')
73geomtype+=('ST_LineString')
74auxfields+=('')
75
76tables+=('map_baeche_g1')
77geomtype+=('ST_LineString')
78auxfields+=('')
79
80tables+=('map_baeche_g2')
81geomtype+=('ST_LineString')
82auxfields+=('')
83
84tables+=('map_baeche_g3')
85geomtype+=('ST_LineString')
86auxfields+=('')
87
88tables+=('map_baeche_g4')
89geomtype+=('ST_LineString')
90auxfields+=('')
91
92tables+=('map_baeche_g5')
93geomtype+=('ST_LineString')
94auxfields+=('')
95
96tables+=('map_baeche_g6')
97geomtype+=('ST_LineString')
98auxfields+=('')
99
100tables+=('map_strasse_g0')
101geomtype+=('ST_LineString')
102auxfields+=('name_, bezeichnung,')
103
104tables+=('map_strasse_g1')
105geomtype+=('ST_LineString')
106auxfields+=('name_, bezeichnung,')
107
108tables+=('map_strasse_g2')
109geomtype+=('ST_LineString')
110auxfields+=('name_, bezeichnung,')
111
112tables+=('map_strasse_g3')
113geomtype+=('ST_LineString')
114auxfields+=('name_, bezeichnung,')
115
116tables+=('map_strasse_g4')
117geomtype+=('ST_LineString')
118auxfields+=('name_, bezeichnung,')
119
120tables+=('map_strasse_g5')
121geomtype+=('ST_LineString')
122auxfields+=('name_, bezeichnung,')
123
124tables+=('map_strasse_g6')
125geomtype+=('ST_LineString')
126auxfields+=('name_, bezeichnung,')
127
128tables+=('map_wege_g0')
129geomtype+=('ST_LineString')
130auxfields+=('')
131
132tables+=('map_wege_g1')
133geomtype+=('ST_LineString')
134auxfields+=('')
135
136tables+=('map_wege_g2')
137geomtype+=('ST_LineString')
138auxfields+=('')
139
140
141
142
143# Es können auch noch andere DatensÀtze hier geclippt werden.
144# Einfach danach auch das $cells-Array entsprechend erweitern.
145
146# Die zu verwendenden Kacheln: g0=2km, g1=5km, g2=10km, g3=25km, g4=50km
147cells=('map_landesflaeche_g0')  #wald_g0
148cells+=('map_landesflaeche_g0') #wald_g1
149cells+=('map_landesflaeche_g1') #wald_g2
150cells+=('map_landesflaeche_g1') #wald_g3
151cells+=('map_landesflaeche_g2') #wald_g4
152cells+=('map_landesflaeche_g3') #wald_g5
153cells+=('map_landesflaeche_g4') #wald_g6
154
155cells+=('map_landesflaeche_g0') #fluesse_g0
156cells+=('map_landesflaeche_g0') #fluesse_g1
157cells+=('map_landesflaeche_g1') #fluesse_g2
158cells+=('map_landesflaeche_g1') #fluesse_g3
159cells+=('map_landesflaeche_g2') #fluesse_g4
160cells+=('map_landesflaeche_g3') #fluesse_g5
161cells+=('map_landesflaeche_g4') #fluesse_g6
162
163cells+=('map_landesflaeche_g0') #baeche_g0
164cells+=('map_landesflaeche_g0') #baeche_g1
165cells+=('map_landesflaeche_g1') #baeche_g2
166cells+=('map_landesflaeche_g1') #baeche_g3
167cells+=('map_landesflaeche_g2') #baeche_g4
168cells+=('map_landesflaeche_g3') #baeche_g5
169cells+=('map_landesflaeche_g4') #baeche_g6
170
171cells+=('map_landesflaeche_g0') #strasse_g0
172cells+=('map_landesflaeche_g0') #strasse_g1
173cells+=('map_landesflaeche_g1') #strasse_g2
174cells+=('map_landesflaeche_g1') #strasse_g3
175cells+=('map_landesflaeche_g2') #strasse_g4
176cells+=('map_landesflaeche_g3') #strasse_g5
177cells+=('map_landesflaeche_g4') #strasse_g6
178
179cells+=('map_landesflaeche_g0') #wege_g0
180cells+=('map_landesflaeche_g0') #wege_g1
181cells+=('map_landesflaeche_g1') #wege_g2
182####################################################################
183#                                       ab hier nichts mehr Àndern
184#                               do not change anything below this line.
185####################################################################
186
187# Festlegen der Datenbank-Verbindung
188echo "Teste PostGIS-Verbindung zu $dbname auf $dbuser@$dbhost:$dbport:"
189if [ $dbpass == false ]; then
190        CONN="psql --user=$dbuser $dbname --host=$dbhost --port=$dbport -w"
191else   
192        CONN="psql --user=$dbuser $dbname --host=$dbhost --port=$dbport --password=$dbpass"
193fi
194
195
196
197
198#### SCHLEIFE ÃŒber tables ####
199echo ${#tables[@]}
200for (( x=0 ; x < ${#tables[@]}; x++ ))
201do
202        echo -e "\n-----------------------------------------------------------------"
203        echo "Prozessiere ${tables[$x]}:"
204       
205        QUERY="${CONN} -c 'SELECT true FROM ${tables[$x]} LIMIT 1 OFFSET 0' --quiet"
206
207        if eval $QUERY &> /dev/null;
208        then
209                echo "  Verbindung erfolgreich hergestellt, Eingabetabelle existiert."
210        else # Kein Abruf von Tabelle möglich - DB-Konfig falsch oder Tabelle nicht existent
211                QUERY="${CONN} -c 'SELECT false' --quiet"
212                if eval $QUERY &> /dev/null;
213                then
214                        echo "  Fehler: Eingabetabelle ${tables[$x]} existiert nicht."
215                else
216                        echo "  Fehler: Verbindung zum Server konnte nicht hergestellt werden!"
217                        echo "  Bitte Verbindungseinstellungen ÃŒberprÃŒfen."
218                fi
219                exit 0
220        fi
221       
222        #### PROZESSIERUNG ####
223
224       
225        echo "Geometrie-Layer: ${tables[$x]}, Clipping-Layer: ${cells[$x]}, aux fields: ${auxfields[$x]}"
226        time $CONN -c "DROP TABLE IF EXISTS temp0;
227        SELECT ${auxfields[$x]} (ST_Dump(ST_Intersection(rlp.wkb_geometry, t.wkb_geometry))).geom AS wkb_geometry, t.widmung
228        INTO temp0
229        FROM ${tables[$x]} t
230        INNER JOIN ${cells[$x]} rlp
231        ON rlp.wkb_geometry && t.wkb_geometry
232        WHERE ST_Intersects( rlp.wkb_geometry, t.wkb_geometry);
233        DELETE FROM ${tables[$x]} ;
234        INSERT INTO ${tables[$x]} (${auxfields[$x]} wkb_geometry, widmung) SELECT ${auxfields[$x]} wkb_geometry, widmung FROM temp0 WHERE ST_GeometryType( wkb_geometry ) = '${geomtype[$x]}';"
235
236done
Note: See TracBrowser for help on using the repository browser.