source: other-projects/tipple-android/osmosis/bin/osmosis@ 26899

Last change on this file since 26899 was 26899, checked in by davidb, 11 years ago

Tipple reborn after Chris's Summer of Code 2013

File size: 3.2 KB
Line 
1#!/bin/sh
2
3# Config files can define several variables used throughout this script.
4# JAVACMD - The java command to launch osmosis.
5# JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.
6# OSMOSIS_OPTIONS - The options to apply to all osmosis invocations, typically used to add plugins or make quiet operation the default.
7
8if [ -f /etc/osmosis ] ; then
9 . /etc/osmosis
10fi
11
12if [ -f "$HOME/.osmosis" ] ; then
13 . "$HOME/.osmosis"
14fi
15
16if [ -z "$JAVACMD" ] ; then
17 # No JAVACMD provided in osmosis config files, therefore default to java
18 JAVACMD=java
19fi
20
21## resolve links - $0 may be a link to application
22PRG="$0"
23
24# if started without absolute path, but from PATH environment
25if [ ! -s "$PRG" ] ; then
26 PRG=`which $PRG`
27fi
28
29# need this for relative symlinks
30while [ -h "$PRG" ] ; do
31 ls=`ls -ld "$PRG"`
32 link=`expr "$ls" : '.*-> \(.*\)$'`
33 if expr "$link" : '/.*' > /dev/null; then
34 PRG="$link"
35 else
36 PRG="`dirname "$PRG"`/$link"
37 fi
38done
39
40if [ "x$1x" = "xx" ] || echo "$@" | grep -q -e '--help' ; then
41cat <<EOF
42osmosis
43
44Example Usage
45
46Import a planet file into a local PostgreSQL database.
47
48osmosis --read-xml file=~/osm/planbet/planet.osm --write-apidb host="x" database="x" user="x" password="x"
49
50Export a planet file from a local PostgreSQL database.
51
52osmosis --read-apidb host="x" database="x" user="x" password="x" --write-xml file="planet.osm"
53
54Derive a change set between two planet files.
55
56osmosis --read-xml file="planet2.osm" --read-xml file="planet1.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"
57
58Derive a change set between a planet file and a database.
59
60osmosis --read-mysql host="x" database="x" user="x" password="x" --read-xml file="planet1.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"
61
62Apply a change set to a planet file.
63
64osmosis --read-xml-change file="planetdiff-1-2.osc" --read-xml file="planet1.osm" --apply-change --write-xml file="planet2.osm"
65
66Sort the contents of a planet file.
67
68osmosis --read-xml file="data.osm" --sort type="TypeThenId" --write-xml file="data-sorted.osm"
69
70The above examples make use of the default pipe connection feature, however a simple read and write planet file command line could be written in two ways. The first example uses default pipe connection, the second explicitly connects the two components using a pipe named "mypipe". The default pipe connection will always work so long as each task is specified in the correct order.
71
72osmosis --read-xml file="planetin.osm" --write-xml file="planetout.osm"
73
74osmosis --read-xml file="planetin.osm" outPipe.0="mypipe" --write-xml file="planetout.osm" inPipe.0="mypipe"
75
76Full usage details are available at: http://wiki.openstreetmap.org/wiki/Osmosis/DetailedUsage
77
78EOF
79exit 1
80fi
81
82# make it fully qualified
83saveddir=`pwd`
84MYAPP_HOME=`dirname "$PRG"`/..
85MYAPP_HOME=`cd "$MYAPP_HOME" && pwd`
86cd "$saveddir"
87
88# Build up the classpath of required jar files via classworlds launcher.
89MYAPP_CLASSPATH=$MYAPP_HOME/lib/default/plexus-classworlds-*.jar
90
91MAINCLASS=org.codehaus.classworlds.Launcher
92EXEC="$JAVACMD $JAVACMD_OPTIONS -cp $MYAPP_CLASSPATH -Dapp.home=$MYAPP_HOME -Dclassworlds.conf=$MYAPP_HOME/config/plexus.conf $MAINCLASS $OSMOSIS_OPTIONS"
93
94exec $EXEC "$@"
Note: See TracBrowser for help on using the repository browser.