source: subversion/utils/osmarender/example_debian.sh @ 2052

Last change on this file since 2052 was 1967, checked in by joerg, 13 years ago

tag shell schript executable

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/sh
2# Checks to see if everything that is needed is installed, then downloads
3#  a sample area
4# Accepts a bbox on the command line, or goes with a default
5
6BBOX=$1
7if [ -z $BBOX ]; then
8        # Default is of Southern Oxford
9        BBOX="-1.25,51.71,-1.20,51.75"
10        # For all of Oxford, use:
11        #BBOX="-1.3586995030608724,51.69824616779909,-1.1249755249943214,51.83024250815124"
12fi
13
14XALAN=""
15RENDERER=""
16
17# Check if xalan is installed
18# We can use the binary, or the .jar
19dpkg -L xalan > /dev/null 2>/dev/null
20HAS_XALAN=$?
21dpkg -L libxalan2-java > /dev/null 2>/dev/null
22HAS_XALAN_JAR=$?
23
24if [ $HAS_XALAN == 0 ]; then
25        XALAN="xalan"
26elif [ $HAS_XALAN_JAR == 0 ]; then
27        XALAN="java -jar /usr/share/java/xalan2.jar"
28else
29        # No xalan found
30        echo "No xalan was found. Please run one of:"
31        echo ""
32        echo "   sudo apt-get install xalan"
33        echo "   sudo apt-get install libxalan2-java"
34        exit 1
35fi
36
37
38# We need a render, either librsvg2-bin or inkscape
39dpkg -L librsvg2-bin > /dev/null 2>/dev/null
40#HAS_RSVG=$?
41HAS_RSVG=1
42dpkg -L inkscape > /dev/null 2>/dev/null
43HAS_INKSCAPE=$?
44if [ $HAS_RSVG == 0 ]; then
45        RENDERER="rsvg -f png data.svg data.png"
46elif [ $HAS_INKSCAPE == 0 ]; then
47#       RENDERER="inkscape -D --export-width=3000 --export-height=4000 -e data.png data.svg"
48        RENDERER="inkscape -D -e data.png data.svg"
49else
50        # No svg renderer found
51        echo "No SVG renderer was found. Please run one of:"
52        echo ""
53        echo "   sudo apt-get install librsvg2-bin"
54        echo "   sudo apt-get install inkscape"
55        exit 1
56fi
57
58
59# Grab the .osm file, if we don't already have one
60download_url='http://www.openstreetmap.org/api/0.3/map?'
61download_bbox="bbox=$BBOX"
62if [ ! -s data.osm ] ; then
63        echo "Fetching OSM data for bounding box "
64        echo " $BBOX"
65        echo ""
66
67        # Do they have a netrc for openstreetmap?
68        CURL_ARGS=""
69        if [[ -f $HOME/.netrc ]]; then
70                grep -q 'openstreetmap.org' $HOME/.netrc
71                NO_ENTRY=$?
72                if [[ $NO_ENTRY -eq 0 ]]; then
73                        CURL_ARGS="--netrc"
74                fi
75        fi
76        if [[ "$CURL_ARGS" == "" ]]; then
77                echo "No .netrc entry found for openstreetmap"
78                echo ""
79                echo "Please enter your OpenStreetMap username (normally your email)"
80                read USERNAME
81                CURL_ARGS="-u $USERNAME"
82        fi
83
84    curl --anyauth $CURL_ARGS -o data.osm "$download_url$download_bbox"
85else
86        echo "Using existing data.osm file"
87        echo ""
88fi
89
90# Start rendering
91$XALAN -in osm-map-features.xml -out data.svg
92
93# svg --> png
94$RENDERER
Note: See TracBrowser for help on using the repository browser.