-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_data_pgis
More file actions
executable file
·146 lines (125 loc) · 5.31 KB
/
Copy pathget_data_pgis
File metadata and controls
executable file
·146 lines (125 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
function download {
OVERPASS_SERVERS=( "http://overpass-api.de/api" "http://overpass.osm.rambler.ru/cgi" )
OVERPASS_SERVERS_COUNT=${#OVERPASS_SERVERS[@]}
DB=gis_eu
LAT_START=30
LON_START=-20
LAT_END=80
LON_END=52
LAT_STEP=2
LON_STEP=6
i=0
str=""
#qs="${1}"
OLD_IFS=$IFS
IFS=''
qs="$1[*]"
qs=(${!qs})
IFS=$OLD_IFS
#echo $qs2
#qs=("raz" "dva" "tri" )
#for qq in "${qs[@]}"; do
#for i_lat in $(eval echo "{$LAT_START..$LAT_END..$LAT_STEP}"); do
#lat_from=$i_lat
#lat_to=$(python <<< "print min($LAT_END,$i_lat+$LAT_STEP)")
#for i_lon in $(eval echo "{$LON_START..$LON_END..$LON_STEP}"); do
#lon_from=$i_lon
#lon_to=$(python <<< "print min($LON_END,$i_lon+$LON_STEP)")
#q=${qq//%lon1%/$lon_from}
#q=${q//%lon2%/$lon_to}
#q=${q//%lat1%/$lat_from}
#q=${q//%lat2%/$lat_to}
#i=$(($i+1))
#server=${OVERPASS_SERVERS[$(($i % $OVERPASS_SERVERS_COUNT))]}
#wget -T 86400 -O - "$server/interpreter?data=[timeout:86400];$q;out;" | /home/klinger/mymap/osm/osmconvert - --out-o5m > "/tmp/~$2.$i_lon.$i_lat.o5m"
#while [ $? -ne 0 ]; do
#i=$(($i+1))
#server=${OVERPASS_SERVERS[$(($i % $OVERPASS_SERVERS_COUNT))]}
#wget -T 86400 -O - "$server/interpreter?data=[timeout:86400];$q;out;" | /home/klinger/mymap/osm/osmconvert - --out-o5m > "/tmp/~$2.$i_lon.$i_lat.o5m"
#done
#if [ -f "/tmp/$2.o5m" ]; then
#/home/klinger/mymap/osm/osmconvert "/tmp/$2.o5m" "/tmp/~$2.$i_lon.$i_lat.o5m" --out-o5m > "/tmp/~$2.o5m"
#FS1=$(stat -c%s "/tmp/~$2.$i_lon.$i_lat.o5m")
#FS2=$(stat -c%s "/tmp/~$2.o5m")
#if [ $FS1 -ge $FS2 ]; then
#unlink "/tmp/~$2.o5m"
#else
#unlink "/tmp/$2.o5m"
#mv "/tmp/~$2.o5m" "/tmp/$2.o5m"
#fi
#unlink "/tmp/~$2.$i_lon.$i_lat.o5m"
#else
#mv "/tmp/~$2.$i_lon.$i_lat.o5m" "/tmp/$2.o5m"
#fi
#done
#done
#done
#/home/klinger/mymap/osm/osmconvert "/tmp/$2.o5m" --out-osm | bzip2 > "/tmp/$2.osm.bz2"
#unlink "/tmp/$2.o5m"
case "$3" in
point)
echo "DROP TABLE $2; DROP INDEX $2_point_pkey,$2_point_index;" | psql -d $DB
;;
pointex)
echo "DROP TABLE $2; DROP INDEX $2_point_pkey,$2_point_index;" | psql -d $DB
;;
line)
echo "DROP TABLE $2; DROP INDEX $2_line_pkey,$2_line_index;" | psql -d $DB
;;
route)
echo "DROP TABLE $2; DROP INDEX $2_line_pkey,$2_line_index;" | psql -d $DB
;;
polygon)
echo "DROP TABLE $2; DROP INDEX $2_polygon_pkey,$2_polygon_index;" | psql -d $DB
;;
esac
/usr/local/bin/osm2pgsql \
-d $DB \
--style "/home/klinger/mymap/osm2pgsql/$2.style" \
--create \
--slim --cache 30 \
--prefix $2 \
/tmp/$2.osm.bz2
#unlink /tmp/$2.osm.bz2
case "$3" in
point)
echo "ALTER TABLE $2_point RENAME TO $2; DROP TABLE $2_polygon; DROP TABLE $2_line,$2_nodes,$2_rels,$2_roads,$2_ways;" | psql -d $DB
;;
pointex)
echo "CREATE TABLE $2 AS $4; DROP TABLE $2_point,$2_polygon,$2_line,$2_nodes,$2_rels,$2_roads,$2_ways; DROP TABLE $2_point,$2_polygon,$2_line,$2_nodes,$2_rels,$2_roads,$2_ways;" | psql -d $DB
;;
line)
echo "ALTER TABLE $2_line RENAME TO $2; DROP TABLE $2_polygon; DROP TABLE $2_point,$2_nodes,$2_rels,$2_roads,$2_ways;" | psql -d $DB
;;
route)
echo "ALTER TABLE $2_line RENAME TO $2; DROP TABLE $2_polygon;" | psql -d $DB
;;
polygon)
echo "ALTER TABLE $2_polygon RENAME TO $2; DROP TABLE $2_line; DROP TABLE $2_point,$2_nodes,$2_rels,$2_roads,$2_ways;" | psql -d $DB
;;
esac
}
q=( "node(%lat1%,%lon1%,%lat2%,%lon2%)[place~\"city|town|village|hamlet|isolated_dwelling|farm|suburb|neighbourhood|locality|island|islet\"]" )
#download q places point
q=( "node(%lat1%,%lon1%,%lat2%,%lon2%)[natural=\"peak\"]" )
download q peaks point
q=( "(rel(%lat1%,%lon1%,%lat2%,%lon2%)[waterway~\"river|stream|ditch|canal\"];);(._;way(r););(._;node(w););(way(%lat1%,%lon1%,%lat2%,%lon2%)[waterway~\"river|stream|ditch|canal\"];);(._;node(w);)" )
download q waterway line
q=( "(rel(%lat1%,%lon1%,%lat2%,%lon2%)[boundary=\"administrative\"];);(._;way(r););(._;node(w);)" )
#download q adminboundary polygon
q=(
"node(%lat1%,%lon1%,%lat2%,%lon2%)[historic]"
"node(%lat1%,%lon1%,%lat2%,%lon2%)[man_made]"
"node(%lat1%,%lon1%,%lat2%,%lon2%)[leisure]"
"node(%lat1%,%lon1%,%lat2%,%lon2%)[tourism]"
"node(%lat1%,%lon1%,%lat2%,%lon2%)[amenity]"
"node(%lat1%,%lon1%,%lat2%,%lon2%)[natural=\"cave_entrance\"]"
"(rel(%lat1%,%lon1%,%lat2%,%lon2%)[building~\"church|chapel\"];);(._;way(r););(._;node(w););(way(%lat1%,%lon1%,%lat2%,%lon2%)[building~\"church|chapel\"];);(._;node(w);)"
)
#download q symbol pointex \
"SELECT osm_id,name,int_name,\"name:en\",\"name:de\",\"name:cs\",historic,leisure,man_made,tourism,amenity,ruins,castle_type,building,\"natural\",\"tower:type\",information,place_of_worship,\"place_of_worship:type\",z_order,way FROM symbol_point UNION SELECT osm_id,name,int_name,\"name:en\",\"name:de\",\"name:cs\",historic,leisure,man_made,tourism,amenity,ruins,castle_type,building,\"natural\",\"tower:type\",information,place_of_worship,\"place_of_worship:type\",z_order,ST_Centroid(way) AS way FROM symbol_polygon"
q=(
"(rel(%lat1%,%lon1%,%lat2%,%lon2%)[route~\"mtb|horse|ski|bicycle|horse|hiking|foot\"];);(._;way(r););(._;node(w);)"
)
#download q route route