source: livedvd/gisvm/trunk/bin/install_gpsdrive.sh

Last change on this file was 12182, checked in by darkblueb, 21 months ago

FeatureCity? -> SanMateo_CA in gpsdrive

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:mime-type set to text/x-sh
File size: 8.6 KB
Line 
1#!/bin/sh
2# Copyright (c) 2009-2013 by Hamish Bowman, and the Open Source Geospatial Foundation
3# Licensed under the GNU LGPL version >= 2.1.
4#
5# This library is free software; you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as published
7# by the Free Software Foundation, either version 2.1 of the License,
8# or any later version.  This library is distributed in the hope that
9# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
10# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU Lesser General Public License for more details, either
12# in the "LGPL-2.1.txt" file distributed with this software or at
13# web page "http://www.fsf.org/licenses/lgpl.html".
14#
15#
16# script to install GpsDrive
17#    written by H.Bowman <hamish_b  yahoo com>
18#    GpsDrive homepage: http://www.gpsdrive.de
19#
20
21./diskspace_probe.sh "`basename $0`" begin
22BUILD_DIR=`pwd`
23####
24
25## same as install_osm.sh def
26CITY="SanMateo_CA"
27
28# live disc's username is "user"
29if [ -z "$USER_NAME" ] ; then
30   USER_NAME="user"
31fi
32USER_HOME="/home/$USER_NAME"
33
34TMP_DIR=/tmp/build_gpsdrive
35
36
37#### install program ####
38####  (postgresql is installed once, system-wide
39####   so do not repeat the PG install here)
40
41PACKAGES="gpsd gpsd-clients python-gps \
42   espeak gdal-bin gpsbabel \
43   graphicsmagick-imagemagick-compat \
44   python-mapnik \
45   speech-dispatcher \
46   openstreetmap-map-icons-square \
47   openstreetmap-map-icons-scalable \
48   openstreetmap-map-icons-classic \
49   ttf-dejavu \
50   wget netpbm optipng \
51   sqlite3 sqlitebrowser"
52
53apt-get --assume-yes install $PACKAGES
54
55if [ $? -ne 0 ] ; then
56   echo "An error occurred installing packages. Aborting install."
57   exit 1
58fi
59
60
61#######################
62## use prebuilt debs
63
64if [ ! -d "$TMP_DIR" ] ; then
65  mkdir "$TMP_DIR"
66fi
67cd "$TMP_DIR"
68
69URL="http://download.osgeo.org/livedvd/data/gpsdrive/trusty/i386"
70VER="2.12+svn2726-1"
71MAIN_FILE="gpsdrive_${VER}_i386.deb"
72EXTRA_FILES="
73  gpsdrive-data_${VER}_all.deb
74  gpsdrive-friendsd_${VER}_i386.deb
75  gpsdrive-utils_${VER}_i386.deb"
76
77wget -c --progress=dot:mega "$URL/$MAIN_FILE"
78for FILE in $EXTRA_FILES ; do
79   wget -c -nv "$URL/$FILE"
80done
81
82gdebi --non-interactive --quiet gpsdrive-data_${VER}_all.deb
83gdebi --non-interactive --quiet gpsdrive-friendsd_${VER}_i386.deb
84gdebi --non-interactive --quiet gpsdrive-utils_${VER}_i386.deb
85gdebi --non-interactive --quiet gpsdrive_${VER}_i386.deb
86
87
88
89#### install data ####
90
91mkdir /etc/skel/.gpsdrive
92mkdir "$USER_HOME/.gpsdrive"
93
94# program defaults
95cat << EOF > "/etc/skel/.gpsdrive/gpsdriverc"
96lastlong = -122.3
97lastlat  =  37.5
98scalewanted = 10000
99dashboard_3 = 12
100autobestmap = 0
101mapnik = 1
102mapnik_caching = 0
103minsecmode = 2
104friendsname = LiveDVD
105showbutton_trackrestart = 0
106showbutton_trackclear = 0
107icon_theme = classic.small
108osmdbfile = /usr/local/share/osm/${CITY}_poi.db
109mapnik_postgis_dbname = osm_local
110EOF
111
112cp /etc/skel/.gpsdrive/gpsdriverc "$USER_HOME/.gpsdrive/"
113
114
115# add any waypoints you want to see displayed
116cat << EOF > "/etc/skel/.gpsdrive/way.txt"
117Sydney_Convention_Centre        -33.8750   151.2005
118Barcelona_Convention_Centre      41.3724     2.1518
119FOSS4G_2011_(Sheraton_Denver)    39.74251 -104.9891
120OSM_State_of_the_Map_2011        39.7457  -105.0034
121Business_School_South_(Jubilee)  52.9517  -1.1864
122East_Midlands_Conference_Centre  52.9390  -1.2032
123FOSS4G-NA_2013_(Marriott_City_Center)   44.9776  -93.2735
124Oregon_Convention_Center         45.5281  -122.6632
125Portland_State_University        45.5121  -122.6828
126EOF
127
128cp /etc/skel/.gpsdrive/way.txt "$USER_HOME/.gpsdrive/"
129
130
131#download latest OSM POIs for host city
132#wget -N --progress=dot:mega  http://poi.gpsdrive.de/$COUNTRY.db.bz2
133wget -N --progress=dot:mega \
134  "http://download.osgeo.org/livedvd/data/osm/$CITY/${CITY}_poi.db.bz2"
135bzip2 -d "${CITY}_poi.db.bz2"
136mkdir -p /usr/local/share/osm/
137mkdir -p /usr/local/share/data/osm/
138mv "${CITY}_poi.db" /usr/local/share/osm/
139ln -s /usr/local/share/osm/"${CITY}_poi.db" \
140   /usr/local/share/data/osm/feature_city_poi.db
141
142# fool the hardcoded bastard
143mkdir -p /usr/share/mapnik/world_boundaries
144
145# bypass Mapnik wanting 300mb World Boundaries DB to be installed, use Natural Earth instead.
146sed -e 's+/usr/share/mapnik/world_boundaries/world_boundaries_m+/usr/local/share/data/natural_earth2/ne_10m_land+' \
147    -e 's/Layer name="world-1".*/Layer name="world-1" status="on" srs="+proj=longlat +datum=WGS84 +no_defs +over">/' \
148    \
149    -e 's+/usr/share/mapnik/world_boundaries/world_bnd_m+/usr/local/share/data/natural_earth2/ne_10m_land+' \
150    -e 's/Layer name="world".*/Layer name="world" status="on" srs="+proj=longlat +datum=WGS84 +no_defs +over">/' \
151    \
152    -e 's+/usr/share/mapnik/world_boundaries/processed_p+/usr/local/share/data/natural_earth2/ne_10m_land+' \
153    -e 's/Layer name="coast-poly".*/Layer name="coast-poly" status="on" srs="+proj=longlat +datum=WGS84 +no_defs +over">/' \
154    \
155    -e 's+/usr/share/mapnik/world_boundaries/builtup_area+/usr/local/share/data/natural_earth2/ne_10m_urban_areas+' \
156    -e 's/Layer name="buildup".*/Layer name="builtup" status="on" srs="+proj=longlat +datum=WGS84 +no_defs +over">/' \
157    \
158    -e 's+/usr/share/mapnik/world_boundaries/places+/usr/local/share/data/natural_earth2/ne_10m_populated_places+' \
159    -e 's/Layer name="places".*/Layer name="builtup" status="on" srs="+proj=longlat +datum=WGS84 +no_defs">/' \
160    \
161    /usr/share/gpsdrive/osm-template.xml > "/etc/skel/.gpsdrive/osm.xml"
162# "$TMP_DIR/gpsdrive-$VERSION/build/scripts/mapnik/osm-template.xml" \
163
164
165# change DB name from "gis" to "osm_local" as per load_postgis.sh
166sed -i -e 's+<Parameter name="dbname">gis</Parameter>+<Parameter name="dbname">osm_local</Parameter>+' \
167  "/etc/skel/.gpsdrive/osm.xml"
168
169# and change from epsg:900913 to epsg:4326 to match the "osm_local" DB's SRS
170sed -i -e 's|\("on" srs="\)+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs|\1+proj=longlat +datum=WGS84|' \
171  "/etc/skel/.gpsdrive/osm.xml"
172
173# layer extent too:  (FIXME, just guessed from the larger BBOX in install_osm.sh)
174sed -i -e 's|-20037508,-19929239,20037508,19929239|-122.8,45.4,-122.5,45.6|' \
175  "/etc/skel/.gpsdrive/osm.xml"
176
177# avoid shapefile column city name mismatch & tweak its map scale render rule:
178sed -i -e 's|TextSymbolizer name="\[place_name\]"|TextSymbolizer name="[NAME]"|' \
179       -e 's|<MaxScaleDenominator>10000000</|<MaxScaleDenominator>500000</|' \
180       -e 's|<MinScaleDenominator>10000000</|<MinScaleDenominator>1000000</|' \
181  "/etc/skel/.gpsdrive/osm.xml"
182
183
184# osm.xml changes for Mapnik2 ...
185sed -i -e 's/ face_name=/ face-name=/' \
186       -e 's/TextSymbolizer name="\([^"]*\)"/TextSymbolizer name="[\1]"/' \
187       -e 's/ShieldSymbolizer name="\([^"]*\)"/ShieldSymbolizer name="[\1]"/' \
188       -e 's/Map bgcolor=/Map background-color=/' \
189       -e 's|CssParameter name="\([^"]*\)">|Css>\1="|' \
190       -e 's|</CssParameter|"</Css|' \
191       -e 's|halo_fill|halo-fill|' \
192       -e 's|halo_radius|halo-radius|' \
193       -e 's|allow_overlap|allow-overlap|' \
194       -e 's|wrap_width|wrap-width|' \
195       -e 's|min_distance|minimum-distance|' \
196       -e 's|\.png" type="png" width="[^"]*" height="[^"]*"|.png" |' \
197  "/etc/skel/.gpsdrive/osm.xml"
198
199# todo: combine into a single command:
200perl -0777 -i.original -pe 's/Symbolizer>\n        <Css>/Symbolizer /g' \
201    "/etc/skel/.gpsdrive/osm.xml"
202perl -0777 -i.original -pe 's/<\/Css>\n        <Css>/ /g' \
203    "/etc/skel/.gpsdrive/osm.xml"
204perl -0777 -i.original -pe 's/<\/Css>\n      <\/LineSymbolizer>/ \/>/g' \
205    "/etc/skel/.gpsdrive/osm.xml"
206perl -0777 -i.original -pe 's/<\/Css>\n      <\/PolygonSymbolizer>/ \/>/g' \
207    "/etc/skel/.gpsdrive/osm.xml"
208
209
210# use (new) official debian pkg home of map icons
211sed -i -e 's/map-icons/openstreetmap/' \
212       -e 's|classic.small/rendering/landuse/forest.png|classic.big/rendering/landuse/forest.png|' \
213  "/etc/skel/.gpsdrive/osm.xml"
214
215cp /etc/skel/.gpsdrive/osm.xml "$USER_HOME/.gpsdrive/"
216
217
218chown -R $USER_NAME:$USER_NAME "$USER_HOME/.gpsdrive"
219
220cp /usr/share/applications/gpsdrive.desktop "$USER_HOME/Desktop/"
221chown $USER_NAME:$USER_NAME "$USER_HOME/Desktop/gpsdrive.desktop"
222
223
224####
225"$BUILD_DIR"/diskspace_probe.sh "`basename $0`" end
226
227exit
228
229
230
231
232
233############################################################################
234############################################################################
235############################################################################
236
237############################################################################
238
239
240############################################################################
241
242
243
244
245############################################################################
Note: See TracBrowser for help on using the repository browser.