source: subversion/applications/rendering/osmarender/example_redhat.sh @ 10852

Last change on this file since 10852 was 1846, checked in by joerg, 13 years ago

set executable property

  • Property svn:executable set to *
File size: 2.0 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
18rpm -q xalan-j2 > /dev/null 2>/dev/null
19HAS_XALAN_JAR=$?
20
21if [ $HAS_XALAN_JAR == 0 ]; then
22        XALAN="java -jar /usr/share/java/xalan-j2.jar"
23else
24        # No xalan found
25        echo "No xalan was found. Please run:"
26        echo ""
27        echo "   sudo yum install xalan-j2"
28        exit 1
29fi
30
31
32# We need a render, either librsvg2-bin or inkscape
33rpm -q librsvg2 > /dev/null 2>/dev/null
34HAS_RSVG=$?
35rpm -q inkscape > /dev/null 2>/dev/null
36HAS_INKSCAPE=$?
37if [ $HAS_RSVG == 0 ]; then
38        RENDERER="rsvg -f png data.svg data.png"
39elif [ $HAS_INKSCAPE == 0 ]; then
40        RENDERER="inkscape -D -e data.png data.svg"
41else
42        # No svg renderer found
43        echo "No SVG renderer was found. Please run one of:"
44        echo ""
45        echo "   sudo yum install librsvg2"
46        echo "   sudo yum install inkscape"
47        exit 1
48fi
49
50
51# Grab the .osm file, if we don't already have one
52download_url='http://www.openstreetmap.org/api/0.3/map?'
53download_bbox="bbox=$BBOX"
54if [ ! -s data.osm ] ; then
55        echo "Fetching OSM data for bounding box "
56        echo " $BBOX"
57        echo ""
58
59        # Do they have a netrc for openstreetmap?
60        CURL_ARGS=""
61        if [[ -f $HOME/.netrc ]]; then
62                grep -q 'openstreetmap.org' $HOME/.netrc
63                NO_ENTRY=$?
64                if [[ $NO_ENTRY -eq 0 ]]; then
65                        CURL_ARGS="--netrc"
66                fi
67        fi
68        if [[ "$CURL_ARGS" == "" ]]; then
69                echo "No .netrc entry found for openstreetmap"
70                echo ""
71                echo "Please enter your OpenStreetMap username (normally your email)"
72                read USERNAME
73                CURL_ARGS="-u $USERNAME"
74        fi
75
76    curl --anyauth $CURL_ARGS -o data.osm "$download_url$download_bbox"
77else
78        echo "Using existing data.osm file"
79        echo ""
80fi
81
82# Start rendering
83$XALAN -in osm-map-features.xml -out data.svg
84
85# svg --> png
86$RENDERER
Note: See TracBrowser for help on using the repository browser.