source: subversion/utils/osmarender4/example_debian.sh @ 2188

Last change on this file since 2188 was 1877, checked in by jochen, 14 years ago

New version of osmarender. There are many changes and it is not quite
compatible to osmarender 3, so I have started a new version.

  • Property svn:executable set to *
File size: 2.2 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
40HAS_RSVG=$?
41dpkg -L inkscape > /dev/null 2>/dev/null
42HAS_INKSCAPE=$?
43if [ $HAS_RSVG == 0 ]; then
44        RENDERER="rsvg -f png data.svg data.png"
45elif [ $HAS_INKSCAPE == 0 ]; then
46        RENDERER="inkscape -D -e data.png data.svg"
47else
48        # No svg renderer found
49        echo "No SVG renderer was found. Please run one of:"
50        echo ""
51        echo "   sudo apt-get install librsvg2-bin"
52        echo "   sudo apt-get install inkscape"
53        exit 1
54fi
55
56
57# Grab the .osm file, if we don't already have one
58download_url='http://www.openstreetmap.org/api/0.3/map?'
59download_bbox="bbox=$BBOX"
60if [ ! -s data.osm ] ; then
61        echo "Fetching OSM data for bounding box "
62        echo " $BBOX"
63        echo ""
64
65        # Do they have a netrc for openstreetmap?
66        CURL_ARGS=""
67        if [[ -f $HOME/.netrc ]]; then
68                grep -q 'openstreetmap.org' $HOME/.netrc
69                NO_ENTRY=$?
70                if [[ $NO_ENTRY -eq 0 ]]; then
71                        CURL_ARGS="--netrc"
72                fi
73        fi
74        if [[ "$CURL_ARGS" == "" ]]; then
75                echo "No .netrc entry found for openstreetmap"
76                echo ""
77                echo "Please enter your OpenStreetMap username (normally your email)"
78                read USERNAME
79                CURL_ARGS="-u $USERNAME"
80        fi
81
82    curl --anyauth $CURL_ARGS -o data.osm "$download_url$download_bbox"
83else
84        echo "Using existing data.osm file"
85        echo ""
86fi
87
88# Start rendering
89$XALAN -in rules/standard.xml -out data.svg -param osmfile "'data.osm'"
90
91# svg --> png
92$RENDERER
Note: See TracBrowser for help on using the repository browser.