]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - jsroute/jsroute
3 # jsroute, a utility to route via Google Maps using Envjs.
5 # We take a starting point and a destination as arguments, and
6 # pass them off to a Javascript file (route.js) which is compiled
7 # on-the-fly using Mozilla's Rhino Javascript compiler. Then, magic
8 # occurs, and the JSON results are output to the command line.
10 # Soon the output will be piped through a Python script to convert
16 EXIT_MISSING_DESTINATION
=2
25 # A function which just displays the usage information.
28 echo "Usage: $0 [-h] [-n \"name\"] \"<start>\" \"<destination>\""
31 echo " <start>, Your starting location. Use quotes."
32 echo " <destination>, Your destination. Use quotes."
35 echo " -h, Show the usage information and bail."
36 echo " -n <name>, Give the route a meaningful name. Use quotes."
41 while getopts "hn:" option
; do
43 n
) ROUTENAME
="$OPTARG";
44 # Shift the number of remaining arguments down by two,
45 # so that the non-option parameters are accessible via
51 exit $EXIT_GETOPT_UNHAPPY;;
56 # The non-option parameters.
60 # Dollarsign-octothorpe contains the number of parameter arguments.
61 if [ "$#" -gt 2 ]; then
62 echo "Error: too many arguments. Maybe you forgot to place the source and destination in quotes?"
64 exit $EXIT_TOO_MANY_ARGS
67 if [ "$START" == "" ]; then
69 exit $EXIT_MISSING_START
72 if [ "$DESTINATION" == "" ]; then
74 exit $EXIT_MISSING_DESTINATION
77 if [ "$ROUTENAME" == "" ]; then
78 # Set it to a default of "<start> to <destination>".
79 ROUTENAME
="$START to $DESTINATION"
82 java
-jar ..
/lib
/env
-js/rhino
/js.jar
-opt -1 route.js
"$1" "$2"