#!/bin/sh -e
# mcmer@tor.at 2011-12-04
# 
# required: 
# osmosis:
# http://wiki.openstreetmap.org/wiki/Osmosis
# http://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage
# 
# osmosis-simplifyways plugin
# https://github.com/podolsir/osmosis-simplifyways
# https://github.com/podolsir/osmosis-simplifyways/downloads
# goes to $osmosisdir/lib/default/
#
# WARNING: simplifyways just removes the nodes from the ways, but does not
# remove the nodes themselves.
# see osm-nodes-usedonly.sh or osmosis --used-node
#
if [[ $# -lt 2 ]]; then
	print -u2 "usage: osm-ways-normalize.sh src tgt maxerr"
	exit
fi
local _src="${1}"
local _tgt="${2}"
local _err=${3:-"10"}
osmosis --read-xml "${_src}" \
  --sort --simplify-ways epsilonMeters="${_err}" \
  --wx "${_tgt}"
