-
Notifications
You must be signed in to change notification settings - Fork 1
/
mrwa2osm.sh
executable file
·55 lines (49 loc) · 1.51 KB
/
mrwa2osm.sh
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
#!/bin/bash
## Download zip of shapefile.
if [[ -z "$SLIP_USER" || -z "$SLIP_PASS" ]]; then
echo "Please set SLIP_USER and SLIP_PASS env vars"
exit 1
fi
TOKEN=$(echo -n $SLIP_USER':'$SLIP_PASS | base64 -w 0)
URL="https://maps.slip.wa.gov.au/datadownloads/MRWA_Public_Services/MRWA_Public_Secure_Services/RoadNetworkMRWA_514/RoadNetworkMRWA_514.zip"
SHPZIP=RoadNetwork_MRWA_514.zip
curl --version
echo "Downloading shapefile"
curl --location --cookie --verbose \
-H "User-Agent: QGIS" -H "Authorization: Basic "$TOKEN \
--output $SHPZIP \
"$URL"
if [[ $? -ne 0 ]]; then
echo "curl failed with: $?"
exit $?
fi
## Check size in Mb.
ZIPSIZE=$(du -m "$SHPZIP" | cut -f 1)
if [[ $ZIPSIZE < 20 ]]; then
echo "Zip file was not large enough (only $ZIPSIZE Mb). Contents:"
cat $SHPZIP
exit 1
fi
## Unzip.
echo "Unzipping downloaded shapefile"
unzip -d shp "$SHPZIP"
## Convert.
mkdir gh-pages
echo "Converting to OSM format"
OSMFILE="gh-pages/RoadNetworkMRWA_514.osm"
python ogr2osm/ogr2osm.py shp/RoadNetworkMRWA_514_1.shp -o "$OSMFILE"
## Zip.
ZIPFILE="RoadNetworkMRWA_514.zip"
zip "gh-pages/$ZIPFILE" "$OSMFILE"
## Send to Github.
cd gh-pages
cp ../docs/index.html .
cp ../mrwa_josm_styles.mapcss .
git init
git config user.name "Geogeeks (Travis CI)"
git config user.email "[email protected]"
git checkout -b gh-pages
git add "index.html" "$ZIPFILE" "mrwa_josm_styles.mapcss"
git commit -m"Updated from Slip"
echo "Pushing to Github"
git push -f "https://${GH_TOKEN}@github.com/geogeeks-au/MainRoads-to-OSM.git" gh-pages:gh-pages