summaryrefslogtreecommitdiff
path: root/scripts/geojson/fetch.sh
blob: bd86239c91610abadb1920f9f76d46f9a834fd34 (plain)
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
fetch_category () {
    echo "Fetching $1" > /dev/stderr
    json=`curl "https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:$1&cmlimit=max" 2>/dev/null`
    cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '`
    num=`echo $cities | tr ' ' '\n' | wc -l`
    i=0
    echo "["
    for city in $cities; do
	let i++
	echo -n -e "\rFetched $i/$num" > /dev/stderr
	./fetch_single.sh "$city"
    done
    echo > /dev/stderr
    echo "{}]"
}

JSONDIR=../../htdocs/geojson

mkdir -p $JSONDIR


fetch_category Shops > $JSONDIR/shops.json
fetch_category City > $JSONDIR/cities.json
fetch_category Stations > $JSONDIR/stations.json
fetch_category Parks > $JSONDIR/parks.json
fetch_category Libraries > $JSONDIR/libraries.json
fetch_category "CW_Complexes" > $JSONDIR/cw_complexes.json
fetch_category Courts > $JSONDIR/courts.json
fetch_category Waterway > $JSONDIR/waterway.json
fetch_category Train_Depots > $JSONDIR/depots.json