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 |
|
---|
8 | if [ -f /etc/osmosis ] ; then
|
---|
9 | . /etc/osmosis
|
---|
10 | fi
|
---|
11 |
|
---|
12 | if [ -f "$HOME/.osmosis" ] ; then
|
---|
13 | . "$HOME/.osmosis"
|
---|
14 | fi
|
---|
15 |
|
---|
16 | if [ -z "$JAVACMD" ] ; then
|
---|
17 | # No JAVACMD provided in osmosis config files, therefore default to java
|
---|
18 | JAVACMD=java
|
---|
19 | fi
|
---|
20 |
|
---|
21 | ## resolve links - $0 may be a link to application
|
---|
22 | PRG="$0"
|
---|
23 |
|
---|
24 | # if started without absolute path, but from PATH environment
|
---|
25 | if [ ! -s "$PRG" ] ; then
|
---|
26 | PRG=`which $PRG`
|
---|
27 | fi
|
---|
28 |
|
---|
29 | # need this for relative symlinks
|
---|
30 | while [ -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
|
---|
38 | done
|
---|
39 |
|
---|
40 | if [ "x$1x" = "xx" ] || echo "$@" | grep -q -e '--help' ; then
|
---|
41 | cat <<EOF
|
---|
42 | osmosis
|
---|
43 |
|
---|
44 | Example Usage
|
---|
45 |
|
---|
46 | Import a planet file into a local PostgreSQL database.
|
---|
47 |
|
---|
48 | osmosis --read-xml file=~/osm/planbet/planet.osm --write-apidb host="x" database="x" user="x" password="x"
|
---|
49 |
|
---|
50 | Export a planet file from a local PostgreSQL database.
|
---|
51 |
|
---|
52 | osmosis --read-apidb host="x" database="x" user="x" password="x" --write-xml file="planet.osm"
|
---|
53 |
|
---|
54 | Derive a change set between two planet files.
|
---|
55 |
|
---|
56 | osmosis --read-xml file="planet2.osm" --read-xml file="planet1.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"
|
---|
57 |
|
---|
58 | Derive a change set between a planet file and a database.
|
---|
59 |
|
---|
60 | osmosis --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 |
|
---|
62 | Apply a change set to a planet file.
|
---|
63 |
|
---|
64 | osmosis --read-xml-change file="planetdiff-1-2.osc" --read-xml file="planet1.osm" --apply-change --write-xml file="planet2.osm"
|
---|
65 |
|
---|
66 | Sort the contents of a planet file.
|
---|
67 |
|
---|
68 | osmosis --read-xml file="data.osm" --sort type="TypeThenId" --write-xml file="data-sorted.osm"
|
---|
69 |
|
---|
70 | The 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 |
|
---|
72 | osmosis --read-xml file="planetin.osm" --write-xml file="planetout.osm"
|
---|
73 |
|
---|
74 | osmosis --read-xml file="planetin.osm" outPipe.0="mypipe" --write-xml file="planetout.osm" inPipe.0="mypipe"
|
---|
75 |
|
---|
76 | Full usage details are available at: http://wiki.openstreetmap.org/wiki/Osmosis/DetailedUsage
|
---|
77 |
|
---|
78 | EOF
|
---|
79 | exit 1
|
---|
80 | fi
|
---|
81 |
|
---|
82 | # make it fully qualified
|
---|
83 | saveddir=`pwd`
|
---|
84 | MYAPP_HOME=`dirname "$PRG"`/..
|
---|
85 | MYAPP_HOME=`cd "$MYAPP_HOME" && pwd`
|
---|
86 | cd "$saveddir"
|
---|
87 |
|
---|
88 | # Build up the classpath of required jar files via classworlds launcher.
|
---|
89 | MYAPP_CLASSPATH=$MYAPP_HOME/lib/default/plexus-classworlds-*.jar
|
---|
90 |
|
---|
91 | MAINCLASS=org.codehaus.classworlds.Launcher
|
---|
92 | EXEC="$JAVACMD $JAVACMD_OPTIONS -cp $MYAPP_CLASSPATH -Dapp.home=$MYAPP_HOME -Dclassworlds.conf=$MYAPP_HOME/config/plexus.conf $MAINCLASS $OSMOSIS_OPTIONS"
|
---|
93 |
|
---|
94 | exec $EXEC "$@"
|
---|