[osm2pgsql] 03/11: Imported Upstream version 0.84.0

Bas Couwenberg sebastic at xs4all.nl
Wed Apr 30 14:29:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch master
in repository osm2pgsql.

commit bc5a8868db5aa124893037a8aaedcbebd463b131
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Apr 30 12:43:48 2014 +0200

    Imported Upstream version 0.84.0
---
 .gitignore                                      |   35 +
 INSTALL                                         |  365 ------
 Makefile.am                                     |   10 +-
 README                                          |   37 +-
 README_lua.md                                   |   57 +
 build_geometry.cpp                              |   79 +-
 configure.ac                                    |   23 +-
 cygpkg.sh                                       |   59 +
 debian/README                                   |    9 -
 debian/changelog                                |   88 --
 debian/compat                                   |    1 -
 debian/control                                  |   23 -
 debian/copyright                                |    4 -
 debian/dirs                                     |    2 -
 debian/manpages                                 |    1 -
 debian/openstreetmap-postgis-db-setup.config    |   22 -
 debian/openstreetmap-postgis-db-setup.install   |    2 -
 debian/openstreetmap-postgis-db-setup.postinst  |   52 -
 debian/openstreetmap-postgis-db-setup.templates |   23 -
 debian/osm2pgsql.install                        |    2 -
 debian/rules                                    |   93 --
 debian/source/format                            |    1 -
 default.style                                   |  350 ++++--
 docs/nodecachefilereader.1                      |    4 +-
 docs/osm2pgsql.1                                |   46 +-
 empty.style                                     |  107 ++
 legacy/Makefile.am                              |   11 -
 legacy/build_geometry.cpp                       |  163 ---
 legacy/build_geometry.h                         |   40 -
 legacy/osm2pgsql.c                              |  642 ----------
 m4/ax_lua.m4                                    |  607 +++++++++
 middle-pgsql.c                                  |   16 +-
 middle-ram.c                                    |    1 -
 node-persistent-cache.c                         |   17 +-
 node-persistent-cache.h                         |    2 +-
 node-ram-cache.c                                |    7 +-
 node-ram-cache.h                                |    2 +-
 osm2pgsql.c                                     |  272 ++--
 output-gazetteer.c                              |   85 +-
 output-pgsql.c                                  |  583 ++-------
 output-pgsql.h                                  |   14 +
 output.h                                        |    1 +
 parse-pbf.c                                     |   14 +-
 style.lua                                       |  178 +++
 tagtransform.c                                  |  756 ++++++++++++
 tagtransform.h                                  |   29 +
 tests/000466354.osc.gz                          |  Bin 0 -> 161335 bytes
 tests/liechtenstein-2013-08-03.osm.pbf          |  Bin 0 -> 666646 bytes
 tests/regression-test.py                        |  605 +++++++++
 tests/regression-test.sh                        |   63 +-
 tests/test_multipolygon.osm                     | 1508 +++++++++++++++++++++++
 tests/test_multipolygon_diff.osc                |  193 +++
 tests/test_multipolygon_postdiff.osm            |  987 +++++++++++++++
 53 files changed, 5895 insertions(+), 2396 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7b6e670
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,35 @@
+*.o
+Makefile.in
+aclocal.m4
+autom4te.cache/
+config.guess
+config.h.in
+config.sub
+configure
+depcomp
+fileformat.pb-c.c
+fileformat.pb-c.h
+install-sh
+legacy/Makefile.in
+ltmain.sh
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+missing
+osmformat.pb-c.c
+osmformat.pb-c.h
+osm2pgsql
+
+Makefile
+config.h
+config.log
+config.nice
+config.status
+legacy/.deps/
+legacy/Makefile
+libtool
+.deps/
+stamp-h1
+INSTALL
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 7d1c323..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,365 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
-
-   Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved.  This file is offered as-is,
-without warranty of any kind.
-
-Basic Installation
-==================
-
-   Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.  Some packages provide this
-`INSTALL' file but do not implement all of the features documented
-below.  The lack of an optional feature in a given package is not
-necessarily a bug.  More recommendations for GNU packages can be found
-in *note Makefile Conventions: (standards)Makefile Conventions.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-   The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
-
-     Running `configure' might take a while.  While running, it prints
-     some messages telling which features it is checking for.
-
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package, generally using the just-built uninstalled binaries.
-
-  4. Type `make install' to install the programs and any data files and
-     documentation.  When installing into a prefix owned by root, it is
-     recommended that the package be configured and built as a regular
-     user, and only the `make install' phase executed with root
-     privileges.
-
-  5. Optionally, type `make installcheck' to repeat any self-tests, but
-     this time using the binaries in their final installed location.
-     This target does not install anything.  Running this target as a
-     regular user, particularly if the prior `make install' required
-     root privileges, verifies that the installation completed
-     correctly.
-
-  6. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
-
-  7. Often, you can also type `make uninstall' to remove the installed
-     files again.  In practice, not all packages have tested that
-     uninstallation works correctly, even though it is required by the
-     GNU Coding Standards.
-
-  8. Some packages, particularly those that use Automake, provide `make
-     distcheck', which can by used by developers to test that all other
-     targets like `make install' and `make uninstall' work correctly.
-     This target is generally not run by end users.
-
-Compilers and Options
-=====================
-
-   Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
-for details on some of the pertinent environment variables.
-
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-   You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.  This
-is known as a "VPATH" build.
-
-   With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-   On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor.  Like
-this:
-
-     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CPP="gcc -E" CXXCPP="g++ -E"
-
-   This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
-
-Installation Names
-==================
-
-   By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX', where PREFIX must be an
-absolute file name.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
-   In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.  In general, the
-default for these options is expressed in terms of `${prefix}', so that
-specifying just `--prefix' will affect all of the other directory
-specifications that were not explicitly provided.
-
-   The most portable way to affect installation locations is to pass the
-correct locations to `configure'; however, many packages provide one or
-both of the following shortcuts of passing variable assignments to the
-`make install' command line to change installation locations without
-having to reconfigure or recompile.
-
-   The first method involves providing an override variable for each
-affected directory.  For example, `make install
-prefix=/alternate/directory' will choose an alternate location for all
-directory configuration variables that were expressed in terms of
-`${prefix}'.  Any directories that were specified during `configure',
-but not in terms of `${prefix}', must each be overridden at install
-time for the entire installation to be relocated.  The approach of
-makefile variable overrides for each directory variable is required by
-the GNU Coding Standards, and ideally causes no recompilation.
-However, some platforms have known limitations with the semantics of
-shared libraries that end up requiring recompilation when using this
-method, particularly noticeable in packages that use GNU Libtool.
-
-   The second method involves providing the `DESTDIR' variable.  For
-example, `make install DESTDIR=/alternate/directory' will prepend
-`/alternate/directory' before all installation names.  The approach of
-`DESTDIR' overrides is not required by the GNU Coding Standards, and
-does not work on platforms that have drive letters.  On the other hand,
-it does better at avoiding recompilation issues, and works well even
-when some directory options were not specified in terms of `${prefix}'
-at `configure' time.
-
-Optional Features
-=================
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-   Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-   Some packages offer the ability to configure how verbose the
-execution of `make' will be.  For these packages, running `./configure
---enable-silent-rules' sets the default to minimal output, which can be
-overridden with `make V=1'; while running `./configure
---disable-silent-rules' sets the default to verbose, which can be
-overridden with `make V=0'.
-
-Particular systems
-==================
-
-   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
-CC is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
-     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
-   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
-a workaround.  If GNU CC is not installed, it is therefore recommended
-to try
-
-     ./configure CC="cc"
-
-and if that doesn't work, try
-
-     ./configure CC="cc -nodtk"
-
-   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
-directory contains several dysfunctional programs; working variants of
-these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
-in your `PATH', put it _after_ `/usr/bin'.
-
-   On Haiku, software installed for all users goes in `/boot/common',
-not `/usr/local'.  It is recommended to use the following options:
-
-     ./configure --prefix=/boot/common
-
-Specifying the System Type
-==========================
-
-   There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
-     CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
-     OS
-     KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-   Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
-
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
-   `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
-     Print a summary of all of the options to `configure', and exit.
-
-`--help=short'
-`--help=recursive'
-     Print a summary of the options unique to this package's
-     `configure', and exit.  The `short' variant lists options used
-     only in the top level, while the `recursive' variant lists options
-     also present in any nested packages.
-
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
-     Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
-     messages will still be shown).
-
-`--srcdir=DIR'
-     Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
-
-`--prefix=DIR'
-     Use DIR as the installation prefix.  *note Installation Names::
-     for more details, including other options available for fine-tuning
-     the installation locations.
-
-`--no-create'
-`-n'
-     Run the configure checks, but stop before creating any output
-     files.
-
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
-
diff --git a/Makefile.am b/Makefile.am
index 38429af..051f12d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,8 @@
 ACLOCAL_AMFLAGS = -I m4
 
-DIST_SUBDIRS = legacy
-
 bin_PROGRAMS = osm2pgsql nodecachefilereader
 
-osm2pgsql_SOURCES = build_geometry.cpp input.c middle.h middle-ram.h output-gazetteer.h output-pgsql.c rb.c sanitizer.h text-tree.h build_geometry.h input.h middle-pgsql.c osm2pgsql.c output.h output-pgsql.h rb.h sprompt.c UTF8sanitizer.c expire-tiles.c keyvals.c middle-pgsql.h osmtypes.h output-null.c parse-o5m.c parse-o5m.h parse-primitive.c parse-primitive.h parse-xml2.c parse-xml2.h pgsql.c reprojection.c sprompt.h expire-tiles.h keyvals.h middle-ram.c output-gazetteer.c output-null. [...]
+osm2pgsql_SOURCES = build_geometry.cpp input.c middle.h middle-ram.h output-gazetteer.h output-pgsql.c rb.c sanitizer.h text-tree.h build_geometry.h input.h middle-pgsql.c osm2pgsql.c output.h output-pgsql.h rb.h sprompt.c UTF8sanitizer.c expire-tiles.c keyvals.c middle-pgsql.h osmtypes.h output-null.c parse-o5m.c parse-o5m.h parse-primitive.c parse-primitive.h parse-xml2.c parse-xml2.h pgsql.c reprojection.c sprompt.h expire-tiles.h keyvals.h middle-ram.c output-gazetteer.c output-null. [...]
 
 nodecachefilereader_SOURCES = node-persistent-cache-reader.c node-persistent-cache.c node-ram-cache.c binarysearcharray.c
 
@@ -38,10 +36,10 @@ endif
 
 osm2pgsqldir = $(datadir)/osm2pgsql
 
-AM_CFLAGS = @PTHREAD_CFLAGS@ @LFS_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@  @PROTOBUF_C_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -DVERSION='"@PACKAGE_VERSION@"' 
-AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -Igeos-fallback
+AM_CFLAGS = @PTHREAD_CFLAGS@ @LFS_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@  @PROTOBUF_C_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -DVERSION='"@PACKAGE_VERSION@"' @LUA_INCLUDE@ 
+AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -Igeos-fallback @LUA_INCLUDE@
 
-AM_LDFLAGS = @PTHREAD_CFLAGS@ @ZLIB_LDFLAGS@ @ZLIB_LIBS@ @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @XML2_LDFLAGS@ @BZIP2_LDFLAGS@ @BZIP2_LIBS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ @PROJ_LDFLAGS@ @PROJ_LIBS@ @PROTOBUF_C_LDFLAGS@ @PROTOBUF_C_LIBS@
+AM_LDFLAGS = @PTHREAD_CFLAGS@ @ZLIB_LDFLAGS@ @ZLIB_LIBS@ @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @XML2_LDFLAGS@ @BZIP2_LDFLAGS@ @BZIP2_LIBS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ @PROJ_LDFLAGS@ @PROJ_LIBS@ @PROTOBUF_C_LDFLAGS@ @PROTOBUF_C_LIBS@ -L/usr/lib/x86_64-linux-gnu @LUA_LIB@
 
 osm2pgsql_DATA = default.style 900913.sql
 
diff --git a/README b/README
index 9f99242..b8b2f85 100644
--- a/README
+++ b/README
@@ -64,8 +64,6 @@ To make use of the database generated by this tool you will
 probably also want to install:
 - Mapnik from http://mapnik.org/
 
-
-
 Building
 ========
 Make sure you have installed the development packages for the 
@@ -87,6 +85,11 @@ You must create a PostgreSQL user and a database with the
 PostGIS functions enabled. This requires access as the
 database administrator, normally the 'postgres' user.
 
+PostGIS version 2.0 or greater is suggested for databases in
+production. 1.5.x will work but 2.0 contains enhancements that
+should increase speed and reliability as well as add new features
+that style sheet authors can use.
+
 The default name for this database is 'gis' but this may
 be changed by using the osm2pgsql --database option.
 
@@ -105,11 +108,14 @@ $ sudo -u postgres createuser <username>
 $ sudo -u postgres createdb -E UTF8 -O <username> <dbname>
 $ sudo -u postgres createlang plpgsql <dbname>
 
-Adding the PostGIS extensions. Note the location of the
+Adding the PostGIS extensions.
+$ sudo -u postgres psql -d <dbname> -c "CREATE EXTENSION postgis;"
+
+On older versions of PostGIS you will have to run .sql scripts. Note the location of the
 files may vary.
 
-$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
-$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
+$ sudo -u postgres psql -d <dbname> -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
+$ sudo -u postgres psql -d <dbname> -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
 
 Next we need to give the <username> access to update the postgis
 meta-data tables
@@ -125,30 +131,29 @@ $ sudo psql -u postgres psql -d <dbname> -f 900913.sql
 If you want to use hstore support then you will also need to enable the PostgreSQL
 hstore-new extension.
 
-$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/hstore.sql
+$ sudo -u postgres psql -d <dbname> -c "CREATE EXTENSION hstore;"
 
-On PostgreSQL 9.1 and above, you can install it by running "CREATE EXTENSION hstore;"
-in your database.
+On PostgreSQL versions before 9.1 you need to install the hstore-new extension instead
+
+$ sudo -u postgres psql -d <dbname> -f /usr/share/postgresql/8.4/contrib/hstore-new.sql
 
 Now you can run osm2pgsql to import the OSM data.
 This will perform the following actions:
 
-1) Osm2pgsql connects to database and creates the following 4 tables
+1) osm2pgsql connects to database and creates the following 4 tables
 when used with the default output back-end (pgsql):
    - planet_osm_point
    - planet_osm_line
    - planet_osm_roads
    - planet_osm_polygon
-The prefix "planet_osm" can be changed with the --prefix option, 
-the above is the default.
+The default prefix "planet_osm" can be changed with the --prefix option.
 
 If you are using --slim mode, it will create the following additional 3 tables:
    - planet_osm_nodes
    - planet_osm_ways
    - planet_osm_rels
 
-
-2) Runs an XML parser on the input file (typically planet.osm) 
+2) Runs a parser on the input file (typically planet-latest.osm.pbf)
  and processes the nodes, ways and relations.
 
 3) If a node has a tag declared in the style file then it is 
@@ -176,7 +181,7 @@ Tuning PostgreSQL
 
 For an efficient operation of PostgreSQL you will need to tune the config
 parameters of PostgreSQL from its default values. These are set in the
-config file at /etc/postgresql/8.4/main/postgresql.conf
+config file at /etc/postgresql/9.1/main/postgresql.conf
 
 The values you need to set will depend on the hardware you have available,
 but you will likely need to increase the values for the following parameters:
@@ -262,7 +267,6 @@ subset of all possible tags are stored in the DB. Only ones rendered in
 the osm.xml are actually interesting to mapnik.
 - way = PostGIS geometry describing the physical layout of the object.
 
-
 Querying specific data requires knowlege of SQL and the OSM key/value
 system, e.g.
 
@@ -296,6 +300,5 @@ osm_id  |   highway    |       name
  4019199 | trunk        |
  4238966 | unclassified |
 
-
 See the Postgis docs for details, e.g.
-http://postgis.refractions.net/docs/ch04.html
+http://postgis.net/docs/manual-2.0/reference.html
diff --git a/README_lua.md b/README_lua.md
new file mode 100644
index 0000000..c88f64c
--- /dev/null
+++ b/README_lua.md
@@ -0,0 +1,57 @@
+# Lua tag transformations
+
+osm2pgsql supports [Lua](http://lua.org/) scripts to rewrite tags before they enter the database.
+
+This allows you to unify disparate tagging (for example, `highway=path; foot=yes` and `highway=footway`) and perform complex queries, potentially more efficiently than writing them as rules in your Mapnik or other stylesheet.
+
+## How to
+
+Pass a Lua script to osm2pgsql using the command line switch `--tag-transform-script`:
+
+    osm2pgsql -S your.style --tag-transform-script your.lua --hstore-all extract.osm.pbf
+
+This Lua script needs to implement the following functions:
+
+    function filter_tags_node(tags, num_tags)
+    return filter, tags
+
+    function filter_tags_way(tags, num_tags)
+    return filter, tags, polygon, roads
+
+    function filter_basic_tags_rel(tags, num_tags)
+    return filter, tags
+
+These take a set of tags as a Lua key-value table, and an integer which is the number of tags supplied.
+
+The first return value is `filter`, a flag which you should set to `1` if the way/node/relation should be filtered out and not added to the database, `0` otherwise. (They will still end up in the slim mode tables, but not in the rendering tables)
+
+The second return value is `tags`, a transformed (or unchanged) set of tags.
+
+`filter_tags_way` returns two additional flags. `poly` should be `1` if the way should be treated as a polygon, `0` as a line. `roads` should be `1` if the way should be added to the planet_osm_roads table, `0` otherwise.
+
+    function filter_tags_relation_member(tags, member_tags, 
+        roles, num_members)
+    return filter, tags, member_superseded, boundary, 
+        polygon, roads
+
+The function filter_tags_relation_member is more complex and can handle more advanced relation tagging, such as multipolygons that take their tags from the member ways.
+
+This function is called with the tags from the relation; an set of tags for each of the member ways (member relations and nodes are ignored); the set of roles for each of the member ways; and the number of members. The tag and role sets are both arrays (indexed tables) of hashes (tables).
+
+As usual, it should return a filter flag, and a transformed set of tags to be applied to the relation in later processing.
+
+The third return value, `member_superseded`, is a flag set to `1` if the way has now been dealt with (e.g. outer ways in multipolygon relations, which are superseded by the multipolygon geometry), `0` if it needs to have its own entry in the database (e.g. tagged inner ways).
+
+The fourth and fifth return values, `boundary` and `polygon`, are flags that specify if the relation should be processed as a line, a polygon, or both (e.g. administrative boundaries).
+
+The final return value, `roads`, is `1` if the geometry should be added to the `planet_osm_roads` table.
+
+There is a sample tag transform lua script in the repository as an example, which (nearly) replicates current processing and can be used as a template for one's own scripts.
+
+## In practice
+
+There is inevitably a performance hit with any extra processing. The sample Lua tag transformation is a little slower than the C-based default. However, extensive Lua pre-processing may save you further processing in your Mapnik (or other) stylesheet.
+
+Test your Lua script with small excerpts before applying it to a whole country or even the planet.
+
+Where possible, add new tags, don't replace existing ones; otherwise you will be faced with a reimport if you decide to change your transformation.
diff --git a/build_geometry.cpp b/build_geometry.cpp
index 20523c6..bb160ab 100644
--- a/build_geometry.cpp
+++ b/build_geometry.cpp
@@ -23,8 +23,13 @@
 #include <iostream>
 #include <cstring>
 #include <cstdlib>
+#include <cmath>
 #include <exception>
 
+#if defined(__CYGWIN__)
+#define GEOS_INLINE
+#endif
+
 /* Need to know which geos version we have to work out which headers to include */
 #include <geos/version.h>
 
@@ -118,12 +123,30 @@ char *get_wkt_simple(osmNode *nodes, int count, int polygon) {
     }
 }
 
+// helper method to add the WKT for a geometry to the
+// global wkts list - used primarily for polygons.
+void add_wkt(geom_ptr &geom, double area) {
+    WKTWriter wktw;
+    std::string wkt = wktw.write(geom.get());
+    wkts.push_back(wkt);
+    areas.push_back(area);
+}
+
+// helper method to add the WKT for a line built from a
+// coordinate sequence to the global wkts list.
+void add_wkt_line(GeometryFactory &gf, std::auto_ptr<CoordinateSequence> &segment) {
+    WKTWriter wktw;
+    geom_ptr geom = geom_ptr(gf.createLineString(segment.release()));
+    std::string wkt = wktw.write(geom.get());
+    wkts.push_back(wkt);
+    areas.push_back(0);
+    segment.reset(gf.getCoordinateSequenceFactory()->create((size_t)0, (size_t)2));
+}
 
 size_t get_wkt_split(osmNode *nodes, int count, int polygon, double split_at) {
     GeometryFactory gf;
     std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create((size_t)0, (size_t)2));
     double area;
-    WKTWriter wktw;
     size_t wkt_size = 0;
 
     try
@@ -148,10 +171,8 @@ size_t get_wkt_split(osmNode *nodes, int count, int polygon, double split_at) {
             }
             geom->normalize(); // Fix direction of ring
             area = geom->getArea();
-            std::string wkt = wktw.write(geom.get());
-            wkts.push_back(wkt);
-            areas.push_back(area);
-            wkt_size++;
+            add_wkt(geom, area);
+
         } else {
             if (coords->getSize() < 2)
                 return 0;
@@ -161,21 +182,47 @@ size_t get_wkt_split(osmNode *nodes, int count, int polygon, double split_at) {
             segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create((size_t)0, (size_t)2));
             segment->add(coords->getAt(0));
             for(unsigned i=1; i<coords->getSize(); i++) {
-                segment->add(coords->getAt(i));
-                distance += coords->getAt(i).distance(coords->getAt(i-1));
-                if ((distance >= split_at) || (i == coords->getSize()-1)) {
-                    geom = geom_ptr(gf.createLineString(segment.release()));
-                    std::string wkt = wktw.write(geom.get());
-                    wkts.push_back(wkt);
-                    areas.push_back(0);
-                    wkt_size++;
-                    distance=0;
-                    segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create((size_t)0, (size_t)2));
-                    segment->add(coords->getAt(i));
+                const Coordinate this_pt = coords->getAt(i);
+                const Coordinate prev_pt = coords->getAt(i-1);
+                const double delta = this_pt.distance(prev_pt);
+                // figure out if the addition of this point would take the total 
+                // length of the line in `segment` over the `split_at` distance.
+                const size_t splits = std::floor((distance + delta) / split_at);
+
+                if (splits > 0) {
+                  // use the splitting distance to split the current segment up
+                  // into as many parts as necessary to keep each part below
+                  // the `split_at` distance.
+                  for (size_t i = 0; i < splits; ++i) {
+                    double frac = (double(i + 1) * split_at - distance) / delta;
+                    const Coordinate interpolated(frac * (this_pt.x - prev_pt.x) + prev_pt.x,
+                                                  frac * (this_pt.y - prev_pt.y) + prev_pt.y);
+                    segment->add(interpolated);
+                    add_wkt_line(gf, segment);
+                    segment->add(interpolated);
+                  }
+                  // reset the distance based on the final splitting point for
+                  // the next iteration.
+                  distance = segment->getAt(0).distance(this_pt);
+
+                } else {
+                  // if not split then just push this point onto the sequence
+                  // being saved up.
+                  distance += delta;
+                }
+
+                // always add this point
+                segment->add(this_pt);
+
+                // on the last iteration, close out the line.
+                if (i == coords->getSize()-1) {
+                  add_wkt_line(gf, segment);
                 }
             }
         }
 
+        // ensure the number of wkts in the global list is accurate.
+        wkt_size = wkts.size();
     }
     catch (std::bad_alloc)
     {
diff --git a/configure.ac b/configure.ac
index ccc72e8..25ad2f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(osm2pgsql, 0.82.0)
+AC_INIT(osm2pgsql, 0.84.0)
 
 dnl Required autoconf version
 AC_PREREQ(2.61)
@@ -118,9 +118,17 @@ fi
 dnl Check for pthread library
 AX_PTHREAD(,[AC_MSG_ERROR([no])])
 
+AX_PROG_LUA([5.0],[],[
+    AX_LUA_HEADERS([
+        AX_LUA_LIBS([
+            AC_DEFINE([HAVE_LUA], [1], [Requirements for lua are met])
+            HAVE_LUA=yes
+        ],[AC_MSG_WARN([cannot find Lua libs])])
+    ],[AC_MSG_WARN([cannot find Lua includes])])
+],[AC_MSG_WARN([cannot find Lua interpreter])])
 
 dnl Generate Makefile
-AC_OUTPUT(Makefile legacy/Makefile)
+AC_OUTPUT(Makefile)
 
 if test "$BUILD_READER_PBF" != "yes"
 then
@@ -131,3 +139,14 @@ To enable PBF support, the protobuf library and compiler are required.
 Look for packages named: libprotobuf-c0-dev protobuf-c-compiler
 ])
 fi
+
+if test "$HAVE_LUA" != "yes"
+then
+    AC_MSG_WARN([
+lua libraries not found. You will NOT be able to use lua scripts for tag transform.
+
+To enable lua support, the lua interpreter and libraries are required. 
+Look for packages named: lua5.2 liblua5.2-dev
+])
+fi
+
diff --git a/cygpkg.sh b/cygpkg.sh
new file mode 100644
index 0000000..e1a37a3
--- /dev/null
+++ b/cygpkg.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+#  Author:       Jason Huntley
+#  Email:        onepremise at gmail.com
+#  Description:  Cygwin Package script
+#
+#  Change Log
+#
+#  Date                   Description                 Initials
+#-------------------------------------------------------------
+#  04-11-13             Initial Coding                  JAH
+#=============================================================
+
+if [ ! -e "cygwin-package" ]; then
+  mkdir cygwin-package
+fi
+
+echo
+echo Copying Executable...
+echo
+
+cp -rfv default.style cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
+cp -rfv 900913.sql cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
+cp -rfv README cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
+cp -rfv .libs/osm2pgsql.exe cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
+
+echo
+echo Copying Dependent Libraries...
+echo
+
+cp -rfv /bin/cygcrypt*.dll cygwin-package
+cp -rfv /bin/cyggcc*.dll cygwin-package
+cp -rfv /usr/local/bin/cyggeos*.dll cygwin-package
+cp -rfv /bin/cygiconv*.dll cygwin-package
+cp -rfv /bin/cygintl*.dll cygwin-package
+cp -rfv /bin/cyglber*.dll cygwin-package
+cp -rfv /bin/cygldap*.dll cygwin-package
+cp -rfv /bin/cyglzma*.dll cygwin-package
+cp -rfv /bin/cygpq*.dll cygwin-package
+cp -rfv /usr/local/bin/cygproj*.dll cygwin-package
+cp -rfv /usr/local/bin/cygproto*.dll cygwin-package
+cp -rfv /bin/cygsasl*.dll cygwin-package
+cp -rfv /bin/cygssl*.dll cygwin-package
+cp -rfv /bin/cygstdc++**.dll cygwin-package
+cp -rfv /bin/cygwin*.dll cygwin-package
+cp -rfv /bin/cygxml2*.dll cygwin-package
+cp -rfv /bin/cygz*.dll cygwin-package
+
+echo
+echo Creating Archive...
+echo
+
+zip -r9 cygwin-package.zip cygwin-package
+
+echo
+echo Packaging Complete.
+echo
+
+exit 0
diff --git a/debian/README b/debian/README
deleted file mode 100644
index 6d53162..0000000
--- a/debian/README
+++ /dev/null
@@ -1,9 +0,0 @@
-The Debian Package osm2pgsql
-----------------------------
-
-Debian packaging stuff created to allow building a stand-alone osm2pgsql package.
-
-Unrelated to Joerg Ostertag's "openstreetmap-utils" package which also contains
-osm2pgsql!
-
- -- Frederik Ramm <frederik at remote.org>  Fri, 13 Mar 2009 00:14:15 +0100
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 003c747..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,88 +0,0 @@
-osm2pgsql (0.80.0-13~precise1) precise; urgency=low
-
-  * Update from upstream to svn version 28638
-    - Implement a file based node lookup in slim mode
-    - fix segfault if out of memory
-
- -- Kai Krueger <kakrueger at gmail.com>  Sun, 26 Aug 2012 10:00:00 +0000
-
-osm2pgsql (0.80.0-12~precise1) precise; urgency=low
-
-  * Update from upstream to svn version 28406
-
- -- Kai Krueger <kakrueger at gmail.com>  Thu, 24 May 2012 10:00:00 +0000
-
-osm2pgsql (0.80.0-11~precise1) precise; urgency=low
-
-  * Be less agressive on tile expiry
-  * Fix gazeteer
-
- -- Kai Krueger <kakrueger at gmail.com>  Sat, 14 Jan 2012 10:00:00 +0000
-
-osm2pgsql (0.80.0-10~lucid1) lucid; urgency=low
-
-  * Improve handling of multiple processes. Gracefully fallback if creating of helper processes fails
-  * Improve speed when fsync is enabled
-  * Fix expiry code when using multiple processes
-  * Introduce a --drop option, if updating is not needed but using --slim for memory saving purposes
-  * Create an additional index on planet_osm_polygon to improve rendering speed
-
- -- Kai Krueger <kakrueger at gmail.com>  Sun, 18 Dec 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0-9~lucid1) lucid; urgency=low
-
-  * Bugfix: incorrectly round lat / lon to 2 s.f. in -l projection
-  * Reduce virtual memory usage to reduce chance of out of memory errors
-
- -- Kai Krueger <kakrueger at gmail.com>  Thu, 3 Nov 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0-8~oneiric1) oneiric; urgency=low
-
-  * Bugfix: Did not handle cache values larger than 2Gb correctly
-
- -- Kai Krueger <kakrueger at gmail.com>  Sat, 22 Oct 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0-7~natty2) natty; urgency=low
-
-  * Memory optimize the node cache to handle larger extracts
-  * parallelize parts of the import and diff processing
-
- -- Kai Krueger <kakrueger at gmail.com>  Sun, 16 Oct 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0-6~oneiric1) oneiric; urgency=low
-
-  * Add a script to add permissions to a db afterwards
-  
-  * Handle postgresql 9.1
-
- -- Kai Krueger <kakrueger at gmail.com>  Sun, 09 Oct 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0-5~oneiric1) oneiric; urgency=low
-
-  * Fix debian package scripts.
-
- -- Kai Krueger <kakrueger at gmail.com>  Fri, 07 Oct 2011 10:00:00 +0000
-
-osm2pgsql (0.80.0) lucid; urgency=low
-
-  * version 0.80 does not use intarray any longer.
-
- -- Frederik Ramm <frederik at remote.org>  Wed, 03 Aug 2011 15:03:42 +0200
-
-osm2pgsql (0.70.5-karmic1) karmic; urgency=low
-
-  * 0.70.5 build
-
- -- Frederik Ramm <frederik at remote.org>  Sat, 29 Jan 2011 12:11:42 +0000
-
-osm2pgsql (0.69) jaunty; urgency=low
-
-  * v0.69
-
- -- Frederik Ramm <frederik at remote.org>  Wed, 04 Nov 2009 09:51:59 +0100
-
-osm2pgsql (0.65) unstable; urgency=low
-
-  * Initial standalone debian package
-
- -- Frederik Ramm <frederik at remote.org>  Fri, 13 Mar 2009 00:14:15 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7f8f011..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/debian/control b/debian/control
deleted file mode 100644
index f0d4ac7..0000000
--- a/debian/control
+++ /dev/null
@@ -1,23 +0,0 @@
-Source: osm2pgsql
-Section: utils
-Priority: optional
-Maintainer: Frederik Ramm <frederik at remote.org>
-Build-Depends: debhelper (>= 7), libgeos-dev, libxml2-dev, libpq-dev, proj | libproj0, libbz2-dev, automake, autoconf, libtool, protobuf-c-compiler, libprotobuf-c0-dev
-Standards-Version: 3.9.3
-
-Package: osm2pgsql
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Recommends: postgresql, postgresql-8.4-postgis | postgresql-9.1-postgis, openstreetmap-postgis-db-setup
-Conflicts:  openstreetmap-utils
-Description: Openstreetmap data to PostgreSQL converter
- osm2pgsql imports OpenStreetMap data into a PostGIS database.
-
-Package: openstreetmap-postgis-db-setup
-Architecture: all
-Depends: ${misc:Depends}, debconf, postgis, postgresql-8.4-postgis | postgresql-9.1-postgis, postgresql-contrib
-Recommends: osm2pgsql
-Suggests: libapache2-mod-tile, openstreetmap-mapnik-data
-Description: Provides setup scripts to create a postgis database for OpenStreetMap
- The database can be used with e.g. osm2pgsql to load data and mapnik for rendering
- It sets up a database named 'gis'
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 02bbe06..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,4 +0,0 @@
-Licensed under GPL v2 or later
-The full license text can be found at /usr/share/common-licenses/GPL-2
-Various authors, as per http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index 4c79d0d..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/share/osm2pgsql
diff --git a/debian/manpages b/debian/manpages
deleted file mode 100644
index b351308..0000000
--- a/debian/manpages
+++ /dev/null
@@ -1 +0,0 @@
-debian/osm2pgsql.1
diff --git a/debian/openstreetmap-postgis-db-setup.config b/debian/openstreetmap-postgis-db-setup.config
deleted file mode 100755
index 7e37410..0000000
--- a/debian/openstreetmap-postgis-db-setup.config
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-set -e
-
-. /usr/share/debconf/confmodule
-
-db_input high openstreetmap-postgis-db-setup/initdb || true
-db_input high openstreetmap-postgis-db-setup/dbname || true
-db_input high openstreetmap-postgis-db-setup/grant_user || true
-db_go || true
-
-db_get openstreetmap-postgis-db-setup/initdb || true
-INIT_DB=$RET
-db_get openstreetmap-postgis-db-setup/grant_user || true
-GRANT_USER=$RET
-
-cat <<EOF > /etc/default/openstreetmap-postgis-db-setup
-# Default settings for openstreetmap-mapnik-data
-INIT_DB="$INIT_DB"
-GRANT_USER="$GRANT_USER"
-EOF
-
diff --git a/debian/openstreetmap-postgis-db-setup.install b/debian/openstreetmap-postgis-db-setup.install
deleted file mode 100644
index 44e8216..0000000
--- a/debian/openstreetmap-postgis-db-setup.install
+++ /dev/null
@@ -1,2 +0,0 @@
-install-postgis-osm-db.sh /usr/bin/
-install-postgis-osm-user.sh /usr/bin/
\ No newline at end of file
diff --git a/debian/openstreetmap-postgis-db-setup.postinst b/debian/openstreetmap-postgis-db-setup.postinst
deleted file mode 100755
index 4b96fbe..0000000
--- a/debian/openstreetmap-postgis-db-setup.postinst
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh 
-# postinst script for openstreetmap-mapnik-data
-#
-# see: dh_installdeb(1)
-
-set -e
-
-case "$1" in
-    configure)
-
-        . /usr/share/debconf/confmodule
-
-	db_get openstreetmap-postgis-db-setup/initdb || true
-	INIT_DB=$RET
-	
-	db_get openstreetmap-postgis-db-setup/dbname || true
-	DBNAME=$RET
-	
-	db_get openstreetmap-postgis-db-setup/grant_user || true
-	GRANT_USER=$RET
-
-	#echo "# Default settings for openstreetmap-mapnik-data" > /etc/default/openstreetmap-mapnik-data
-	#echo "GRANT_USER='$GRANT_USER' " >> /etc/default/openstreetmap-mapnik-data
-	#echo "INIT_DB='$INIT_DB' " >> /etc/default/openstreetmap-mapnik-data
-
-    # only call the install postgis script on the first configuration
-    # we don't want to delete and recreate the db on upgrades of osm2pgsql
-    if [ -z "$2" ] ; then
-	    if [ "x$INIT_DB" = "xtrue" ] ; then
-            export DBNAME GRANT_USER
-	        /usr/bin/install-postgis-osm-db.sh || true
-	    fi
-    fi
-	true
-	;;
-    
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/openstreetmap-postgis-db-setup.templates b/debian/openstreetmap-postgis-db-setup.templates
deleted file mode 100644
index bb29a2a..0000000
--- a/debian/openstreetmap-postgis-db-setup.templates
+++ /dev/null
@@ -1,23 +0,0 @@
-Template: openstreetmap-postgis-db-setup/initdb
-Type: boolean
-Default: true
-Description: Do you want to create a postgis db?
- Do you want these scripts to create and setup a new postgis 
- database ready to be used with e.g. Osm2pgsql.
- WARNING: This will delete an existing db
-
-Template: openstreetmap-postgis-db-setup/dbname
-Type: string
-Default: gis
-Description: Name of the database to create:
- If you don't use the default name, you might need to adapt programs
- and scripts to use the new name
-
-Template: openstreetmap-postgis-db-setup/grant_user
-Type: string
-Default: www-data
-Description: Other users that should have access to the db:
- Please specify which users should have access to the newly created db.
- You will want the user www-data for rendering and your own user name
- to import data into the db. The list of users is blank separated: 
- E.g. "www-data peter"
diff --git a/debian/osm2pgsql.install b/debian/osm2pgsql.install
deleted file mode 100644
index 99696ef..0000000
--- a/debian/osm2pgsql.install
+++ /dev/null
@@ -1,2 +0,0 @@
-default.style /usr/share/osm2pgsql
-osm2pgsql /usr/bin/
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index ef07506..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-configure: configure-stamp
-configure-stamp: 
-	dh_testdir
-
-	# Add here commands to configure the package.
-
-	touch configure-stamp
-
-build: build-arch build-indep
-build-arch: build-stamp
-build-indep: build-stamp
-build-stamp: configure-stamp  
-	dh_testdir
-
-	# Add here commands to compile the package.
-	./autogen.sh
-	automake --add-missing
-	aclocal
-	autoreconf -f
-	./configure --prefix=/usr --datadir=/usr/share/osm2pgsql
-	$(MAKE)
-	#docbook-to-man debian/osm2pgsql.sgml > osm2pgsql.1
-
-	touch $@
-
-clean: 
-	dh_testdir
-	dh_testroot
-	rm -f build-stamp configure-stamp
-
-	# Add here commands to clean up after the build process.
-	$(MAKE) clean || /bin/true
-
-	dh_clean 
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_prep 
-	dh_installdirs
-
-	# Add here commands to install the package into debian/osm2pgsql.
-	$(MAKE) DESTDIR=$(CURDIR)/debian/osm2pgsql install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-	dh_installchangelogs 
-	dh_installdocs
-	dh_installexamples
-	dh_install
-#	dh_installmenu
-	dh_installdebconf	
-#	dh_installlogrotate
-#	dh_installemacsen
-#	dh_installpam
-#	dh_installmime
-#	dh_python
-#	dh_installinit
-#	dh_installcron
-#	dh_installinfo
-	dh_installman
-	dh_link
-	dh_strip
-	dh_compress
-	dh_fixperms
-#	dh_perl
-#	dh_makeshlibs
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 89ae9db..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (native)
diff --git a/default.style b/default.style
index 80b6adb..1c53f73 100644
--- a/default.style
+++ b/default.style
@@ -1,124 +1,226 @@
-# This is the style file that matches the old version of osm2pgsql, which
-# did not make distinctions between tags for nodes and for ways. There are a
-# number of optimisations that can be applied here. Firstly, certain tags
-# only apply to only nodes or only ways. By fixing this we reduce the amount
-# of useless data loaded into the DB, which is a good thing. Possible
-# optimisations for the future:
-
-# 1. Generate this file directly from the mapnik XML config, so it's always
-# optimal
-
-# 2. Extend it so it can understand that highway=tertiary is for ways and
-# highway=bus_stop is for nodes
-
-# Flags field isn't used much yet, expect if it contains the text "polygon"
-# it indicates the shape is candidate for the polygon table. In the future I
-# would like to be able to add directives like "nocache" which tells
-# osm2pgsql that it is unlikely this node will be used by a way and so it
-# doesn't need to be stored (eg coastline nodes). While in essence an
-# optimisation hack, for --slim mode it doesn't matter if you're wrong, but
-# in non-slim you might break something!
-
-# Also possibly an ignore flag, for things like "note" and "source" which
-# can simply be deleted. (In slim mode this is, does not apply to non-slim
-# obviously)
-
-# OsmType  Tag          DataType     Flags
-node,way   note         text         delete   # These tags can be long but are useless for rendering
-node,way   source       text         delete   # This indicates that we shouldn't store them
-node,way   created_by   text         delete
-
-node,way   access       text         linear
-node,way   addr:housename      text  linear
-node,way   addr:housenumber    text  linear
-node,way   addr:interpolation  text  linear 
-node,way   admin_level  text         linear
-node,way   aerialway    text         linear
-node,way   aeroway      text         polygon
-node,way   amenity      text         nocache,polygon
-node,way   area         text         # hard coded support for area=1/yes => polygon is in osm2pgsql
-node,way   barrier      text         linear
-node,way   bicycle      text         nocache
-node,way   brand        text         linear
-node,way   bridge       text         linear
-node,way   boundary     text         linear
-node,way   building     text         polygon
-node       capital      text         linear
-node,way   construction text         linear
-node,way   covered      text         linear
-node,way   culvert      text         linear
-node,way   cutting      text         linear
-node,way   denomination text         linear
-node,way   disused      text         linear
-node       ele          text         linear
-node,way   embankment   text         linear
-node,way   foot         text         linear
-node,way   generator:source    text  linear
-node,way   harbour      text         polygon
-node,way   highway      text         linear
-node,way   historic     text         polygon
-node,way   horse        text         linear
-node,way   intermittent text         linear
-node,way   junction     text         linear
-node,way   landuse      text         polygon
-node,way   layer        text         linear
-node,way   leisure      text         polygon
-node,way   lock         text         linear
-node,way   man_made     text         polygon
-node,way   military     text         polygon
-node,way   motorcar     text         linear
-node,way   name         text         linear
-node,way   natural      text         polygon  # natural=coastline tags are discarded by a hard coded rule in osm2pgsql
-node,way   office       text         polygon
-node,way   oneway       text         linear
-node,way   operator     text         linear
-node,way   place        text         polygon
-node       poi          text
-node,way   population   text         linear
-node,way   power        text         polygon
-node,way   power_source text         linear
-node,way   public_transport text     polygon
-node,way   railway      text         linear
-node,way   ref          text         linear
-node,way   religion     text         nocache
-node,way   route        text         linear
-node,way   service      text         linear
-node,way   shop         text         polygon
-node,way   sport        text         polygon
-node,way   surface      text         linear
-node,way   toll         text         linear
-node,way   tourism      text         polygon
-node,way   tower:type   text         linear
-way        tracktype    text         linear
-node,way   tunnel       text         linear
-node,way   water        text         polygon
-node,way   waterway     text         polygon
-node,way   wetland      text         polygon
-node,way   width        text         linear
-node,way   wood         text         linear
-node,way   z_order      int4         linear # This is calculated during import
-way        way_area     real                # This is calculated during import
-
-# If you're interested in bicycle routes, you may want the following fields
-# To make these work you need slim mode or the necessary data won't be remembered.
-#way       lcn_ref      text     linear
-#way       rcn_ref      text     linear
-#way       ncn_ref      text     linear
-#way       lcn          text     linear
-#way       rcn          text     linear
-#way       ncn          text     linear
-#way       lwn_ref      text     linear
-#way       rwn_ref      text     linear
-#way       nwn_ref          text     linear
-#way       lwn              text     linear
-#way       rwn              text     linear
-#way       nwn              text     linear
-#way       route_pref_color text     linear
-#way       route_name       text     linear
-
-# The following entries can be used with the --extra-attributes option
-# to include the username, userid, version & timstamp in the DB
-#node,way  osm_user       text
-#node,way  osm_uid        text
-#node,way  osm_version    text
-#node,way  osm_timestamp  text
+# This is the default osm2pgsql .style file that comes with osm2pgsql.
+#
+# A .style file has 4 columns that define how OSM objects end up in tables in
+# the database and what columns are created. It interacts with the command-line
+# hstore options.
+#
+# Columns
+# =======
+#
+# OsmType: This is either "node", "way" or "node,way" and indicates if this tag
+# applies to nodes, ways, or both.
+#
+# Tag: The tag
+#
+# DataType: The type of the column to be created. Normally "text"
+#
+# Flags: Flags that indicate what table the OSM object is moved into.
+#
+# There are 5 possible flags. These flags are used both to indicate if a column
+# should be created, and if ways with the tag are assumed to be areas. The area
+# assumptions can be overridden with an area=yes/no tag
+#
+# polygon - Create a column for this tag, and objects the tag with are areas
+#
+# linear - Create a column for this tag
+#
+# phstore - Don't create a column for this tag, but objects with the tag are areas
+#
+# delete - Drop this tag completely and don't create a column for it. This also
+# prevents the tag from being added to hstore columns
+#
+# nocache - Deprecated and does nothing
+#
+# If an object has a tag that indicates it is an area or has area=yes/1,
+# osm2pgsql will try to turn it into an area. If it succeeds, it places it in
+# the polygon table. If it fails (e.g. not a closed way) it places it in the
+# line table.
+#
+# Nodes are never placed into the polygon or line table and are always placed in
+# the point table.
+#
+# Hstore
+# ======
+#
+# The options --hstore, --hstore-match-only, and --hstore-all interact with
+# the .style file.
+#
+# With --hstore any tags without a column will be added to the hstore column.
+# This will also cause all objects to be kept.
+#
+# With --hstore-match-only the behavior for tags is the same, but objects are
+# only kept if they have a non-NULL value in one of the columns.
+#
+# With --hstore-all all tags are added to the hstore column unless they appear
+# in the style file with a delete flag, causing duplication between the normal
+# columns and the hstore column.
+#
+# Special database columns
+# ========================
+#
+# There are some special database columns that if present in the .style file
+# will be populated by osm2pgsql.
+#
+# These are
+#
+# z_order - datatype int4
+#
+# way_area - datatype real. The area of the way, in the units of the projection
+# (e.g. square mercator meters). Only applies to areas
+#
+# osm_user, osm_uid, osm_version, osm_timestamp - datatype text. Used with the
+# --extra-attributes option to include metadata in the database. If importing
+# with both --hstore and --extra-attributes the meta-data will end up in the
+# tags hstore column regardless of the style file.
+
+# OsmType  Tag          DataType     Flags
+node,way   access       text         linear
+node,way   addr:housename      text  linear
+node,way   addr:housenumber    text  linear
+node,way   addr:interpolation  text  linear
+node,way   admin_level  text         linear
+node,way   aerialway    text         linear
+node,way   aeroway      text         polygon
+node,way   amenity      text         polygon
+node,way   area         text         # hard coded support for area=1/yes => polygon is in osm2pgsql
+node,way   barrier      text         linear
+node,way   bicycle      text
+node,way   brand        text         linear
+node,way   bridge       text         linear
+node,way   boundary     text         linear
+node,way   building     text         polygon
+node       capital      text         linear
+node,way   construction text         linear
+node,way   covered      text         linear
+node,way   culvert      text         linear
+node,way   cutting      text         linear
+node,way   denomination text         linear
+node,way   disused      text         linear
+node       ele          text         linear
+node,way   embankment   text         linear
+node,way   foot         text         linear
+node,way   generator:source    text  linear
+node,way   harbour      text         polygon
+node,way   highway      text         linear
+node,way   historic     text         polygon
+node,way   horse        text         linear
+node,way   intermittent text         linear
+node,way   junction     text         linear
+node,way   landuse      text         polygon
+node,way   layer        text         linear
+node,way   leisure      text         polygon
+node,way   lock         text         linear
+node,way   man_made     text         polygon
+node,way   military     text         polygon
+node,way   motorcar     text         linear
+node,way   name         text         linear
+node,way   natural      text         polygon  # natural=coastline tags are discarded by a hard coded rule in osm2pgsql
+node,way   office       text         polygon
+node,way   oneway       text         linear
+node,way   operator     text         linear
+node,way   place        text         polygon
+node       poi          text
+node,way   population   text         linear
+node,way   power        text         polygon
+node,way   power_source text         linear
+node,way   public_transport text     polygon
+node,way   railway      text         linear
+node,way   ref          text         linear
+node,way   religion     text         nocache
+node,way   route        text         linear
+node,way   service      text         linear
+node,way   shop         text         polygon
+node,way   sport        text         polygon
+node,way   surface      text         linear
+node,way   toll         text         linear
+node,way   tourism      text         polygon
+node,way   tower:type   text         linear
+way        tracktype    text         linear
+node,way   tunnel       text         linear
+node,way   water        text         polygon
+node,way   waterway     text         polygon
+node,way   wetland      text         polygon
+node,way   width        text         linear
+node,way   wood         text         linear
+node,way   z_order      int4         linear # This is calculated during import
+way        way_area     real                # This is calculated during import
+
+# Area tags
+# We don't make columns for these tags, but objects with them are areas.
+# Mainly for use with hstore
+way         abandoned:aeroway       text    phstore
+way         abandoned:amenity       text    phstore
+way         abandoned:building      text    phstore
+way         abandoned:landuse       text    phstore
+way         abandoned:power         text    phstore
+way         area:highway            text    phstore
+
+# Deleted tags
+# These are tags that are generally regarded as useless for most rendering.
+# Most of them are from imports or intended as internal information for mappers
+# Some of them are automatically deleted by editors.
+# If you want some of them, perhaps for a debugging layer, just delete the lines.
+
+# These tags are used by mappers to keep track of data.
+# They aren't very useful for rendering.
+node,way    note                    text    delete
+node,way    note:*                  text    delete
+node,way    source                  text    delete
+node,way    source_ref              text    delete
+node,way    source:*                text    delete
+node,way    attribution             text    delete
+node,way    comment                 text    delete
+node,way    fixme                   text    delete
+
+# Tags generally dropped by editors, not otherwise covered
+node,way    created_by              text    delete
+node,way    odbl                    text    delete
+node,way    odbl:note               text    delete
+node,way    SK53_bulk:load          text    delete
+
+# Lots of import tags
+# TIGER (US)
+node,way    tiger:*                 text    delete
+
+# NHD (US)
+# NHD has been converted every way imaginable
+node,way    NHD:*                   text    delete
+node,way    nhd:*                   text    delete
+
+# GNIS (US)
+node,way    gnis:*                  text    delete
+
+# Geobase (CA)
+node,way    geobase:*               text    delete
+# NHN (CA)
+node,way    accuracy:meters         text    delete
+node,way    sub_sea:type            text    delete
+node,way    waterway:type           text    delete
+
+# KSJ2 (JA)
+# See also note:ja and source_ref above
+node,way    KSJ2:*                  text    delete
+# Yahoo/ALPS (JA)
+node,way    yh:*                    text    delete
+
+# osak (DK)
+node,way    osak:*                  text    delete
+
+# kms (DK)
+node,way    kms:*                   text    delete
+
+# ngbe (ES)
+# See also note:es and source:file above
+node,way    ngbe:*                  text    delete
+
+# naptan (UK)
+node,way    naptan:*                text    delete
+
+# Corine (CLC) (Europe)
+node,way    CLC:*                   text    delete
+
+# misc
+node,way    3dshapes:ggmodelk       text    delete
+node,way    AND_nosr_r              text    delete
+node,way    import                  text    delete
+node,way    it:fvg:*                text    delete
diff --git a/docs/nodecachefilereader.1 b/docs/nodecachefilereader.1
index cd48225..1d28c64 100644
--- a/docs/nodecachefilereader.1
+++ b/docs/nodecachefilereader.1
@@ -18,7 +18,7 @@ This manual page documents briefly the
 command.
 .PP
 .B nodecachefilereader
-allows you to inspect and test osm2pgsql's custome node database.
+allows you to inspect and test osm2pgsql's custom node database.
 .PP
 .SH OPTIONS
 If only the filename of the node cache is given, nodecachefilereader
@@ -34,4 +34,4 @@ information stored (latitude / longitude) about those nodes in the database
 .SH AUTHOR
 nodecachefilereader was written by Kai Krueger and other
 OpenStreetMap project members.
-.PP
\ No newline at end of file
+.PP
diff --git a/docs/osm2pgsql.1 b/docs/osm2pgsql.1
index c026f6b..862dfec 100644
--- a/docs/osm2pgsql.1
+++ b/docs/osm2pgsql.1
@@ -44,9 +44,9 @@ Add the OSM file into the database without removing
 existing data.
 .TP
 \fB\-b\fR|\-\-bbox
-Apply a bounding box filter on the imported data
+Apply a bounding box filter on the imported data.
 Must be specified as: minlon,minlat,maxlon,maxlat
-e.g. \fB\-\-bbox\fR \fB\-0\fR.5,51.25,0.5,51.75
+e.g. \fB\-\-bbox\fR \fB\-0.5,51.25,0.5,51.75\fR
 .TP
 \fB\-c\fR|\-\-create
 Remove existing data from the database. This is the
@@ -58,49 +58,49 @@ to (default: gis).
 .TP
 \fB\-i\fR|\-\-tablespace\-index tablespacename
 Store all indices in a separate PostgreSQL tablespace named by this parameter.
-This allows to e.g. store the indices on faster storage like SSDs
+This allows to e.g. store the indices on faster storage like SSDs.
 .TP
 \fB\ \fR\-\-tablespace\-main\-data tablespacename
-Store the data tables (non slim) in the given tablespace
+Store the data tables (non slim) in the given tablespace.
 .TP
 \fB\ \fR\-\-tablespace\-main\-index tablespacename
-Store the indices of the main tables (non slim) in the given tablespace
+Store the indices of the main tables (non slim) in the given tablespace.
 .TP
 \fB\ \fR\-\-tablespace\-slim\-data tablespacename
-Store the slim mode tables in the given tablespace
+Store the slim mode tables in the given tablespace.
 .TP
 \fB\ \fR\-\-tablespace\-slim\-index tablespacename
-Store the indices of the slim mode tables in the given tablespace
+Store the indices of the slim mode tables in the given tablespace.
 .TP
 \fB\-l\fR|\-\-latlong
 Store data in degrees of latitude & longitude.
 .TP
 \fB\-m\fR|\-\-merc
-Store data in proper spherical Mercator (the default)
+Store data in proper spherical Mercator (the default).
 .TP
 \fB\-M\fR|\-\-oldmerc
-Store data in the legacy OSM Mercator format
+Store data in the legacy OSM Mercator format.
 .TP
 \fB\-E\fR|\-\-proj num
 Use projection EPSG:num
 .TP
 \fB\-u\fR|\-\-utf8\-sanitize
-Repair bad UTF8 input data (present in planet
+Repair bad UTF-8 input data (present in planet
 dumps prior to August 2007). Adds about 10% overhead.
 .TP
 \fB\-p\fR|\-\-prefix prefix_string
-Prefix for table names (default planet_osm)
+Prefix for table names (default: planet_osm).
 .TP
 \fB\-r\fR|\-\-input\-reader format
 Select input format reader. Available choices are \fBlibxml2\fR 
 (default) and \fBprimitive\fR for OSM XML format files, \fBo5m\fR for o5m formatted file
-and \fBpbf\fR for OSM PBF binary format (may not be available on all platforms)
+and \fBpbf\fR for OSM PBF binary format (may not be available on all platforms).
 .TP
 \fB\-s\fR|\-\-slim
 Store temporary data in the database. Without this mode, all temporary data is stored in
-RAM and if you do not have enough the import will not succeed successfully. With slim mode,
+RAM and if you do not have enough the import will not work successfully. With slim mode,
 you should be able to import the data even on a system with limited RAM, although if you
-do no have enough RAM to cache at least all of the nodes, the time to import the data
+do not have enough RAM to cache at least all of the nodes, the time to import the data
 will likely be greatly increased.
 .TP
 \fB\  \fR\-\-drop
@@ -109,7 +109,7 @@ greatly reduce the size of the database, as the slim mode tables typically are t
 size, if not slightly bigger than the main tables. It does not, however, reduce the
 maximum spike of disk usage during import. It can furthermore increase the import speed,
 as no indices need to be created for the slim mode tables, which (depending on hardware)
-can nearly half import time. Slim mode tables however have to be persistent if you want
+can nearly halve import time. Slim mode tables however have to be persistent if you want
 to be able to update your database, as these tables are needed for diff processing.
 .TP
 \fB\-S\fR|\-\-style /path/to/style
@@ -169,19 +169,19 @@ This includes the username, userid, timestamp and version.
 Note: this option also requires additional entries in your style file.
 .TP
 \fB\-k\fR|\-\-hstore
-Add tags without column to an additional hstore (key/value) column to PostgreSQL tables
+Add tags without column to an additional hstore (key/value) column to PostgreSQL tables.
 .TP
 \fB\-j\fR|\-\-hstore\-all
-Add all tags to an additional history (key/value) column in PostgreSQL tables
+Add all tags to an additional hstore (key/value) column in PostgreSQL tables.
 .TP
 \fB\-z\fR|\-\-hstore\-column key_name
-Add an additional history (key/value) column containing all tags
+Add an additional hstore (key/value) column containing all tags
 that start with the specified string, egg --hstore-column "name:" will
 produce an extra hstore column that contains all name:xx tags
 .TP
 \fB\  \fR\-\-hstore\-match\-only
 Only keep objects that have a value in one of the columns
-(normal action with --hstore is to keep all objects)
+(normal action with --hstore is to keep all objects).
 .TP
 \fB\  \fR\-\-hstore-add-index
 Create indices for the hstore columns during import.
@@ -220,20 +220,20 @@ server.
 \fB\-I\fR|\-\-disable-parallel-indexing
 By default osm2pgsql initiates the index building on all tables in parallel to increase
 performance. This can be disadvantages on slow disks, or if you don't have
-enough ram for PostgreSQL to perform up to 7 parallel index building processes
-(e.g. because maintenance_work_mem is set high)
+enough RAM for PostgreSQL to perform up to 7 parallel index building processes
+(e.g. because maintenance_work_mem is set high).
 .TP
 \fB\  \fR\-\-flat-nodes /path/to/nodes.cache
 The flat-nodes mode is a separate method to store slim mode node information on disk.
 Instead of storing this information in the main PostgreSQL database, this mode creates
 its own separate custom database to store the information. As this custom database
 has application level knowledge about the data to store and is not general purpose,
-it can store the data much more efficient. Storing the node information for the full
+it can store the data much more efficiently. Storing the node information for the full
 planet requires about 100GB in PostgreSQL, the same data is stored in only ~16GB using
 the flat-nodes mode. This can also increase the speed of applying diff files. This option
 activates the flat-nodes mode and specifies the location of the database file. It is a
 single large > 16GB file. This mode is only recommended for full planet imports
-as it doesn't work well with small extracts. The default is disabled
+as it doesn't work well with small extracts. The default is disabled.
 .TP
 \fB\-h\fR|\-\-help
 Help information.
diff --git a/empty.style b/empty.style
new file mode 100644
index 0000000..6c9919d
--- /dev/null
+++ b/empty.style
@@ -0,0 +1,107 @@
+# This osm2pgsql style file is one that will generate no columns from tags
+# It is designed as a starting point for you to develop your own, or for 
+# use where all OSM tags are in hstore.
+
+# See default.style for documentation on all the flags
+
+# OsmType   Tag                     Type    Flags
+# Insert your own columns here, or change phstore to polygon below
+way         abandoned:aeroway       text    phstore
+way         abandoned:amenity       text    phstore
+way         abandoned:building      text    phstore
+way         abandoned:landuse       text    phstore
+way         abandoned:power         text    phstore
+way         area:highway            text    phstore
+node,way    aeroway                 text    phstore
+node,way    amenity                 text    phstore
+node,way    building                text    phstore
+way         building:part           text    phstore
+node,way    harbour                 text    phstore
+node,way    historic                text    phstore
+node,way    landuse                 text    phstore
+node,way    leisure                 text    phstore
+node,way    man_made                text    phstore
+node,way    military                text    phstore
+node,way    natural                 text    phstore
+node,way    office                  text    phstore
+node,way    place                   text    phstore
+node,way    power                   text    phstore
+node,way    public_transport        text    phstore
+node,way    shop                    text    phstore
+node,way    sport                   text    phstore
+node,way    tourism                 text    phstore
+node,way    water                   text    phstore
+node,way    waterway                text    phstore
+node,way    wetland                 text    phstore
+node,way    z_order                 int4    linear  # This is calculated during import
+way         way_area                real            # This is calculated during import
+
+# Deleted tags
+# These are tags that are generally regarded as useless for most rendering.
+# Most of them are from imports or intended as internal information for mappers
+# Some of them are automatically deleted by editors.
+# If you want some of them, perhaps for a debugging layer, just delete the lines.
+
+# These tags are used by mappers to keep track of data.
+# They aren't very useful for rendering.
+node,way    note                    text    delete
+node,way    note:*                  text    delete
+node,way    source                  text    delete
+node,way    source_ref              text    delete
+node,way    source:*                text    delete
+node,way    attribution             text    delete
+node,way    comment                 text    delete
+node,way    fixme                   text    delete
+
+# Tags generally dropped by editors, not otherwise covered
+node,way    created_by              text    delete
+node,way    odbl                    text    delete
+node,way    odbl:note               text    delete
+node,way    SK53_bulk:load          text    delete
+
+# Lots of import tags
+# TIGER (US)
+node,way    tiger:*                 text    delete
+
+# NHD (US)
+# NHD has been converted every way imaginable
+node,way    NHD:*                   text    delete
+node,way    nhd:*                   text    delete
+
+# GNIS (US)
+node,way    gnis:*                  text    delete
+
+# Geobase (CA)
+node,way    geobase:*               text    delete
+# NHN (CA)
+node,way    accuracy:meters         text    delete
+node,way    sub_sea:type            text    delete
+node,way    waterway:type           text    delete
+
+# KSJ2 (JA)
+# See also note:ja and source_ref above
+node,way    KSJ2:*                  text    delete
+# Yahoo/ALPS (JA)
+node,way    yh:*                    text    delete
+
+# osak (DK)
+node,way    osak:*                  text    delete
+
+# kms (DK)
+node,way    kms:*                   text    delete
+
+# ngbe (ES)
+# See also note:es and source:file above
+node,way    ngbe:*                  text    delete
+
+# naptan (UK)
+node,way    naptan:*                text    delete
+
+# Corine (CLC) (Europe)
+node,way    CLC:*                   text    delete
+
+# misc
+node,way    3dshapes:ggmodelk       text    delete
+node,way    AND_nosr_r              text    delete
+node,way    import                  text    delete
+node,way    it:fvg:*                text    delete
diff --git a/legacy/Makefile.am b/legacy/Makefile.am
deleted file mode 100644
index e0cee29..0000000
--- a/legacy/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-bin_PROGRAMS = osm2pgsql-legacy
-
-osm2pgsql_legacy_SOURCES = build_geometry.cpp osm2pgsql.c
-
-AM_CFLAGS=@XML2_CFLAGS@ @GEOS_CFLAGS@ 
-AM_CPPFLAGS=@XML2_CFLAGS@ @GEOS_CFLAGS@ 
-
-AM_LDFLAGS=@XML2_LDFLAGS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ 
-
-noinst_HEADERS = build_geometry.h
-
diff --git a/legacy/build_geometry.cpp b/legacy/build_geometry.cpp
deleted file mode 100644
index 1b2cd43..0000000
--- a/legacy/build_geometry.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-#-----------------------------------------------------------------------------
-# Part of osm2pgsql utility
-#-----------------------------------------------------------------------------
-# By Artem Pavlenko, Copyright 2007
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-#-----------------------------------------------------------------------------
-*/
-
-#include <iostream>
-#include <geos_c.h>
-
-#if (GEOS_VERSION_MAJOR==3)
-/* geos trunk (3.0.0rc) */
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/CoordinateSequenceFactory.h>
-#include <geos/geom/Geometry.h>
-#include <geos/geom/LineString.h>
-#include <geos/geom/LinearRing.h>
-#include <geos/geom/MultiLineString.h>
-#include <geos/geom/Polygon.h>
-#include <geos/io/WKTReader.h>
-#include <geos/io/WKTWriter.h>
-#include <geos/opLinemerge.h>
-using namespace geos::geom;
-using namespace geos::io;
-using namespace geos::operation::linemerge;
-#else
-/* geos-2.2 */
-#include <geos/geom.h>
-#include <geos/io.h>
-#include <geos/opLinemerge.h>
-using namespace geos;
-#endif
-
-#include "build_geometry.h"
-
-
-struct Segment
-{
-      Segment(double x0_,double y0_,double x1_,double y1_)
-         :x0(x0_),y0(y0_),x1(x1_),y1(y1_) {}
-      
-      double x0;
-      double y0;
-      double x1;
-      double y1;
-};
-
-static std::vector<Segment> segs;
-static std::vector<std::string> wkts;
-
-typedef std::auto_ptr<Geometry> geom_ptr;
-
-int is_simple(const char* wkt)
-{
-   GeometryFactory factory;
-   WKTReader reader(&factory);
-   geom_ptr geom(reader.read(wkt));
-   if (geom->isSimple()) return 1;
-   return 0;
-}
-
-void add_segment(double x0,double y0,double x1,double y1)
-{
-   segs.push_back(Segment(x0,y0,x1,y1));
-}
-
-const char * get_wkt(size_t index)
-{
-   return wkts[index].c_str();
-}
-
-void clear_wkts()
-{
-   wkts.clear();
-}
-
-size_t build_geometry(int polygon)
-{
-   size_t wkt_size = 0;
-   GeometryFactory factory;
-   geom_ptr segment(0);
-   std::auto_ptr<std::vector<Geometry*> > lines(new std::vector<Geometry*>);
-   std::vector<Segment>::const_iterator pos=segs.begin();
-   std::vector<Segment>::const_iterator end=segs.end();
-   bool first=true;
-   try  {
-     while (pos != end)
-       {
-	 if (pos->x0 != pos->x1 || pos->y0 != pos->y1)
-	   {
-	     std::auto_ptr<CoordinateSequence> coords(factory.getCoordinateSequenceFactory()->create(0,2));
-	     coords->add(Coordinate(pos->x0,pos->y0));
-	     coords->add(Coordinate(pos->x1,pos->y1));
-	     geom_ptr linestring(factory.createLineString(coords.release()));
-	     if (first)
-	       {
-		 segment = linestring;
-		 first=false;
-	       }
-	     else
-	       {
-		 lines->push_back(linestring.release());
-	       }
-	   }
-	 ++pos;
-       }
-     
-     segs.clear();
-     
-     if (segment.get())
-       {
-	 geom_ptr mline (factory.createMultiLineString(lines.release()));
-	 geom_ptr noded (segment->Union(mline.get()));
-	 LineMerger merger;
-	 merger.add(noded.get());
-	 std::auto_ptr<std::vector<LineString *> > merged(merger.getMergedLineStrings());
-	 WKTWriter writer;
-	 
-	 for (unsigned i=0 ;i < merged->size(); ++i)
-	   {
-	     std::auto_ptr<LineString> pline ((*merged ) [i]);
-	     
-	     if (polygon == 1 && pline->getNumPoints() > 3 && pline->isClosed())
-	       {
-		 std::auto_ptr<LinearRing> ring(factory.createLinearRing(pline->getCoordinates()));
-		 geom_ptr poly(factory.createPolygon(ring.release(),0));
-		 std::string text = writer.write(poly.get());
-		 
-		 wkts.push_back(text);
-		 ++wkt_size;
-	       }
-	     else
-	       {
-		 std::string text = writer.write(pline.get());
-		 wkts.push_back(text);
-		 ++wkt_size;
-	       }
-	   }
-       }
-   }
-   catch (...)
-     {
-       std::cerr << "excepton caught \n";
-       wkt_size = 0;
-     }
-   return wkt_size;
-}
-
diff --git a/legacy/build_geometry.h b/legacy/build_geometry.h
deleted file mode 100644
index d96912a..0000000
--- a/legacy/build_geometry.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-#-----------------------------------------------------------------------------
-# Part of osm2pgsql utility
-#-----------------------------------------------------------------------------
-# By Artem Pavlenko, Copyright 2007
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-#-----------------------------------------------------------------------------
-*/
-
-#ifndef BUILD_GEOMETRY_H
-#define BUILD_GEOMETRY_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int is_simple(const char* wkt);
-void add_segment(double x0,double y0,double x1, double y1);
-const char* get_wkt(size_t index);
-size_t build_geometry(int polygon);
-void clear_wkts();
-
-#ifdef __cplusplus
-}
-#endif
-   
-#endif 
diff --git a/legacy/osm2pgsql.c b/legacy/osm2pgsql.c
deleted file mode 100644
index a4fb021..0000000
--- a/legacy/osm2pgsql.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
-  #-----------------------------------------------------------------------------
-  # osm2pgsql - converts planet.osm file into PostgreSQL
-  # compatible output suitable to be rendered by mapnik
-  # Use: osm2pgsql planet.osm > planet.sql
-  #-----------------------------------------------------------------------------
-  # Original Python implementation by Artem Pavlenko
-  # Re-implementation by Jon Burgess, Copyright 2006
-  #
-  # This program is free software; you can redistribute it and/or
-  # modify it under the terms of the GNU General Public License
-  # as published by the Free Software Foundation; either version 2
-  # of the License, or (at your option) any later version.
-  # 
-  # This program is distributed in the hope that it will be useful,
-  # but WITHOUT ANY WARRANTY; without even the implied warranty of
-  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  # GNU General Public License for more details.
-  # 
-  # You should have received a copy of the GNU General Public License
-  # along with this program; if not, write to the Free Software
-  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-  #-----------------------------------------------------------------------------
-*/
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <libxml/xmlstring.h>
-#include <libxml/xmlreader.h>
-
-#include "build_geometry.h"
-
-#if 0
-#define DEBUG printf
-#else
-#define DEBUG(x, ...)
-#endif
-
-struct tagDesc {
-      const char *name;
-      const char *type;
-      const int polygon;
-}; 
-
-static struct tagDesc exportTags[] = {
-   {"name",    "text", 0},
-   {"place",   "text", 0},
-   {"landuse", "text", 1},
-   {"leisure", "text", 1},
-   {"natural", "text", 1},
-   {"man_made","text", 0},
-   {"waterway","text", 0},
-   {"highway", "text", 0},
-   {"foot",    "text", 0},
-   {"horse",   "text", 0},
-   {"bicycle", "text", 0},
-   {"motorcar","text", 0},
-   {"residence","text", 0},
-   {"railway", "text", 0},
-   {"amenity", "text", 1},
-   {"tourism", "text", 1},
-   {"learning","text", 0},
-   {"building","text", 1},
-   {"bridge",  "text", 0},
-   {"layer",   "text", 0},
-   {"junction","text", 0},
-   {"sport",   "text", 1},
-   {"route",   "text", 0},
-   {"aeroway", "text", 0}
-};
-
-static const char *table_name_point = "planet_osm_point";
-static const char *table_name_line = "planet_osm_line";
-static const char *table_name_polygon = "planet_osm_polygon";
-
-#define MAX_ID_NODE (35000000)
-#define MAX_ID_SEGMENT (35000000)
-
-struct osmNode {
-      double lon;
-      double lat;
-};
-
-struct osmSegment {
-      unsigned int from;
-      unsigned int to;
-};
-
-struct osmWay {
-      char *values;
-      char *wkt;
-};
-
-static struct osmNode    nodes[MAX_ID_NODE+1];
-static struct osmSegment segments[MAX_ID_SEGMENT+1];
-
-static int count_node,    count_all_node,    max_node;
-static int count_segment, count_all_segment, max_segment;
-static int count_way,     count_all_way,     max_way;
-static int count_way_seg;
-
-struct keyval {
-      char *key;
-      char *value;
-      struct keyval *next;
-      struct keyval *prev;
-};
-
-
-static struct keyval keys, tags, segs;
-
-
-void usage(const char *arg0)
-{
-   fprintf(stderr, "Usage error:\n\t%s planet.osm  > planet.sql\n", arg0);
-   fprintf(stderr, "or\n\tgzip -dc planet.osm.gz | %s - | gzip -c > planet.sql.gz\n", arg0);
-}
-
-void initList(struct keyval *head)
-{
-   head->next = head;
-   head->prev = head;
-   head->key = NULL;
-   head->value = NULL;
-}
-
-void freeItem(struct keyval *p)
-{
-   free(p->key);
-   free(p->value);
-   free(p);
-}
-
-
-unsigned int countList(struct keyval *head) 
-{
-   struct keyval *p = head->next;
-   unsigned int count = 0;	
-
-   while(p != head) {
-      count++;
-      p = p->next;
-   }
-   return count;
-}
-
-int listHasData(struct keyval *head) 
-{
-   return (head->next != head);
-}
-
-
-char *getItem(struct keyval *head, const char *name)
-{
-   struct keyval *p = head->next;
-   while(p != head) {
-      if (!strcmp(p->key, name))
-         return p->value;
-      p = p->next;
-   }
-   return NULL;
-}	
-
-
-struct keyval *popItem(struct keyval *head)
-{
-   struct keyval *p = head->next;
-   if (p == head)
-      return NULL;
-
-   head->next = p->next;
-   p->next->prev = head;
-
-   p->next = NULL;
-   p->prev = NULL;
-
-   return p;
-}	
-
-
-void pushItem(struct keyval *head, struct keyval *item)
-{
-   item->next = head;
-   item->prev = head->prev;
-   head->prev->next = item;
-   head->prev = item;
-}	
-
-int addItem(struct keyval *head, const char *name, const char *value, int noDupe)
-{
-   struct keyval *item;
-
-   if (noDupe) {
-      item = head->next;
-      while (item != head) {
-         if (!strcmp(item->value, value) && !strcmp(item->key, name)) {
-            //fprintf(stderr, "Discarded %s=%s\n", name, value);
-            return 1;
-         }
-         item = item->next;
-      }
-   }
-	
-   item = malloc(sizeof(struct keyval));
-		
-   if (!item) {
-      fprintf(stderr, "Error allocating keyval\n");
-      return 2;
-   }
-
-   item->key   = strdup(name);
-   item->value = strdup(value);
-
-   item->next = head->next;
-   item->prev = head;
-   head->next->prev = item;
-   head->next = item;
-
-   return 0;
-}
-
-void resetList(struct keyval *head) 
-{
-   struct keyval *item;
-	
-   while((item = popItem(head))) 
-      freeItem(item);
-}
-
-size_t WKT(int polygon)
-{
-   while (listHasData(&segs))
-   {
-      struct keyval *p;
-      unsigned int id, to, from;
-      double x0, y0, x1, y1;
-      p = popItem(&segs);
-      id = strtoul(p->value, NULL, 10);
-      freeItem(p);
-
-      from = segments[id].from;
-      to   = segments[id].to; 
-
-      x0 = nodes[from].lon;
-      y0 = nodes[from].lat;
-      x1 = nodes[to].lon;
-      y1 = nodes[to].lat;
-      add_segment(x0,y0,x1,y1);
-   }
-   return  build_geometry(polygon);
-}
-
-
-void StartElement(xmlTextReaderPtr reader, const xmlChar *name)
-{
-   xmlChar *xid, *xlat, *xlon, *xfrom, *xto, *xk, *xv;
-   unsigned int id, to, from;
-   double lon, lat;
-   char *k;
-
-   if (xmlStrEqual(name, BAD_CAST "node")) {
-      struct osmNode *node;
-      xid  = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
-      xlon = xmlTextReaderGetAttribute(reader, BAD_CAST "lon");
-      xlat = xmlTextReaderGetAttribute(reader, BAD_CAST "lat");
-      assert(xid); assert(xlon); assert(xlat);
-      id  = strtoul((char *)xid, NULL, 10);
-      lon = strtod((char *)xlon, NULL);
-      lat = strtod((char *)xlat, NULL);
-
-      assert(id > 0);
-      assert(id < MAX_ID_NODE);
-
-      if (id > max_node) 
-          max_node = id;
-
-      count_all_node++;
-      if (count_all_node%10000 == 0) 
-         fprintf(stderr, "\rProcessing: Node(%dk)", count_all_node/1000);
-
-      node = &nodes[id];
-      node->lon = lon;
-      node->lat = lat;
-
-      DEBUG("NODE(%d) %f %f\n", id, lon, lat);
-      addItem(&keys, "id", (char *)xid, 0);
-
-      xmlFree(xid);
-      xmlFree(xlon);
-      xmlFree(xlat);
-   } else if (xmlStrEqual(name, BAD_CAST "segment")) {
-      xid   = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
-      xfrom = xmlTextReaderGetAttribute(reader, BAD_CAST "from");
-      xto   = xmlTextReaderGetAttribute(reader, BAD_CAST "to");
-      assert(xid); assert(xfrom); assert(xto);
-      id   = strtoul((char *)xid, NULL, 10);
-      from = strtoul((char *)xfrom, NULL, 10);
-      to   = strtoul((char *)xto, NULL, 10);
-
-      assert(id > 0);
-      assert(id < MAX_ID_SEGMENT);
-
-      if (id > max_segment) 
-          max_segment = id;
-
-      if (count_all_segment == 0)
-         fprintf(stderr, "\n");
-
-      count_all_segment++;
-      if (count_all_segment%10000 == 0) 
-         fprintf(stderr, "\rProcessing: Segment(%dk)", count_all_segment/1000);
-
-      if (!nodes[to].lat && !nodes[to].lon) {
-         DEBUG("SEGMENT(%d), NODE(%d) is missing\n", id, to);
-      } else if (!nodes[from].lat && !nodes[from].lon) {
-         DEBUG("SEGMENT(%d), NODE(%d) is missing\n", id, from);
-      } else {
-         if (from != to) {
-            struct osmSegment *segment;
-            segment = &segments[id];
-            segment->to   = to;
-            segment->from = from;
-
-            count_segment++;
-            DEBUG("SEGMENT(%d) %d, %d\n", id, from, to);
-         }
-      }
-
-      xmlFree(xid);
-      xmlFree(xfrom);
-      xmlFree(xto);
-   } else if (xmlStrEqual(name, BAD_CAST "tag")) {
-      char *p;
-      xk = xmlTextReaderGetAttribute(reader, BAD_CAST "k");
-      xv = xmlTextReaderGetAttribute(reader, BAD_CAST "v");
-      assert(xk); assert(xv);
-      k  = (char *)xmlStrdup(xk);
-
-      while ((p = strchr(k, ':')))
-         *p = '_';
-      while ((p = strchr(k, ' ')))
-         *p = '_';
-
-      addItem(&tags, k, (char *)xv, 0);
-      DEBUG("\t%s = %s\n", xk, xv);
-      xmlFree(k);
-      xmlFree(xk);
-      xmlFree(xv);
-   } else if (xmlStrEqual(name, BAD_CAST "way")) {
-      xid  = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
-      assert(xid);
-      id   = strtoul((char *)xid, NULL, 10);
-      addItem(&keys, "id", (char *)xid, 0);
-      DEBUG("WAY(%s)\n", xid);
-
-      if (id > max_way)
-           max_way = id;
-
-      if (count_all_way == 0)
-         fprintf(stderr, "\n");
-		
-      count_all_way++;
-      if (count_all_way%1000 == 0) 
-         fprintf(stderr, "\rProcessing: Way(%dk)", count_all_way/1000);
-
-      xmlFree(xid);
-   } else if (xmlStrEqual(name, BAD_CAST "seg")) {
-      xid  = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
-      assert(xid);
-      id   = strtoul((char *)xid, NULL, 10);
-      if (!id || (id > MAX_ID_SEGMENT))
-         DEBUG("\tSEG(%s) - invalid segment ID\n", xid);
-      else if (!segments[id].from || !segments[id].to)
-         DEBUG("\tSEG(%s) - missing segment\n", xid);
-      else {
-         if (addItem(&segs, "id", (char *)xid, 1)) {
-            const char *way_id = getItem(&keys, "id");
-            if (!way_id) way_id = "???";
-            //fprintf(stderr, "Way %s with duplicate segment id %d\n", way_id, id);
-            count_way_seg++;
-         }
-         DEBUG("\tSEG(%s)\n", xid);
-      }
-      xmlFree(xid);
-   } else if (xmlStrEqual(name, BAD_CAST "osm")) {
-      /* ignore */
-   } else {
-      fprintf(stderr, "%s: Unknown element name: %s\n", __FUNCTION__, name);
-   }
-}
-
-void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
-{
-   unsigned int id;
-
-   DEBUG("%s: %s\n", __FUNCTION__, name);
-
-   if (xmlStrEqual(name, BAD_CAST "node")) {
-      int i;
-      char *values = NULL, *names = NULL;
-      char *osm_id = getItem(&keys, "id");
-      if (!osm_id) {
-         fprintf(stderr, "%s: Node ID not in keys\n", __FUNCTION__);
-         resetList(&keys);
-         resetList(&tags);
-         return;
-      }
-      id = strtoul(osm_id, NULL, 10);
-      //assert(nodes[id].lat && nodes[id].lon);
-      for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++) {
-         char *v;
-         if ((v = getItem(&tags, exportTags[i].name))) {
-            if (values) {
-               char *oldval = values, *oldnam = names;
-               asprintf(&names,  "%s,\"%s\"", oldnam, exportTags[i].name);
-               asprintf(&values, "%s,$$%s$$", oldval, v);
-               free(oldnam);
-               free(oldval);
-            } else {
-               asprintf(&names,  "\"%s\"", exportTags[i].name);
-               asprintf(&values, "$$%s$$", v);
-            }
-         }
-      }
-      if (values) {
-         count_node++;
-         printf("insert into %s (osm_id,%s,way) values "
-		"(%s,%s,GeomFromText('POINT(%.15g %.15g)',4326));\n", 
-		table_name_point,names,osm_id,values,nodes[id].lon, nodes[id].lat);
-      }
-      resetList(&keys);
-      resetList(&tags);
-      free(values);
-      free(names);
-   } else if (xmlStrEqual(name, BAD_CAST "segment")) {
-      resetList(&tags);
-   } else if (xmlStrEqual(name, BAD_CAST "tag")) {
-      /* Separate tag list so tag stack unused */
-   } else if (xmlStrEqual(name, BAD_CAST "way")) {
-      int i, polygon = 0; 
-      char *values = NULL, *names = NULL;
-      char *osm_id = getItem(&keys, "id");
-
-      if (!osm_id) {
-         fprintf(stderr, "%s: WAY ID not in keys\n", __FUNCTION__);
-         resetList(&keys);
-         resetList(&tags);
-         resetList(&segs);
-         return;
-      }
-
-      if (!listHasData(&segs)) {
-         DEBUG("%s: WAY(%s) has no segments\n", __FUNCTION__, osm_id);
-         resetList(&keys);
-         resetList(&tags);
-         resetList(&segs);
-         return;
-      }
-      id  = strtoul(osm_id, NULL, 10);
-
-      for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++) {
-         char *v;
-         if ((v = getItem(&tags, exportTags[i].name))) {
-            if (values) {
-               char *oldval = values, *oldnam = names;
-               asprintf(&names,  "%s,\"%s\"", oldnam, exportTags[i].name);
-               asprintf(&values, "%s,$$%s$$", oldval, v);
-               free(oldnam);
-               free(oldval);
-            } else {
-               asprintf(&names,  "\"%s\"", exportTags[i].name);
-               asprintf(&values, "$$%s$$", v);
-            }
-            polygon |= exportTags[i].polygon;
-         }
-      }
-      if (values) {
-         size_t wkt_size = WKT(polygon);
-
-         if (wkt_size)
-         {
-            unsigned i;
-            for (i=0;i<wkt_size;i++)
-            {
-               const char * wkt = get_wkt(i);
-               if (strlen(wkt)) {
-		 if (polygon) {
-                     printf("insert into %s (osm_id,%s,way) values (%s,%s,GeomFromText('%s',4326));\n", table_name_polygon,names,osm_id,values,wkt);
-		 }
-		 else {
-		   printf("insert into %s (osm_id,%s,way) values (%s,%s,GeomFromText('%s',4326));\n", table_name_line,names,osm_id,values,wkt);
-		 }
-		 count_way++;	
-               }
-            }
-            clear_wkts();
-         }
-      }
-
-      resetList(&keys);
-      resetList(&tags);
-      resetList(&segs);
-      free(values);
-      free(names);
-   } else if (xmlStrEqual(name, BAD_CAST "seg")) {
-      /* ignore */
-   } else if (xmlStrEqual(name, BAD_CAST "osm")) {
-      /* ignore */
-   } else {
-      fprintf(stderr, "%s: Unknown element name: %s\n", __FUNCTION__, name);
-   }
-}
-
-static void processNode(xmlTextReaderPtr reader) {
-   xmlChar *name;
-   name = xmlTextReaderName(reader);
-   if (name == NULL)
-      name = xmlStrdup(BAD_CAST "--");
-	
-   switch(xmlTextReaderNodeType(reader)) {
-      case XML_READER_TYPE_ELEMENT:
-         StartElement(reader, name);	
-         if (xmlTextReaderIsEmptyElement(reader))
-            EndElement(reader, name); /* No end_element for self closing tags! */
-         break;
-      case XML_READER_TYPE_END_ELEMENT:
-         EndElement(reader, name);
-         break;
-      case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
-         /* Ignore */
-         break;
-      default:
-         fprintf(stderr, "Unknown node type %d\n", xmlTextReaderNodeType(reader));
-         break;
-   }
-
-   xmlFree(name);
-}
-
-void streamFile(char *filename) {
-   xmlTextReaderPtr reader;
-   int ret;
-
-   reader = xmlNewTextReaderFilename(filename);
-   if (reader != NULL) {
-      ret = xmlTextReaderRead(reader);
-      while (ret == 1) {
-         processNode(reader);
-         ret = xmlTextReaderRead(reader);
-      }
-
-      if (ret != 0) {
-         fprintf(stderr, "%s : failed to parse\n", filename);
-         return;
-      }
-
-      xmlFreeTextReader(reader);
-   } else {
-      fprintf(stderr, "Unable to open %s\n", filename);
-   }
-}
-
-
-
-int main(int argc, char *argv[])
-{
-   int i;
-
-   if (argc != 2) {
-      usage(argv[0]);
-      exit(1);
-   }
-
-   initList(&keys);
-   initList(&tags);
-   initList(&segs);
-
-   LIBXML_TEST_VERSION
-
-   printf("drop table %s ;\n", table_name_point);
-   printf("create table %s ( osm_id int4",table_name_point);
-   for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++)
-      printf(",\"%s\" %s", exportTags[i].name, exportTags[i].type);
-   printf(" );\n");
-   printf("select AddGeometryColumn('%s', 'way', 4326, 'POINT', 2 );\n", table_name_point);
-   
-   printf("drop table %s ;\n", table_name_line);
-   printf("create table %s ( osm_id int4",table_name_line);
-   for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++)
-      printf(",\"%s\" %s", exportTags[i].name, exportTags[i].type);
-   printf(" );\n");
-   printf("select AddGeometryColumn('%s', 'way', 4326, 'LINESTRING', 2 );\n", table_name_line);
-   
-   printf("drop table %s ;\n", table_name_polygon);
-   printf("create table %s ( osm_id int4",table_name_polygon);
-   for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++)
-      printf(",\"%s\" %s", exportTags[i].name, exportTags[i].type);
-   printf(" );\n");
-   printf("select AddGeometryColumn('%s', 'way', 4326, 'GEOMETRY', 2 );\n", table_name_polygon);
-   
-   printf("begin;\n");
-   streamFile(argv[1]);
-   printf("commit;\n");
-   
-   printf("vacuum analyze %s;\n", table_name_point);
-   printf("vacuum analyze %s;\n", table_name_line);
-   printf("vacuum analyze %s;\n", table_name_polygon);
-   
-   printf("CREATE INDEX way_index0 ON %s USING GIST (way GIST_GEOMETRY_OPS);\n", table_name_point);
-   printf("ALTER TABLE %s ALTER COLUMN way SET NOT NULL;\n",table_name_point);
-   printf("CLUSTER way_index0 on %s;\n",table_name_point);
-   printf("vacuum analyze %s;\n", table_name_point);
-   
-   printf("CREATE INDEX way_index1 ON %s USING GIST (way GIST_GEOMETRY_OPS);\n", table_name_line);
-   printf("ALTER TABLE %s ALTER COLUMN way SET NOT NULL;\n",table_name_line);
-   printf("ALTER TABLE %s ADD COLUMN z_order int4 default 0;\n",table_name_line);
-   printf("CLUSTER way_index1 on %s;\n",table_name_line);
-   printf("vacuum analyze %s;\n", table_name_line);
-   
-   printf("CREATE INDEX way_index2 ON %s USING GIST (way GIST_GEOMETRY_OPS);\n", table_name_polygon);
-   printf("ALTER TABLE %s ALTER COLUMN way SET NOT NULL;\n",table_name_polygon);
-   printf("CLUSTER way_index2 on %s;\n",table_name_polygon);
-   printf("vacuum analyze %s;\n", table_name_polygon);
-
-   xmlCleanupParser();
-   xmlMemoryDump();
-
-   fprintf(stderr, "\n");
-
-   fprintf(stderr, "Node stats: out(%d), total(%d), max(%d)\n", count_node, count_all_node, max_node);
-   fprintf(stderr, "Segment stats: out(%d), total(%d), max(%d)\n", count_segment, count_all_segment, max_segment);
-   fprintf(stderr, "Way stats: out(%d), total(%d), max(%d)\n", count_way, count_all_way, max_way);
-   fprintf(stderr, "Way stats: duplicate segments in ways %d\n", count_way_seg);
-
-   return 0;
-}
diff --git a/m4/ax_lua.m4 b/m4/ax_lua.m4
new file mode 100644
index 0000000..c6f5974
--- /dev/null
+++ b/m4/ax_lua.m4
@@ -0,0 +1,607 @@
+# ===========================================================================
+#          http://www.gnu.org/software/autoconf-archive/ax_lua.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
+#   AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
+#   AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
+#   AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
+#
+# DESCRIPTION
+#
+#   Detect a Lua interpreter, optionally specifying a minimum and maximum
+#   version number. Set up important Lua paths, such as the directories in
+#   which to install scripts and modules (shared libraries).
+#
+#   Also detect Lua headers and libraries. The Lua version contained in the
+#   header is checked to match the Lua interpreter version exactly. When
+#   searching for Lua libraries, the version number is used as a suffix.
+#   This is done with the goal of supporting multiple Lua installs (5.1 and
+#   5.2 side-by-side).
+#
+#   A note on compatibility with previous versions: This file has been
+#   mostly rewritten for serial 18. Most developers should be able to use
+#   these macros without needing to modify configure.ac. Care has been taken
+#   to preserve each macro's behavior, but there are some differences:
+#
+#   1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as
+#   AX_PROG_LUA with no arguments.
+#
+#   2) AX_LUA_HEADERS now checks that the version number defined in lua.h
+#   matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore
+#   unnecessary, so it is deprecated and does not expand to anything.
+#
+#   3) The configure flag --with-lua-suffix no longer exists; the user
+#   should instead specify the LUA precious variable on the command line.
+#   See the AX_PROG_LUA description for details.
+#
+#   Please read the macro descriptions below for more information.
+#
+#   This file was inspired by Andrew Dalke's and James Henstridge's
+#   python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4
+#   (serial 17). Basically, this file is a mash-up of those two files. I
+#   like to think it combines the best of the two!
+#
+#   AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua
+#   paths. Adds precious variable LUA, which may contain the path of the Lua
+#   interpreter. If LUA is blank, the user's path is searched for an
+#   suitable interpreter.
+#
+#   If MINIMUM-VERSION is supplied, then only Lua interpreters with a
+#   version number greater or equal to MINIMUM-VERSION will be accepted. If
+#   TOO-BIG- VERSION is also supplied, then only Lua interpreters with a
+#   version number greater or equal to MINIMUM-VERSION and less than
+#   TOO-BIG-VERSION will be accepted.
+#
+#   Version comparisons require the AX_COMPARE_VERSION macro, which is
+#   provided by ax_compare_version.m4 from the Autoconf Archive.
+#
+#   The Lua version number, LUA_VERSION, is found from the interpreter, and
+#   substituted. LUA_PLATFORM is also found, but not currently supported (no
+#   standard representation).
+#
+#   Finally, the macro finds four paths:
+#
+#     luadir             Directory to install Lua scripts.
+#     pkgluadir          $luadir/$PACKAGE
+#     luaexecdir         Directory to install Lua modules.
+#     pkgluaexecdir      $luaexecdir/$PACKAGE
+#
+#   These paths a found based on $prefix, $exec_prefix, Lua's package.path,
+#   and package.cpath. The first path of package.path beginning with $prefix
+#   is selected as luadir. The first path of package.cpath beginning with
+#   $exec_prefix is used as luaexecdir. This should work on all reasonable
+#   Lua installations. If a path cannot be determined, a default path is
+#   used. Of course, the user can override these later when invoking make.
+#
+#     luadir             Default: $prefix/share/lua/$LUA_VERSION
+#     luaexecdir         Default: $exec_prefix/lib/lua/$LUA_VERSION
+#
+#   These directories can be used by Automake as install destinations. The
+#   variable name minus 'dir' needs to be used as a prefix to the
+#   appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES.
+#
+#   If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is
+#   performed, otherwise ACTION-IF-NOT-FOUND is preformed. If ACTION-IF-NOT-
+#   FOUND is blank, then it will default to printing an error. To prevent
+#   the default behavior, give ':' as an action.
+#
+#   AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be
+#   expanded before this macro. Adds precious variable LUA_INCLUDE, which
+#   may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If
+#   LUA_INCLUDE is blank, then this macro will attempt to find suitable
+#   flags.
+#
+#   LUA_INCLUDE can be used by Automake to compile Lua modules or
+#   executables with embedded interpreters. The *_CPPFLAGS variables should
+#   be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE).
+#
+#   This macro searches for the header lua.h (and others). The search is
+#   performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE.
+#   If the search is unsuccessful, then some common directories are tried.
+#   If the headers are then found, then LUA_INCLUDE is set accordingly.
+#
+#   The paths automatically searched are:
+#
+#     * /usr/include/luaX.Y
+#     * /usr/include/lua/X.Y
+#     * /usr/include/luaXY
+#     * /usr/local/include/luaX.Y
+#     * /usr/local/include/lua/X.Y
+#     * /usr/local/include/luaXY
+#
+#   (Where X.Y is the Lua version number, e.g. 5.1.)
+#
+#   The Lua version number found in the headers is always checked to match
+#   the Lua interpreter's version number. Lua headers with mismatched
+#   version numbers are not accepted.
+#
+#   If headers are found, then ACTION-IF-FOUND is performed, otherwise
+#   ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then
+#   it will default to printing an error. To prevent the default behavior,
+#   set the action to ':'.
+#
+#   AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be
+#   expanded before this macro. Adds precious variable LUA_LIB, which may
+#   contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank,
+#   then this macro will attempt to find suitable flags.
+#
+#   LUA_LIB can be used by Automake to link Lua modules or executables with
+#   embedded interpreters. The *_LIBADD and *_LDADD variables should be used
+#   for this purpose, e.g. mymod_LIBADD = $(LUA_LIB).
+#
+#   This macro searches for the Lua library. More technically, it searches
+#   for a library containing the function lua_load. The search is performed
+#   with a combination of LIBS, LIBRARY_PATH, and LUA_LIB.
+#
+#   If the search determines that some linker flags are missing, then those
+#   flags will be added to LUA_LIB.
+#
+#   If libraries are found, then ACTION-IF-FOUND is performed, otherwise
+#   ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then
+#   it will default to printing an error. To prevent the default behavior,
+#   set the action to ':'.
+#
+#   AX_LUA_READLINE: Search for readline headers and libraries. Requires the
+#   AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the
+#   Autoconf Archive.
+#
+#   If a readline compatible library is found, then ACTION-IF-FOUND is
+#   performed, otherwise ACTION-IF-NOT-FOUND is performed.
+#
+# LICENSE
+#
+#   Copyright (c) 2013 Tim Perkins <tprk77 at gmail.com>
+#   Copyright (c) 2013 Reuben Thomas <rrt at sc3d.org>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 20
+
+dnl =========================================================================
+dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION],
+dnl             [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl =========================================================================
+AC_DEFUN([AX_PROG_LUA],
+[
+  dnl Make LUA a precious variable.
+  AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1])
+
+  dnl Find a Lua interpreter.
+  m4_define_default([_AX_LUA_INTERPRETER_LIST],
+    [lua lua5.2 lua5.1 lua50])
+
+  m4_if([$1], [],
+  [ dnl No version check is needed. Find any Lua interpreter.
+    AS_IF([test "x$LUA" = 'x'],
+      [AC_PATH_PROGS([LUA], [_AX_LUA_INTERPRETER_LIST], [:])])
+    ax_display_LUA='lua'
+
+    dnl At least check if this is a Lua interpreter.
+    AC_MSG_CHECKING([if $LUA is a Lua interpreter])
+    _AX_LUA_CHK_IS_INTRP([$LUA],
+      [AC_MSG_RESULT([yes])],
+      [ AC_MSG_RESULT([no])
+        AC_MSG_ERROR([not a Lua interpreter])
+      ])
+  ],
+  [ dnl A version check is needed.
+    AS_IF([test "x$LUA" != 'x'],
+    [ dnl Check if this is a Lua interpreter.
+      AC_MSG_CHECKING([if $LUA is a Lua interpreter])
+      _AX_LUA_CHK_IS_INTRP([$LUA],
+        [AC_MSG_RESULT([yes])],
+        [ AC_MSG_RESULT([no])
+          AC_MSG_ERROR([not a Lua interpreter])
+        ])
+      dnl Check the version.
+      m4_if([$2], [],
+        [_ax_check_text="whether $LUA version >= $1"],
+        [_ax_check_text="whether $LUA version >= $1, < $2"])
+      AC_MSG_CHECKING([$_ax_check_text])
+      _AX_LUA_CHK_VER([$LUA], [$1], [$2],
+        [AC_MSG_RESULT([yes])],
+        [ AC_MSG_RESULT([no])
+          AC_MSG_ERROR([version is out of range for specified LUA])])
+      ax_display_LUA=$LUA
+    ],
+    [ dnl Try each interpreter until we find one that satisfies VERSION.
+      m4_if([$2], [],
+        [_ax_check_text="for a Lua interpreter with version >= $1"],
+        [_ax_check_text="for a Lua interpreter with version >= $1, < $2"])
+      AC_CACHE_CHECK([$_ax_check_text],
+        [ax_cv_pathless_LUA],
+        [ for ax_cv_pathless_LUA in _AX_LUA_INTERPRETER_LIST none; do
+            test "x$ax_cv_pathless_LUA" = 'xnone' && break
+            _AX_LUA_CHK_IS_INTRP([$ax_cv_pathless_LUA], [], [continue])
+            _AX_LUA_CHK_VER([$ax_cv_pathless_LUA], [$1], [$2], [break])
+          done
+        ])
+      dnl Set $LUA to the absolute path of $ax_cv_pathless_LUA.
+      AS_IF([test "x$ax_cv_pathless_LUA" = 'xnone'],
+        [LUA=':'],
+        [AC_PATH_PROG([LUA], [$ax_cv_pathless_LUA])])
+      ax_display_LUA=$ax_cv_pathless_LUA
+    ])
+  ])
+
+  AS_IF([test "x$LUA" = 'x:'],
+  [ dnl Run any user-specified action, or abort.
+    m4_default([$4], [AC_MSG_ERROR([cannot find suitable Lua interpreter])])
+  ],
+  [ dnl Query Lua for its version number.
+    AC_CACHE_CHECK([for $ax_display_LUA version], [ax_cv_lua_version],
+      [ ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \
+          sed "s|^Lua \(.*\)|\1|" | \
+          grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"`
+      ])
+    AS_IF([test "x$ax_cv_lua_version" = 'x'],
+      [AC_MSG_ERROR([invalid Lua version number])])
+    AC_SUBST([LUA_VERSION], [$ax_cv_lua_version])
+    AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | sed 's|\.||'`])
+
+    dnl The following check is not supported:
+    dnl At times (like when building shared libraries) you may want to know
+    dnl which OS platform Lua thinks this is.
+    AC_CACHE_CHECK([for $ax_display_LUA platform], [ax_cv_lua_platform],
+      [ax_cv_lua_platform=`$LUA -e "print('unknown')"`])
+    AC_SUBST([LUA_PLATFORM], [$ax_cv_lua_platform])
+
+    dnl Use the values of $prefix and $exec_prefix for the corresponding
+    dnl values of LUA_PREFIX and LUA_EXEC_PREFIX. These are made distinct
+    dnl variables so they can be overridden if need be. However, the general
+    dnl consensus is that you shouldn't need this ability.
+    AC_SUBST([LUA_PREFIX], ['${prefix}'])
+    AC_SUBST([LUA_EXEC_PREFIX], ['${exec_prefix}'])
+
+    dnl Lua provides no way to query the script directory, and instead
+    dnl provides LUA_PATH. However, we should be able to make a safe educated
+    dnl guess. If the built-in search path contains a directory which is
+    dnl prefixed by $prefix, then we can store scripts there. The first
+    dnl matching path will be used.
+    AC_CACHE_CHECK([for $ax_display_LUA script directory],
+      [ax_cv_lua_luadir],
+      [ AS_IF([test "x$prefix" = 'xNONE'],
+          [ax_lua_prefix=$ac_default_prefix],
+          [ax_lua_prefix=$prefix])
+
+        dnl Initialize to the default path.
+        ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION"
+
+        dnl Try to find a path with the prefix.
+        _AX_LUA_FND_PRFX_PTH([$LUA], [$ax_lua_prefix], [package.path])
+        AS_IF([test "x$ax_lua_prefixed_path" != 'x'],
+        [ dnl Fix the prefix.
+          _ax_strip_prefix=`echo "$ax_lua_prefix" | sed 's|.|.|g'`
+          ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \
+            sed "s,^$_ax_strip_prefix,$LUA_PREFIX,"`
+        ])
+      ])
+    AC_SUBST([luadir], [$ax_cv_lua_luadir])
+    AC_SUBST([pkgluadir], [\${luadir}/$PACKAGE])
+
+    dnl Lua provides no way to query the module directory, and instead
+    dnl provides LUA_PATH. However, we should be able to make a safe educated
+    dnl guess. If the built-in search path contains a directory which is
+    dnl prefixed by $exec_prefix, then we can store modules there. The first
+    dnl matching path will be used.
+    AC_CACHE_CHECK([for $ax_display_LUA module directory],
+      [ax_cv_lua_luaexecdir],
+      [ AS_IF([test "x$exec_prefix" = 'xNONE'],
+          [ax_lua_exec_prefix=$ax_lua_prefix],
+          [ax_lua_exec_prefix=$exec_prefix])
+
+        dnl Initialize to the default path.
+        ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION"
+
+        dnl Try to find a path with the prefix.
+        _AX_LUA_FND_PRFX_PTH([$LUA],
+          [$ax_lua_exec_prefix], [package.cpathd])
+        AS_IF([test "x$ax_lua_prefixed_path" != 'x'],
+        [ dnl Fix the prefix.
+          _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | sed 's|.|.|g'`
+          ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \
+            sed "s,^$_ax_strip_prefix,$LUA_EXEC_PREFIX,"`
+        ])
+      ])
+    AC_SUBST([luaexecdir], [$ax_cv_lua_luaexecdir])
+    AC_SUBST([pkgluaexecdir], [\${luaexecdir}/$PACKAGE])
+
+    dnl Run any user specified action.
+    $3
+  ])
+])
+
+dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA.
+AC_DEFUN([AX_WITH_LUA],
+[
+  AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA]])
+  AX_PROG_LUA
+])
+
+
+dnl =========================================================================
+dnl _AX_LUA_CHK_IS_INTRP(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl =========================================================================
+AC_DEFUN([_AX_LUA_CHK_IS_INTRP],
+[
+  dnl Just print _VERSION because all Lua interpreters have this global.
+  AS_IF([$1 -e "print('Hello ' .. _VERSION .. '!')" &>/dev/null],
+    [$2], [$3])
+])
+
+
+dnl =========================================================================
+dnl _AX_LUA_CHK_VER(PROG, MINIMUM-VERSION, [TOO-BIG-VERSION],
+dnl                 [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl =========================================================================
+AC_DEFUN([_AX_LUA_CHK_VER],
+[
+  _ax_test_ver=`$1 -e "print(_VERSION)" 2>/dev/null | \
+    sed "s|^Lua \(.*\)|\1|" | grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"`
+  AS_IF([test "x$_ax_test_ver" = 'x'],
+    [_ax_test_ver='0'])
+  AX_COMPARE_VERSION([$_ax_test_ver], [ge], [$2])
+  m4_if([$3], [], [],
+    [ AS_IF([$ax_compare_version],
+        [AX_COMPARE_VERSION([$_ax_test_ver], [lt], [$3])])
+    ])
+  AS_IF([$ax_compare_version], [$4], [$5])
+])
+
+
+dnl =========================================================================
+dnl _AX_LUA_FND_PRFX_PTH(PROG, PREFIX, LUA-PATH-VARIABLE)
+dnl =========================================================================
+AC_DEFUN([_AX_LUA_FND_PRFX_PTH],
+[
+  dnl Invokes the Lua interpreter PROG to print the path variable
+  dnl LUA-PATH-VARIABLE, usually package.path or package.cpath. Paths are
+  dnl then matched against PREFIX. The first path to begin with PREFIX is set
+  dnl to ax_lua_prefixed_path.
+
+  ax_lua_prefixed_path=''
+  _ax_package_paths=`$1 -e 'print($3)' 2>/dev/null | sed 's|;|\n|g'`
+  dnl Try the paths in order, looking for the prefix.
+  for _ax_package_path in $_ax_package_paths; do
+    dnl Copy the path, up to the use of a Lua wildcard.
+    _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'`
+    _ax_reassembled=''
+    for _ax_path_part in $_ax_path_parts; do
+      echo "$_ax_path_part" | grep '\?' >/dev/null && break
+      _ax_reassembled="$_ax_reassembled/$_ax_path_part"
+    done
+    dnl Check the path against the prefix.
+    _ax_package_path=$_ax_reassembled
+    if echo "$_ax_package_path" | grep "^$2" >/dev/null; then
+      dnl Found it.
+      ax_lua_prefixed_path=$_ax_package_path
+      break
+    fi
+  done
+])
+
+
+dnl =========================================================================
+dnl AX_LUA_HEADERS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl =========================================================================
+AC_DEFUN([AX_LUA_HEADERS],
+[
+  dnl Check for LUA_VERSION.
+  AC_MSG_CHECKING([if LUA_VERSION is defined])
+  AS_IF([test "x$LUA_VERSION" != 'x'],
+    [AC_MSG_RESULT([yes])],
+    [ AC_MSG_RESULT([no])
+      AC_MSG_ERROR([cannot check Lua headers without knowing LUA_VERSION])
+    ])
+
+  dnl Make LUA_INCLUDE a precious variable.
+  AC_ARG_VAR([LUA_INCLUDE], [The Lua includes, e.g. -I/usr/include/lua5.1])
+
+  dnl Some default directories to search.
+  LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'`
+  m4_define_default([_AX_LUA_INCLUDE_LIST],
+    [ /usr/include/lua$LUA_VERSION \
+      /usr/include/lua/$LUA_VERSION \
+      /usr/include/lua$LUA_SHORT_VERSION \
+      /usr/local/include/lua$LUA_VERSION \
+      /usr/local/include/lua/$LUA_VERSION \
+      /usr/local/include/lua$LUA_SHORT_VERSION \
+    ])
+
+  dnl Try to find the headers.
+  _ax_lua_saved_cppflags=$CPPFLAGS
+  CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
+  AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h])
+  CPPFLAGS=$_ax_lua_saved_cppflags
+
+  dnl Try some other directories if LUA_INCLUDE was not set.
+  AS_IF([test "x$LUA_INCLUDE" = 'x' &&
+         test "x$ac_cv_header_lua_h" != 'xyes'],
+    [ dnl Try some common include paths.
+      for _ax_include_path in _AX_LUA_INCLUDE_LIST; do
+        test ! -d "$_ax_include_path" && continue
+
+        AC_MSG_CHECKING([for Lua headers in])
+        AC_MSG_RESULT([$_ax_include_path])
+
+        AS_UNSET([ac_cv_header_lua_h])
+        AS_UNSET([ac_cv_header_lualib_h])
+        AS_UNSET([ac_cv_header_lauxlib_h])
+        AS_UNSET([ac_cv_header_luaconf_h])
+
+        _ax_lua_saved_cppflags=$CPPFLAGS
+        CPPFLAGS="$CPPFLAGS -I$_ax_include_path"
+        AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h])
+        CPPFLAGS=$_ax_lua_saved_cppflags
+
+        AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'],
+          [ LUA_INCLUDE="-I$_ax_include_path"
+            break
+          ])
+      done
+    ])
+
+  AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'],
+    [ dnl Make a program to print LUA_VERSION defined in the header.
+      dnl TODO This probably shouldn't be a runtime test.
+
+      AC_CACHE_CHECK([for Lua header version],
+        [ax_cv_lua_header_version],
+        [ _ax_lua_saved_cppflags=$CPPFLAGS
+          CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
+          AC_RUN_IFELSE(
+            [ AC_LANG_SOURCE([[
+#include <lua.h>
+#include <stdlib.h>
+#include <stdio.h>
+int main(int argc, char ** argv)
+{
+  if(argc > 1) printf("%s", LUA_VERSION);
+  exit(EXIT_SUCCESS);
+}
+]])
+            ],
+            [ ax_cv_lua_header_version=`./conftest$EXEEXT p | \
+                sed "s|^Lua \(.*\)|\1|" | \
+                grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"`
+            ],
+            [ax_cv_lua_header_version='unknown'])
+          CPPFLAGS=$_ax_lua_saved_cppflags
+        ])
+
+      dnl Compare this to the previously found LUA_VERSION.
+      AC_MSG_CHECKING([if Lua header version matches $LUA_VERSION])
+      AS_IF([test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"],
+        [ AC_MSG_RESULT([yes])
+          ax_header_version_match='yes'
+        ],
+        [ AC_MSG_RESULT([no])
+          ax_header_version_match='no'
+        ])
+    ])
+
+  dnl Was LUA_INCLUDE specified?
+  AS_IF([test "x$ax_header_version_match" != 'xyes' &&
+         test "x$LUA_INCLUDE" != 'x'],
+    [AC_MSG_ERROR([cannot find headers for specified LUA_INCLUDE])])
+
+  dnl Test the final result and run user code.
+  AS_IF([test "x$ax_header_version_match" = 'xyes'], [$1],
+    [m4_default([$2], [AC_MSG_ERROR([cannot find Lua includes])])])
+])
+
+dnl AX_LUA_HEADERS_VERSION no longer exists, use AX_LUA_HEADERS.
+AC_DEFUN([AX_LUA_HEADERS_VERSION],
+[
+  AC_MSG_WARN([[$0 is deprecated, please use AX_LUA_HEADERS]])
+])
+
+
+dnl =========================================================================
+dnl AX_LUA_LIBS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl =========================================================================
+AC_DEFUN([AX_LUA_LIBS],
+[
+  dnl TODO Should this macro also check various -L flags?
+
+  dnl Check for LUA_VERSION.
+  AC_MSG_CHECKING([if LUA_VERSION is defined])
+  AS_IF([test "x$LUA_VERSION" != 'x'],
+    [AC_MSG_RESULT([yes])],
+    [ AC_MSG_RESULT([no])
+      AC_MSG_ERROR([cannot check Lua libs without knowing LUA_VERSION])
+    ])
+
+  dnl Make LUA_LIB a precious variable.
+  AC_ARG_VAR([LUA_LIB], [The Lua library, e.g. -llua5.1])
+
+  AS_IF([test "x$LUA_LIB" != 'x'],
+  [ dnl Check that LUA_LIBS works.
+    _ax_lua_saved_libs=$LIBS
+    LIBS="$LIBS $LUA_LIB"
+    AC_SEARCH_LIBS([lua_load], [],
+      [_ax_found_lua_libs='yes'],
+      [_ax_found_lua_libs='no'])
+    LIBS=$_ax_lua_saved_libs
+
+    dnl Check the result.
+    AS_IF([test "x$_ax_found_lua_libs" != 'xyes'],
+      [AC_MSG_ERROR([cannot find libs for specified LUA_LIB])])
+  ],
+  [ dnl First search for extra libs.
+    _ax_lua_extra_libs=''
+
+    _ax_lua_saved_libs=$LIBS
+    LIBS="$LIBS $LUA_LIB"
+    AC_SEARCH_LIBS([exp], [m])
+    AC_SEARCH_LIBS([dlopen], [dl])
+    LIBS=$_ax_lua_saved_libs
+
+    AS_IF([test "x$ac_cv_search_exp" != 'xno' &&
+           test "x$ac_cv_search_exp" != 'xnone required'],
+      [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp"])
+
+    AS_IF([test "x$ac_cv_search_dlopen" != 'xno' &&
+           test "x$ac_cv_search_dlopen" != 'xnone required'],
+      [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen"])
+
+    dnl Try to find the Lua libs.
+    _ax_lua_saved_libs=$LIBS
+    LIBS="$LIBS $LUA_LIB"
+    AC_SEARCH_LIBS([lua_load], [lua$LUA_VERSION lua$LUA_SHORT_VERSION lua],
+      [_ax_found_lua_libs='yes'],
+      [_ax_found_lua_libs='no'],
+      [$_ax_lua_extra_libs])
+    LIBS=$_ax_lua_saved_libs
+
+    AS_IF([test "x$ac_cv_search_lua_load" != 'xno' &&
+           test "x$ac_cv_search_lua_load" != 'xnone required'],
+      [LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs"])
+  ])
+
+  dnl Test the result and run user code.
+  AS_IF([test "x$_ax_found_lua_libs" = 'xyes'], [$1],
+    [m4_default([$2], [AC_MSG_ERROR([cannot find Lua libs])])])
+])
+
+
+dnl =========================================================================
+dnl AX_LUA_READLINE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl =========================================================================
+AC_DEFUN([AX_LUA_READLINE],
+[
+  AX_LIB_READLINE
+  AS_IF([test "x$ac_cv_header_readline_readline_h" != 'x' &&
+         test "x$ac_cv_header_readline_history_h" != 'x'],
+    [ LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS"
+      $1
+    ],
+    [$2])
+])
diff --git a/middle-pgsql.c b/middle-pgsql.c
index 1c6c491..5c87440 100644
--- a/middle-pgsql.c
+++ b/middle-pgsql.c
@@ -15,6 +15,7 @@
 #include <assert.h>
 #include <math.h>
 #include <time.h>
+#include <errno.h>
 
 #ifdef HAVE_PTHREAD
 #include <pthread.h>
@@ -84,8 +85,8 @@ static struct table_desc tables [] = {
       .prepare = "PREPARE insert_node (" POSTGRES_OSMID_TYPE ", double precision, double precision, text[]) AS INSERT INTO %p_nodes VALUES ($1,$2,$3,$4);\n"
 #endif
                "PREPARE get_node (" POSTGRES_OSMID_TYPE ") AS SELECT lat,lon,tags FROM %p_nodes WHERE id = $1 LIMIT 1;\n"
+               "PREPARE get_node_list(" POSTGRES_OSMID_TYPE "[]) AS SELECT id, lat, lon FROM %p_nodes WHERE id = ANY($1::" POSTGRES_OSMID_TYPE "[])",
                "PREPARE delete_node (" POSTGRES_OSMID_TYPE ") AS DELETE FROM %p_nodes WHERE id = $1;\n",
-.prepare_intarray = "PREPARE get_node_list(" POSTGRES_OSMID_TYPE "[]) AS SELECT id, lat, lon FROM %p_nodes WHERE id = ANY($1::" POSTGRES_OSMID_TYPE "[])",
          .copy = "COPY %p_nodes FROM STDIN;\n",
       .analyze = "ANALYZE %p_nodes;\n",
          .stop = "COMMIT;\n"
@@ -103,7 +104,8 @@ static struct table_desc tables [] = {
                "PREPARE way_done(" POSTGRES_OSMID_TYPE ") AS UPDATE %p_ways SET pending = false WHERE id = $1;\n"
                "PREPARE pending_ways AS SELECT id FROM %p_ways WHERE pending;\n"
                "PREPARE delete_way(" POSTGRES_OSMID_TYPE ") AS DELETE FROM %p_ways WHERE id = $1;\n",
-.prepare_intarray = "PREPARE node_changed_mark(" POSTGRES_OSMID_TYPE ") AS UPDATE %p_ways SET pending = true WHERE nodes && ARRAY[$1] AND NOT pending;\n",
+.prepare_intarray = "PREPARE node_changed_mark(" POSTGRES_OSMID_TYPE ") AS UPDATE %p_ways SET pending = true WHERE nodes && ARRAY[$1] AND NOT pending;\n"
+               "PREPARE rel_delete_mark(" POSTGRES_OSMID_TYPE ") AS UPDATE %p_ways SET pending = true WHERE id IN (SELECT unnest(parts[way_off+1:rel_off]) FROM %p_rels WHERE id = $1) AND NOT pending;\n",
          .copy = "COPY %p_ways FROM STDIN;\n",
       .analyze = "ANALYZE %p_ways;\n",
          .stop =  "COMMIT;\n"
@@ -467,6 +469,7 @@ static int middle_nodes_set(osmid_t id, double lat, double lon, struct keyval *t
 }
 
 
+#if 0
 static int pgsql_nodes_get(struct osmNode *out, osmid_t id)
 {
     PGresult   *res;
@@ -497,6 +500,7 @@ static int pgsql_nodes_get(struct osmNode *out, osmid_t id)
     PQclear(res);
     return 0;
 }
+#endif
 
 /* Currently not used 
 static int middle_nodes_get(struct osmNode *out, osmid_t id)
@@ -872,9 +876,9 @@ static void pgsql_iterate_ways(int (*callback)(osmid_t id, struct keyval *tags,
         if (pid==-1) {
 #if HAVE_MMAP
             info[p].finished = HELPER_STATE_FAILED;
-            fprintf(stderr,"WARNING: Failed to fork helper processes %i. Trying to recover.\n", p);
+            fprintf(stderr,"WARNING: Failed to fork helper process %i: %s. Trying to recover.\n", p, strerror(errno));
 #else
-            fprintf(stderr,"ERROR: Failed to fork helper processes. Can't recover! \n");
+            fprintf(stderr,"ERROR: Failed to fork helper process %i: %s. Can't recover!\n", p, strerror(errno));
             exit_nicely();
 #endif            
         }
@@ -1212,10 +1216,12 @@ static int pgsql_rels_delete(osmid_t osm_id)
     char const *paramValues[1];
     char buffer[64];
     /* Make sure we're out of copy mode */
+    pgsql_endCopy( way_table );
     pgsql_endCopy( rel_table );
     
     sprintf( buffer, "%" PRIdOSMID, osm_id );
     paramValues[0] = buffer;
+    pgsql_execPrepared(way_table->sql_conn, "rel_delete_mark", 1, paramValues, PGRES_COMMAND_OK );
     pgsql_execPrepared(rel_table->sql_conn, "delete_rel", 1, paramValues, PGRES_COMMAND_OK );
     return 0;
 }
@@ -1682,7 +1688,7 @@ static int pgsql_start(const struct output_options *options)
             pgsql_exec(sql_conn, PGRES_COMMAND_OK, "%s", tables[i].prepare);
         }
 
-        if (tables[i].prepare_intarray) {
+        if (Append && tables[i].prepare_intarray) {
             pgsql_exec(sql_conn, PGRES_COMMAND_OK, "%s", tables[i].prepare_intarray);
         }
 
diff --git a/middle-ram.c b/middle-ram.c
index 0299fe3..27d50c2 100644
--- a/middle-ram.c
+++ b/middle-ram.c
@@ -58,7 +58,6 @@ struct ramRel {
 static struct ramWay     *ways[NUM_BLOCKS];
 static struct ramRel     *rels[NUM_BLOCKS];
 
-static int node_blocks;
 static int way_blocks;
 
 static int way_out_count;
diff --git a/node-persistent-cache.c b/node-persistent-cache.c
index a3a6874..bd1047a 100644
--- a/node-persistent-cache.c
+++ b/node-persistent-cache.c
@@ -563,7 +563,7 @@ int persistent_cache_nodes_get_list(struct osmNode *nodes, osmid_t *ndids,
 
 void init_node_persistent_cache(const struct output_options *options, int append)
 {
-    int i;
+    int i, err;
     scale = options->scale;
     append_mode = append;
     node_cache_fname = options->flat_node_file;
@@ -610,12 +610,17 @@ void init_node_persistent_cache(const struct output_options *options, int append
         {
 
             #ifdef HAVE_POSIX_FALLOCATE
-            if (posix_fallocate(node_cache_fd, 0,
-                    sizeof(struct ramNode) * MAXIMUM_INITIAL_ID) != 0)
+            if ((err = posix_fallocate(node_cache_fd, 0,
+                    sizeof(struct ramNode) * MAXIMUM_INITIAL_ID)) != 0)
             {
-                fprintf(stderr,
-                        "Failed to allocate space for node cache file: %s\n",
-                        strerror(errno));
+                if (err == ENOSPC) {
+                    fprintf(stderr, "Failed to allocate space for node cache file: No space on disk\n");
+                } else if (err == EFBIG) {
+                    fprintf(stderr, "Failed to allocate space for node cache file: File is too big\n");
+                } else {
+                    fprintf(stderr, "Failed to allocate space for node cache file: Internal error %i\n", err);
+                }
+
                 close(node_cache_fd);
                 exit_nicely();
             }
diff --git a/node-persistent-cache.h b/node-persistent-cache.h
index 881b56d..babf9a5 100644
--- a/node-persistent-cache.h
+++ b/node-persistent-cache.h
@@ -1,4 +1,4 @@
-#define MAXIMUM_INITIAL_ID (1L << 31)
+#define MAXIMUM_INITIAL_ID 2600000000
 
 #define READ_NODE_CACHE_SIZE 10000
 #define READ_NODE_BLOCK_SHIFT 10l
diff --git a/node-ram-cache.c b/node-ram-cache.c
index 3606391..496fc17 100644
--- a/node-ram-cache.c
+++ b/node-ram-cache.c
@@ -164,6 +164,8 @@ static int ram_cache_nodes_set_dense(osmid_t id, double lat, double lon, struct
     int offset = id2offset(id);
     int i = 0;
 
+    if (maxBlocks == 0) return 1;
+
     if (!blocks[block].nodes) {
         if (((allocStrategy & ALLOC_SPARSE) > 0) && ( usedBlocks < maxBlocks) && ( cacheUsed > cacheSize)) {
             /* TODO: It is more memory efficient to drop nodes from the sparse node cache than from the dense node cache */
@@ -353,8 +355,8 @@ void init_node_ram_cache( int strategy, int cacheSizeMB, int fixpointscale ) {
     cacheUsed = 0;
     cacheSize = (int64_t)cacheSizeMB*(1024*1024);
     /* How much we can fit, and make sure it's odd */
-    maxBlocks = (cacheSize/(PER_BLOCK*sizeof(struct ramNode))) | 1;
-    maxSparseTuples = (cacheSize/sizeof(struct ramNodeID)) | 1;
+    maxBlocks = (cacheSize/(PER_BLOCK*sizeof(struct ramNode)));
+    maxSparseTuples = (cacheSize/sizeof(struct ramNodeID));
     
     allocStrategy = strategy;
     scale = fixpointscale;
@@ -432,6 +434,7 @@ void free_node_ram_cache() {
           free(blockCache);
           blockCache = 0;
       }
+      free(blocks);
       free(queue);
   }
   if ( ((allocStrategy & ALLOC_SPARSE) > 0) && ((allocStrategy & ALLOC_DENSE) == 0)) {
diff --git a/node-ram-cache.h b/node-ram-cache.h
index 5196ddf..14e7692 100644
--- a/node-ram-cache.h
+++ b/node-ram-cache.h
@@ -17,7 +17,7 @@
 /* Scale is chosen such that 40,000 * SCALE < 2^32          */
 #define FIXED_POINT
 static int scale = 100;
-#define DOUBLE_TO_FIX(x) ((int)((x) * scale))
+#define DOUBLE_TO_FIX(x) ((int)((x) * scale + 0.4))
 #define FIX_TO_DOUBLE(x) (((double)x) / scale)
 
 #define UNUSED  __attribute__ ((unused))
diff --git a/osm2pgsql.c b/osm2pgsql.c
index 4524704..87a400d 100644
--- a/osm2pgsql.c
+++ b/osm2pgsql.c
@@ -116,129 +116,160 @@ static void short_usage(char *arg0)
 
 static void long_usage(char *arg0)
 {
-    int i;
     const char *name = basename(arg0);
 
     printf("Usage:\n");
     printf("\t%s [options] planet.osm\n", name);
-    printf("\t%s [options] planet.osm.{gz,bz2}\n", name);
+    printf("\t%s [options] planet.osm.{pbf,gz,bz2}\n", name);
     printf("\t%s [options] file1.osm file2.osm file3.osm\n", name);
     printf("\nThis will import the data from the OSM file(s) into a PostgreSQL database\n");
-    printf("suitable for use by the Mapnik renderer\n");
-    printf("\nOptions:\n");
-    printf("   -a|--append\t\tAdd the OSM file into the database without removing\n");
-    printf("              \t\texisting data.\n");
-    printf("   -b|--bbox\t\tApply a bounding box filter on the imported data\n");
-    printf("              \t\tMust be specified as: minlon,minlat,maxlon,maxlat\n");
-    printf("              \t\te.g. --bbox -0.5,51.25,0.5,51.75\n");
-    printf("   -c|--create\t\tRemove existing data from the database. This is the \n");
-    printf("              \t\tdefault if --append is not specified.\n");
-    printf("   -d|--database\tThe name of the PostgreSQL database to connect\n");
-    printf("              \t\tto (default: gis).\n");
-    printf("   -i|--tablespace-index\tThe name of the PostgreSQL tablespace where\n");
-    printf("              \t\tall indexes will be created.\n");
-    printf("              \t\tThe following options allow more fine-grained control:\n");
-    printf("      --tablespace-main-data \ttablespace for main tables\n");
-    printf("      --tablespace-main-index\ttablespace for main table indexes\n");
-    printf("      --tablespace-slim-data \ttablespace for slim mode tables\n");
-    printf("      --tablespace-slim-index\ttablespace for slim mode indexes\n");
-    printf("              \t\t(if unset, use db's default; -i is equivalent to setting\n");
-    printf("              \t\t--tablespace-main-index and --tablespace-slim-index)\n");
-    printf("   -l|--latlong\t\tStore data in degrees of latitude & longitude.\n");
-    printf("   -m|--merc\t\tStore data in proper spherical mercator (default)\n");
-    printf("   -M|--oldmerc\t\tStore data in the legacy OSM mercator format\n");
-    printf("   -E|--proj num\tUse projection EPSG:num\n");
-    printf("   -u|--utf8-sanitize\tRepair bad UTF8 input data (present in planet\n");
-    printf("                \tdumps prior to August 2007). Adds about 10%% overhead.\n");
-    printf("   -p|--prefix\t\tPrefix for table names (default planet_osm)\n");
-    printf("   -s|--slim\t\tStore temporary data in the database. This greatly\n");
-    printf("            \t\treduces the RAM usage but is much slower. This switch is\n");
-    printf("            \t\trequired if you want to update with --append later.\n");
-
-    if (sizeof(int*) == 4) {
-        printf("            \t\tThis program was compiled on a 32bit system, so at most\n");
-        printf("            \t\t3GB of RAM will be used. If you encounter problems\n");
-        printf("            \t\tduring import, you should try this switch.\n");
-    }
-    printf("      --drop\t\tonly with --slim: drop temporary tables after import (no updates).\n");
-    
-    printf("   -S|--style\t\tLocation of the style file. Defaults to " OSM2PGSQL_DATADIR "/default.style\n");
-    printf("   -C|--cache\t\tNow required for slim and non-slim modes: \n");
-    printf("             \t\tUse up to this many MB for caching nodes (default: 800)\n");
-    printf("   -U|--username\tPostgresql user name\n");
-    printf("             \t\tpassword can be given by prompt or PGPASS environment variable.\n");
-    printf("   -W|--password\tForce password prompt.\n");
-    printf("   -H|--host\t\tDatabase server hostname or socket location.\n");
-    printf("   -P|--port\t\tDatabase server port.\n");
-    printf("   -e|--expire-tiles [min_zoom-]max_zoom\tCreate a tile expiry list.\n");
-    printf("   -o|--expire-output filename\tOutput filename for expired tiles list.\n");
-    printf("   -r|--input-reader\tInput frontend.\n");
-    printf("              \t\tlibxml2   - Parse XML using libxml2. (default)\n");
-    printf("              \t\tprimitive - Primitive XML parsing.\n");
-#ifdef BUILD_READER_PBF
-    printf("              \t\tpbf       - OSM binary format.\n");
-#endif
-    printf("   -O|--output\t\tOutput backend.\n");
-    printf("              \t\tpgsql - Output to a PostGIS database. (default)\n");
-    printf("              \t\tgazetteer - Output to a PostGIS database suitable for gazetteer\n");
-    printf("              \t\tnull  - No output. Useful for testing.\n");
-    printf("   -x|--extra-attributes\n");
-    printf("              \t\tInclude attributes for each object in the database.\n");
-    printf("              \t\tThis includes the username, userid, timestamp and version.\n"); 
-    printf("              \t\tNote: this option also requires additional entries in your style file.\n"); 
-    printf("   -k|--hstore\t\tAdd tags without column to an additional hstore (key/value) column to postgresql tables\n");
-    printf("      --hstore-match-only\tOnly keep objects that have a value in one of the columns\n");
-    printf("      -                  \t(normal action with --hstore is to keep all objects)\n");
-    printf("   -j|--hstore-all\tAdd all tags to an additional hstore (key/value) column in postgresql tables\n");
-    printf("   -z|--hstore-column\tAdd an additional hstore (key/value) column containing all tags\n");
-    printf("                     \tthat start with the specified string, eg --hstore-column \"name:\" will\n");
-    printf("                     \tproduce an extra hstore column that contains all name:xx tags\n");
-    printf("      --hstore-add-index\tAdd index to hstore column.\n");
-    printf("   -G|--multi-geometry\tGenerate multi-geometry features in postgresql tables.\n");
-    printf("   -K|--keep-coastlines\tKeep coastline data rather than filtering it out.\n");
-    printf("              \t\tBy default natural=coastline tagged data will be discarded based on the\n");
-    printf("              \t\tassumption that post-processed Coastline Checker shapefiles will be used.\n");
-    printf("      --exclude-invalid-polygon\n");
-#ifdef HAVE_FORK
-    printf("      --number-processes\t\tSpecifies the number of parallel processes used for certain operations\n");
-    printf("             \t\tDefault is 1\n");
-#endif
-    printf("   -I|--disable-parallel-indexing\tDisable indexing all tables concurrently.\n");
-    printf("      --unlogged\tUse unlogged tables (lost on crash but faster). Requires PostgreSQL 9.1.\n");
-    printf("      --cache-strategy\tSpecifies the method used to cache nodes in ram.\n");
-    printf("                      \t\tAvailable options are:\n");
-    printf("                      \t\tdense: caching strategy optimised for full planet import\n");
-    printf("                      \t\tchunked: caching strategy optimised for non-contigouse memory allocation\n");
-    printf("                      \t\tsparse: caching strategy optimised for small extracts\n");
-    printf("                      \t\toptimized: automatically combines dense and sparse strategies for optimal storage efficiency.\n");
-    printf("                      \t\t           optimized may use twice as much virtual memory, but no more physical memory\n");
-
+    printf("suitable for use by the Mapnik renderer.\n\n");
+
+    printf("%s", "\
+Common options:\n\
+   -a|--append      Add the OSM file into the database without removing\n\
+                    existing data.\n\
+   -c|--create      Remove existing data from the database. This is the\n\
+                    default if --append is not specified.\n\
+   -l|--latlong     Store data in degrees of latitude & longitude.\n\
+   -m|--merc        Store data in proper spherical mercator (default).\n\
+   -E|--proj num    Use projection EPSG:num.\n\
+   -s|--slim        Store temporary data in the database. This greatly\n\
+                    reduces the RAM usage but is much slower. This switch is\n\
+                    required if you want to update with --append later.\n\
+   -S|--style       Location of the style file. Defaults to\n");
+    printf("                    %s/default.style.\n", OSM2PGSQL_DATADIR);
+    printf("%s", "\
+   -C|--cache       Use up to this many MB for caching nodes (default: 800)\n\
+\n\
+Database options:\n\
+   -d|--database    The name of the PostgreSQL database to connect\n\
+                    to (default: gis).\n\
+   -U|--username    PostgreSQL user name (specify passsword in PGPASS\n\
+                    environment variable or use -W).\n\
+   -W|--password    Force password prompt.\n\
+   -H|--host        Database server host name or socket location.\n\
+   -P|--port        Database server port.\n");
+
+    if (verbose) 
+    {
+        printf("%s", "\
+Hstore options:\n\
+   -k|--hstore      Add tags without column to an additional hstore\n\
+                    (key/value) column\n\
+      --hstore-match-only   Only keep objects that have a value in one of\n\
+                    the columns (default with --hstore is to keep all objects)\n\
+   -j|--hstore-all  Add all tags to an additional hstore (key/value) column\n\
+   -z|--hstore-column   Add an additional hstore (key/value) column containing\n\
+                    all tags that start with the specified string, eg\n\
+                    --hstore-column \"name:\" will produce an extra hstore\n\
+                    column that contains all name:xx tags\n\
+      --hstore-add-index    Add index to hstore column.\n\
+\n\
+Obsolete options:\n\
+   -u|--utf8-sanitize   Repair bad UTF8 input data (present in planet\n\
+                    dumps prior to August 2007). Adds about 10% overhead.\n\
+   -M|--oldmerc     Store data in the legacy OSM mercator format\n\
+\n\
+Performance options:\n\
+   -i|--tablespace-index    The name of the PostgreSQL tablespace where\n\
+                    all indexes will be created.\n\
+                    The following options allow more fine-grained control:\n\
+      --tablespace-main-data    tablespace for main tables\n\
+      --tablespace-main-index   tablespace for main table indexes\n\
+      --tablespace-slim-data    tablespace for slim mode tables\n\
+      --tablespace-slim-index   tablespace for slim mode indexes\n\
+                    (if unset, use db's default; -i is equivalent to setting\n\
+                    --tablespace-main-index and --tablespace-slim-index)\n\
+      --drop        only with --slim: drop temporary tables after import \n\
+                    (no updates are possible).\n\
+      --number-processes        Specifies the number of parallel processes \n\
+                    used for certain operations (default is 1).\n\
+   -I|--disable-parallel-indexing   Disable indexing all tables concurrently.\n\
+      --unlogged    Use unlogged tables (lost on crash but faster). \n\
+                    Requires PostgreSQL 9.1.\n\
+      --cache-strategy  Specifies the method used to cache nodes in ram.\n\
+                    Available options are:\n\
+                    dense: caching strategy optimised for full planet import\n\
+                    chunk: caching strategy optimised for non-contiguous \n\
+                        memory allocation\n\
+                    sparse: caching strategy optimised for small extracts\n\
+                    optimized: automatically combines dense and sparse \n\
+                        strategies for optimal storage efficiency. This may\n\
+                        us twice as much virtual memory, but no more physical \n\
+                        memory.\n");
 #ifdef __amd64__
-    printf("                      \t\t   The default is \"optimized\"\n");
+    printf("                    The default is \"optimized\"\n");
 #else
     /* use "chunked" as a default in 32 bit compilations, as it is less wasteful of virtual memory than "optimized"*/
-    printf("                      \t\t   The default is \"sparse\"\n");
+    printf("                    The default is \"sparse\"\n");
 #endif
-    printf("      --flat-nodes\tSpecifies the flat file to use to persistently store node information in slim mode instead of in pgsql\n");
-    printf("                  \t\tThis file is a single > 16Gb large file. This method is only recomended for full planet imports\n");
-    printf("                   \t\tas it doesn't work well with small extracts. The default is disabled\n");
-    printf("   -h|--help\t\tHelp information.\n");
-    printf("   -v|--verbose\t\tVerbose output.\n");
-    printf("\n");
-    if(!verbose)
-    {
-        printf("Add -v to display supported projections.\n");
-        printf("Use -E to access any espg projections (usually in /usr/share/proj/epsg)\n" );
+    printf("%s", "\
+      --flat-nodes  Specifies the flat file to use to persistently store node \n\
+                    information in slim mode instead of in PostgreSQL.\n\
+                    This file is a single > 16Gb large file. Only recommended\n\
+                    for full planet imports. Default is disabled.\n\
+\n\
+Expiry options:\n\
+   -e|--expire-tiles [min_zoom-]max_zoom    Create a tile expiry list.\n\
+   -o|--expire-output filename  Output filename for expired tiles list.\n\
+\n\
+Other options:\n\
+   -b|--bbox        Apply a bounding box filter on the imported data\n\
+                    Must be specified as: minlon,minlat,maxlon,maxlat\n\
+                    e.g. --bbox -0.5,51.25,0.5,51.75\n\
+   -p|--prefix      Prefix for table names (default planet_osm)\n\
+   -r|--input-reader    Input frontend.\n\
+                    libxml2   - Parse XML using libxml2. (default)\n\
+                    primitive - Primitive XML parsing.\n");
+#ifdef BUILD_READER_PBF
+    printf("                    pbf       - OSM binary format.\n");
+#endif
+    printf("\
+   -O|--output      Output backend.\n\
+                    pgsql - Output to a PostGIS database. (default)\n\
+                    gazetteer - Output to a PostGIS database for Nominatim\n\
+                    null - No output. Useful for testing.\n");
+#ifdef HAVE_LUA
+    printf("\
+      --tag-transform-script  Specify a lua script to handle tag filtering and normalisation\n\
+                    The script contains callback functions for nodes, ways and relations, which each\n\
+                    take a set of tags and returns a transformed, filtered set of tags which are then\n\
+                    written to the database.\n");
+#endif
+    printf("\
+   -x|--extra-attributes\n\
+                    Include attributes for each object in the database.\n\
+                    This includes the username, userid, timestamp and version.\n\
+                    Requires additional entries in your style file.\n\
+   -G|--multi-geometry  Generate multi-geometry features in postgresql tables.\n\
+   -K|--keep-coastlines Keep coastline data rather than filtering it out.\n\
+                    By default natural=coastline tagged data will be discarded\n\
+                    because renderers usually have shape files for them.\n\
+      --exclude-invalid-polygon   do not import polygons with invalid geometries.\n\
+   -h|--help        Help information.\n\
+   -v|--verbose     Verbose output.\n");
     }
     else
     {
-        printf("Supported projections:\n" );
-        for(i=0; i<PROJ_COUNT; i++ )
-        {
-            printf( "%-20s(%2s) SRS:%6d %s\n", 
-                    Projection_Info[i].descr, Projection_Info[i].option, Projection_Info[i].srs, Projection_Info[i].proj4text);
-        }
+        printf("\n");
+        printf("A typical command to import a full planet is\n");
+        printf("    %s -c -d gis --slim -C <cache size> -k \\\n", name);
+        printf("      --flat-nodes <flat nodes> planet-latest.osm.pbf\n");
+        printf("where\n");
+        printf("    <cache size> is 20000 on machines with 24GB or more RAM \n");
+        printf("      or about 75%% of memory in MB on machines with less\n");
+        printf("    <flat nodes> is a location where a 19GB file can be saved.\n");
+        printf("\n");
+        printf("A typical command to update a database imported with the above command is\n");
+        printf("    osmosis --rri workingDirectory=<osmosis dir> --simc --wx - \\\n");
+        printf("      | %s -a -d gis --slim -k --flat-nodes <flat nodes> \n", name);
+        printf("where\n");
+        printf("    <flat nodes> is the same location as above.\n");
+        printf("    <osmosis dir> is the location osmosis replication was initialized to.\n");
+        printf("\nRun %s --help --verbose (-h -v) for a full list of options.\n", name);
     }
+
 }
 
 const char *build_conninfo(const char *db, const char *username, const char *password, const char *host, const char *port)
@@ -394,6 +425,7 @@ int main(int argc, char *argv[])
     const char *input_reader = "auto";
     const char **hstore_columns = NULL;
     const char *flat_nodes_file = NULL;
+    const char *tag_transform_script = NULL;
     int n_hstore_columns = 0;
     int keep_coastlines=0;
     int cache = 800;
@@ -451,6 +483,7 @@ int main(int argc, char *argv[])
             {"unlogged", 0, 0, 207},
             {"flat-nodes",1,0,209},
             {"exclude-invalid-polygon",0,0,210},
+            {"tag-transform-script",1,0,212},
             {0, 0, 0, 0}
         };
 
@@ -492,9 +525,11 @@ int main(int argc, char *argv[])
             case 'o': expire_tiles_filename=optarg; break;
             case 'O': output_backend = optarg; break;
             case 'x': osmdata.extra_attributes=1; break;
-            case 'k': enable_hstore=HSTORE_NORM; break;
+            case 'k':  if (enable_hstore != HSTORE_NONE) { fprintf(stderr, "ERROR: You can not specify both --hstore (-k) and --hstore-all (-j)\n"); exit (EXIT_FAILURE); }
+                enable_hstore=HSTORE_NORM; break;
             case 208: hstore_match_only = 1; break;
-            case 'j': enable_hstore=HSTORE_ALL; break;
+            case 'j': if (enable_hstore != HSTORE_NONE) { fprintf(stderr, "ERROR: You can not specify both --hstore (-k) and --hstore-all (-j)\n"); exit (EXIT_FAILURE); }
+                enable_hstore=HSTORE_ALL; break;
             case 'z': 
                 n_hstore_columns++;
                 hstore_columns = (const char**)realloc(hstore_columns, sizeof(char *) * n_hstore_columns);
@@ -510,9 +545,10 @@ int main(int argc, char *argv[])
                 break;
             case 204:
                 if (strcmp(optarg,"dense") == 0) alloc_chunkwise = ALLOC_DENSE;
-                if (strcmp(optarg,"chunk") == 0) alloc_chunkwise = ALLOC_DENSE | ALLOC_DENSE_CHUNK;
-                if (strcmp(optarg,"sparse") == 0) alloc_chunkwise = ALLOC_SPARSE;
-                if (strcmp(optarg,"optimized") == 0) alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE;
+                else if (strcmp(optarg,"chunk") == 0) alloc_chunkwise = ALLOC_DENSE | ALLOC_DENSE_CHUNK;
+                else if (strcmp(optarg,"sparse") == 0) alloc_chunkwise = ALLOC_SPARSE;
+                else if (strcmp(optarg,"optimized") == 0) alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE;
+                else {fprintf(stderr, "ERROR: Unrecognized cache strategy %s.\n", optarg); exit(EXIT_FAILURE); }
                 break;
             case 205:
 #ifdef HAVE_FORK                
@@ -529,6 +565,7 @@ int main(int argc, char *argv[])
             	break;
             case 210: excludepoly = 1; exclude_broken_polygon(); break;
             case 211: enable_hstore_index = 1; break;
+            case 212: tag_transform_script = optarg; break;
             case 'V': exit(EXIT_SUCCESS);
             case '?':
             default:
@@ -575,6 +612,10 @@ int main(int argc, char *argv[])
 
     if (cache < 0) cache = 0;
 
+    if (cache == 0) {
+        fprintf(stderr, "WARNING: ram cache is disabled. This will likely slow down processing a lot.\n\n");
+    }
+
     if (num_procs < 1) num_procs = 1;
 
     if (pass_prompt)
@@ -646,6 +687,7 @@ int main(int argc, char *argv[])
     options.flat_node_cache_enabled = flat_node_cache_enabled;
     options.flat_node_file = flat_nodes_file;
     options.excludepoly = excludepoly;
+    options.tag_transform_script = tag_transform_script;
 
     if (strcmp("pgsql", output_backend) == 0) {
       osmdata.out = &out_pgsql;
@@ -705,7 +747,7 @@ int main(int argc, char *argv[])
 	    fprintf(stderr, "ERROR: PBF support has not been compiled into this version of osm2pgsql, please either compile it with pbf support or use one of the other input formats\n");
 	    exit(EXIT_FAILURE);
 #endif
-          } else if (strcasecmp(".o5m",argv[optind]+strlen(argv[optind])-4) == 0) {
+          } else if (strcasecmp(".o5m",argv[optind]+strlen(argv[optind])-4) == 0 || strcasecmp(".o5c",argv[optind]+strlen(argv[optind])-4) == 0) {
               streamFile = &streamFileO5m;
           } else {
             streamFile = &streamFileXML2;
diff --git a/output-gazetteer.c b/output-gazetteer.c
index 03a8bd6..424c8be 100644
--- a/output-gazetteer.c
+++ b/output-gazetteer.c
@@ -38,6 +38,7 @@
    "  admin_level INTEGER,"                     \
    "  housenumber TEXT,"                        \
    "  street TEXT,"                             \
+   "  addr_place TEXT,"                              \
    "  isin TEXT,"                               \
    "  postcode TEXT,"                           \
    "  country_code VARCHAR(2),"                 \
@@ -63,9 +64,6 @@ static unsigned int BufferLen = 0;
 static PGconn *ConnectionDelete = NULL;
 
 static PGconn *ConnectionError = NULL;
-static int CopyErrorActive = 0;
-static char BufferError[BUFFER_SIZE];
-static unsigned int BufferErrorLen = 0;
 
 static FILE * hLog = NULL;
 
@@ -87,7 +85,7 @@ static void copy_data(const char *sql)
    /* Make sure we have an active copy */
    if (!CopyActive)
    {
-      pgsql_exec(Connection, PGRES_COPY_IN, "COPY place FROM STDIN");
+      pgsql_exec(Connection, PGRES_COPY_IN, "COPY place (osm_type, osm_id, class, type, name, admin_level, housenumber, street, addr_place, isin, postcode, country_code, extratags, geometry) FROM STDIN");
       CopyActive = 1;
    }
 
@@ -156,6 +154,7 @@ static void stop_copy(void)
    return;
 }
 
+#if 0
 static void copy_error_data(const char *sql)
 {
    unsigned int sqlLen = strlen(sql);
@@ -233,9 +232,10 @@ static void stop_error_copy(void)
 
    return;
 }
+#endif
 
 static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *names, struct keyval *places, struct keyval *extratags, 
-   int* admin_level, struct keyval ** housenumber, struct keyval ** street, char ** isin, struct keyval ** postcode, struct keyval ** countrycode)
+   int* admin_level, struct keyval ** housenumber, struct keyval ** street, struct keyval ** addr_place, char ** isin, struct keyval ** postcode, struct keyval ** countrycode)
 {
    int placehouse = 0;
    int placebuilding = 0;
@@ -249,6 +249,7 @@ static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *na
    *admin_level = ADMINLEVEL_NONE;
    *housenumber = 0;
    *street = 0;
+   *addr_place = 0;
    *isin = 0;
    int isinsize = 0;
    *postcode = 0;
@@ -320,22 +321,47 @@ static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *na
             pushItem(names, item);
          }
       }
+      else if (strcmp(item->key, "emergency") == 0 ||
+               strcmp(item->key, "tourism") == 0 ||
+               strcmp(item->key, "historic") == 0 ||
+               strcmp(item->key, "military") == 0 ||
+               strcmp(item->key, "natural") == 0)
+      {
+         if (strcmp(item->value, "no") && strcmp(item->value, "yes"))
+         {
+            pushItem(places, item);
+         }
+         else
+         {
+            freeItem(item);
+         }
+      }
+      else if (strcmp(item->key, "highway") == 0)
+      {
+         if (strcmp(item->value, "no") &&
+             strcmp(item->value, "turning_circle") &&
+             strcmp(item->value, "traffic_signals") &&
+             strcmp(item->value, "mini_roundabout") &&
+             strcmp(item->value, "noexit") &&
+             strcmp(item->value, "crossing"))
+         {
+             pushItem(places, item);
+         }
+         else
+         {
+             freeItem(item);
+         }
+      }
       else if (strcmp(item->key, "aerialway") == 0 ||
                strcmp(item->key, "aeroway") == 0 ||
                strcmp(item->key, "amenity") == 0 ||
                strcmp(item->key, "boundary") == 0 ||
                strcmp(item->key, "bridge") == 0 ||
                strcmp(item->key, "craft") == 0 ||
-               strcmp(item->key, "emergency") == 0 ||
-               strcmp(item->key, "highway") == 0 ||
-               strcmp(item->key, "historic") == 0 ||
                strcmp(item->key, "leisure") == 0 ||
-               strcmp(item->key, "military") == 0 ||
-               strcmp(item->key, "natural") == 0 ||
                strcmp(item->key, "office") == 0 ||
                strcmp(item->key, "railway") == 0 ||
                strcmp(item->key, "shop") == 0 ||
-               strcmp(item->key, "tourism") == 0 ||
                strcmp(item->key, "tunnel") == 0 ||
                strcmp(item->key, "waterway") == 0 )
       {
@@ -384,6 +410,10 @@ static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *na
       {
          *street = item;
       }
+      else if (strcmp(item->key, "addr:place") == 0)
+      {
+         *addr_place = item;
+      }
       else if ((strcmp(item->key, "country_code_iso3166_1_alpha_2") == 0 || 
                 strcmp(item->key, "country_code_iso3166_1") == 0 || 
                 strcmp(item->key, "country_code_iso3166") == 0 || 
@@ -708,7 +738,7 @@ static void delete_unused_classes(char osm_type, osmid_t osm_id, struct keyval *
 }
 
 static void add_place(char osm_type, osmid_t osm_id, const char *class, const char *type, struct keyval *names, struct keyval *extratags,
-   int adminlevel, struct keyval *housenumber, struct keyval *street, const char *isin, struct keyval *postcode, struct keyval *countrycode, const char *wkt)
+   int adminlevel, struct keyval *housenumber, struct keyval *street, struct keyval *addr_place, const char *isin, struct keyval *postcode, struct keyval *countrycode, const char *wkt)
 {
    int first;
    struct keyval *name;
@@ -779,6 +809,17 @@ static void add_place(char osm_type, osmid_t osm_id, const char *class, const ch
       copy_data("\\N\t");
    }
 
+   if (addr_place)
+   {
+      escape(sql, sizeof(sql), addr_place->value);
+      copy_data(sql);
+      copy_data("\t");
+   }
+   else
+   {
+      copy_data("\\N\t");
+   }
+
    if (isin)
    {
        /* Skip the leading ',' from the contactination */
@@ -851,6 +892,7 @@ static void add_place(char osm_type, osmid_t osm_id, const char *class, const ch
    return;
 }
 
+#if 0
 static void add_polygon_error(char osm_type, osmid_t osm_id, const char *class, const char *type, 
   struct keyval *names, const char *countrycode, const char *wkt)
 {
@@ -920,6 +962,7 @@ static void add_polygon_error(char osm_type, osmid_t osm_id, const char *class,
 
    return;
 }
+#endif
 
 
 static void delete_place(char osm_type, osmid_t osm_id)
@@ -1045,6 +1088,7 @@ static int gazetteer_process_node(osmid_t id, double lat, double lon, struct key
    int adminlevel;
    struct keyval * housenumber;
    struct keyval * street;
+   struct keyval * addr_place;
    char * isin;
    struct keyval * postcode;
    struct keyval * countrycode;
@@ -1052,7 +1096,7 @@ static int gazetteer_process_node(osmid_t id, double lat, double lon, struct key
 
 
    /* Split the tags */
-   split_tags(tags, TAGINFO_NODE, &names, &places, &extratags, &adminlevel, &housenumber, &street, &isin, &postcode, &countrycode);
+   split_tags(tags, TAGINFO_NODE, &names, &places, &extratags, &adminlevel, &housenumber, &street, &addr_place, &isin, &postcode, &countrycode);
 
    /* Feed this node to the middle layer */
    Options->mid->nodes_set(id, lat, lon, tags);
@@ -1066,12 +1110,13 @@ static int gazetteer_process_node(osmid_t id, double lat, double lon, struct key
       sprintf(wkt, "POINT(%.15g %.15g)", lon, lat);
       for (place = firstItem(&places); place; place = nextItem(&places, place))
       {
-         add_place('N', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, isin, postcode, countrycode, wkt);
+         add_place('N', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, addr_place, isin, postcode, countrycode, wkt);
       }
    }
 
    if (housenumber) freeItem(housenumber);
    if (street) freeItem(street);
+   if (addr_place) freeItem(addr_place);
    if (isin) free(isin);
    if (postcode) freeItem(postcode);
    if (countrycode) freeItem(countrycode);
@@ -1098,6 +1143,7 @@ static int gazetteer_process_way(osmid_t id, osmid_t *ndv, int ndc, struct keyva
    int adminlevel;
    struct keyval * housenumber;
    struct keyval * street;
+   struct keyval * addr_place;
    char * isin;
    struct keyval * postcode;
    struct keyval * countrycode;
@@ -1105,7 +1151,7 @@ static int gazetteer_process_way(osmid_t id, osmid_t *ndv, int ndc, struct keyva
 
 
    /* Split the tags */
-   area = split_tags(tags, TAGINFO_WAY, &names, &places, &extratags, &adminlevel, &housenumber, &street, &isin, &postcode, &countrycode);
+   area = split_tags(tags, TAGINFO_WAY, &names, &places, &extratags, &adminlevel, &housenumber, &street, &addr_place, &isin, &postcode, &countrycode);
 
    /* Feed this way to the middle layer */
    Options->mid->ways_set(id, ndv, ndc, tags, 0);
@@ -1129,7 +1175,7 @@ static int gazetteer_process_way(osmid_t id, osmid_t *ndv, int ndc, struct keyva
       {
          for (place = firstItem(&places); place; place = nextItem(&places, place))
          {
-            add_place('W', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, isin, postcode, countrycode, wkt);
+            add_place('W', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, addr_place, isin, postcode, countrycode, wkt);
          }
       }
 
@@ -1142,6 +1188,7 @@ static int gazetteer_process_way(osmid_t id, osmid_t *ndv, int ndc, struct keyva
 
    if (housenumber) freeItem(housenumber);
    if (street) freeItem(street);
+   if (addr_place) freeItem(addr_place);
    if (isin) free(isin);
    if (postcode) freeItem(postcode);
    if (countrycode) freeItem(countrycode);
@@ -1168,6 +1215,7 @@ static int gazetteer_process_relation(osmid_t id, struct member *members, int me
    int adminlevel;
    struct keyval * housenumber;
    struct keyval * street;
+   struct keyval * addr_place;
    char * isin;
    struct keyval * postcode;
    struct keyval * countrycode;
@@ -1195,7 +1243,7 @@ static int gazetteer_process_relation(osmid_t id, struct member *members, int me
    Options->mid->relations_set(id, members, member_count, tags);
 
    /* Split the tags */
-   split_tags(tags, TAGINFO_AREA, &names, &places, &extratags, &adminlevel, &housenumber, &street, &isin, &postcode, &countrycode);
+   split_tags(tags, TAGINFO_AREA, &names, &places, &extratags, &adminlevel, &housenumber, &street, &addr_place, &isin, &postcode, &countrycode);
 
    if (delete_old)
        delete_unused_classes('R', id, &places);
@@ -1233,7 +1281,7 @@ static int gazetteer_process_relation(osmid_t id, struct member *members, int me
          {
              for (place = firstItem(&places); place; place = nextItem(&places, place))
              {
-                add_place('R', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, isin, postcode, countrycode, wkt);
+                add_place('R', id, place->key, place->value, &names, &extratags, adminlevel, housenumber, street, addr_place, isin, postcode, countrycode, wkt);
              }
          }
          else
@@ -1259,6 +1307,7 @@ static int gazetteer_process_relation(osmid_t id, struct member *members, int me
 
    if (housenumber) freeItem(housenumber);
    if (street) freeItem(street);
+   if (addr_place) freeItem(addr_place);
    if (isin) free(isin);
    if (postcode) freeItem(postcode);
    if (countrycode) freeItem(countrycode);
diff --git a/output-pgsql.c b/output-pgsql.c
index 69f9d90..a9e55a4 100644
--- a/output-pgsql.c
+++ b/output-pgsql.c
@@ -32,6 +32,7 @@
 #include "expire-tiles.h"
 #include "wildcmp.h"
 #include "node-ram-cache.h"
+#include "tagtransform.h"
 
 #define SRID (project_getprojinfo()->srs)
 
@@ -66,11 +67,7 @@ static struct s_table {
 };
 #define NUM_TABLES ((signed)(sizeof(tables) / sizeof(tables[0])))
 
-#define FLAG_POLYGON 1    /* For polygon table */
-#define FLAG_LINEAR  2    /* For lines table */
-#define FLAG_NOCACHE 4    /* Optimisation: don't bother remembering this one */
-#define FLAG_DELETE  8    /* These tags should be simply deleted on sight */
-#define FLAG_PHSTORE 17   /* polygons without own column but listed in hstore this implies FLAG_POLYGON */
+
 static struct flagsname {
     char *name;
     int flag;
@@ -83,43 +80,10 @@ static struct flagsname {
 };
 #define NUM_FLAGS ((signed)(sizeof(tagflags) / sizeof(tagflags[0])))
 
-/* Table columns, representing key= tags */
-struct taginfo {
-    char *name;
-    char *type;
-    int flags;
-    int count;
-};
 
-static struct taginfo *exportList[4]; /* Indexed by enum table_id */
-static int exportListCount[4];
 
-/* Data to generate z-order column and road table
- * The name of the roads table is misleading, this table
- * is used for any feature to be shown at low zoom.
- * This includes railways and administrative boundaries too
- */
-static struct {
-    int offset;
-    const char *highway;
-    int roads;
-} layers[] = {
-    { 3, "minor",         0 },
-    { 3, "road",          0 },
-    { 3, "unclassified",  0 },
-    { 3, "residential",   0 },
-    { 4, "tertiary_link", 0 },
-    { 4, "tertiary",      0 },
-    { 6, "secondary_link",1 },
-    { 6, "secondary",     1 },
-    { 7, "primary_link",  1 },
-    { 7, "primary",       1 },
-    { 8, "trunk_link",    1 },
-    { 8, "trunk",         1 },
-    { 9, "motorway_link", 1 },
-    { 9, "motorway",      1 }
-};
-static const unsigned int nLayers = (sizeof(layers)/sizeof(*layers));
+struct taginfo *exportList[4]; /* Indexed by enum table_id */
+int exportListCount[4];
 
 static int pgsql_delete_way_from_output(osmid_t osm_id);
 static int pgsql_delete_relation_from_output(osmid_t osm_id);
@@ -184,13 +148,6 @@ void read_style_file( const char *filename )
       if( i == NUM_FLAGS )
         fprintf( stderr, "Unknown flag '%s' line %d, ignored\n", str, lineno );
     }
-    if (temp.flags==FLAG_PHSTORE) {
-        if (HSTORE_NONE==(Options->enable_hstore)) {
-            fprintf( stderr, "Error reading style file line %d (fields=%d)\n", lineno, fields );
-            fprintf( stderr, "flag 'phstore' is invalid in non-hstore mode\n");
-            exit_nicely();
-        }
-    }
     if ((temp.flags!=FLAG_DELETE) && ((strchr(temp.name,'?') != NULL) || (strchr(temp.name,'*') != NULL))) {
         fprintf( stderr, "wildcard '%s' in non-delete style entry\n",temp.name);
         exit_nicely();
@@ -314,109 +271,6 @@ void copy_to_table(enum table_id table, const char *sql)
     tables[table].buflen = buflen;
 }
 
-static int add_z_order(struct keyval *tags, int *roads)
-{
-    const char *layer   = getItem(tags, "layer");
-    const char *highway = getItem(tags, "highway");
-    const char *bridge  = getItem(tags, "bridge");
-    const char *tunnel  = getItem(tags, "tunnel");
-    const char *railway = getItem(tags, "railway");
-    const char *boundary= getItem(tags, "boundary");
-
-    int z_order = 0;
-    int l;
-    unsigned int i;
-    char z[13];
-
-    l = layer ? strtol(layer, NULL, 10) : 0;
-    z_order = 10 * l;
-    *roads = 0;
-
-    if (highway) {
-        for (i=0; i<nLayers; i++) {
-            if (!strcmp(layers[i].highway, highway)) {
-                z_order += layers[i].offset;
-                *roads   = layers[i].roads;
-                break;
-            }
-        }
-    }
-
-    if (railway && strlen(railway)) {
-        z_order += 5;
-        *roads = 1;
-    }
-    /* Administrative boundaries are rendered at low zooms so we prefer to use the roads table */
-    if (boundary && !strcmp(boundary, "administrative"))
-        *roads = 1;
-
-    if (bridge && (!strcmp(bridge, "true") || !strcmp(bridge, "yes") || !strcmp(bridge, "1")))
-        z_order += 10;
-
-    if (tunnel && (!strcmp(tunnel, "true") || !strcmp(tunnel, "yes") || !strcmp(tunnel, "1")))
-        z_order -= 10;
-
-    snprintf(z, sizeof(z), "%d", z_order);
-    addItem(tags, "z_order", z, 0);
-
-    return 0;
-}
-
-#if 0
-static void fix_motorway_shields(struct keyval *tags)
-{
-    const char *highway = getItem(tags, "highway");
-    const char *name    = getItem(tags, "name");
-    const char *ref     = getItem(tags, "ref");
-
-    /* The current mapnik style uses ref= for motorway shields but some roads just have name= */
-    if (!highway || strcmp(highway, "motorway"))
-        return;
-
-    if (name && !ref)
-        addItem(tags, "ref", name, 0);
-}
-#endif
-
-/* Append all alternate name:xx on to the name tag with space sepatators.
- * name= always comes first, the alternates are in no particular order
- * Note: A new line may be better but this does not work with Mapnik
- *
- *    <tag k="name" v="Ben Nevis" />
- *    <tag k="name:gd" v="Ben Nibheis" />
- * becomes:
- *    <tag k="name" v="Ben Nevis Ben Nibheis" />
- */
-void compress_tag_name(struct keyval *tags)
-{
-    const char *name = getItem(tags, "name");
-    struct keyval *name_ext = getMatches(tags, "name:");
-    struct keyval *p;
-    char out[2048];
-
-    if (!name_ext)
-        return;
-
-    out[0] = '\0';
-    if (name) {
-        strncat(out, name, sizeof(out)-1);
-        strncat(out, " ", sizeof(out)-1);
-    }
-    while((p = popItem(name_ext)) != NULL) {
-        /* Exclude name:source = "dicataphone" and duplicates */
-        if (strcmp(p->key, "name:source") && !strstr(out, p->value)) {
-            strncat(out, p->value, sizeof(out)-1);
-            strncat(out, " ", sizeof(out)-1);
-        }
-        freeItem(p);
-    }
-    free(name_ext);
-
-    /* Remove trailing space */
-    out[strlen(out)-1] = '\0';
-    /* fprintf(stderr, "*** New name: %s\n", out); */
-    updateItem(tags, "name", out);
-}
 
 
 
@@ -652,11 +506,14 @@ Workaround - output SRID=4326;<WKB>
 static int pgsql_out_node(osmid_t id, struct keyval *tags, double node_lat, double node_lon)
 {
 
+    int filter = tagtransform_filter_node_tags(tags);
     static char *sql;
     static size_t sqllen=0;
     int i;
     struct keyval *tag;
 
+    if (filter) return 1;
+
     if (sqllen==0) {
       sqllen=2048;
       sql=malloc(sqllen);
@@ -756,7 +613,7 @@ static void write_wkts(osmid_t id, struct keyval *tags, const char *wkt, enum ta
     copy_to_table(table, "\n");
 }
 
-static int tag_indicates_polygon(enum OsmType type, const char *key)
+/*static int tag_indicates_polygon(enum OsmType type, const char *key)
 {
     int i;
 
@@ -769,127 +626,9 @@ static int tag_indicates_polygon(enum OsmType type, const char *key)
     }
 
     return 0;
-}
-
-/* Go through the given tags and determine the union of flags. Also remove
- * any tags from the list that we don't know about */
-unsigned int pgsql_filter_tags(enum OsmType type, struct keyval *tags, int *polygon)
-{
-    int i, filter = 1;
-    int flags = 0;
-    int add_area_tag = 0;
+}*/
 
-    const char *area;
-    struct keyval *item;
-    struct keyval temp;
-    initList(&temp);
 
-    /* We used to only go far enough to determine if it's a polygon or not, but now we go through and filter stuff we don't need */
-    while( (item = popItem(tags)) != NULL )
-    {
-        /* Allow named islands to appear as polygons */
-        if (!strcmp("natural",item->key) && !strcmp("coastline",item->value))
-        {               
-            add_area_tag = 1; 
-        }
-
-        /* Discard natural=coastline tags (we render these from a shapefile instead) */
-        if (!Options->keep_coastlines && !strcmp("natural",item->key) && !strcmp("coastline",item->value))
-        {               
-            freeItem( item );
-            item = NULL;
-            continue;
-        }
-
-        for (i=0; i < exportListCount[type]; i++)
-        {
-            if (wildMatch( exportList[type][i].name, item->key ))
-            {
-                if( exportList[type][i].flags & FLAG_DELETE )
-                {
-                    freeItem( item );
-                    item = NULL;
-                    break;
-                }
-
-                filter = 0;
-                flags |= exportList[type][i].flags;
-
-                pushItem( &temp, item );
-                item = NULL;
-                break;
-            }
-        }
-
-        /** if tag not found in list of exports: */
-        if (i == exportListCount[type])
-        {
-            if (Options->enable_hstore) {
-                /* with hstore, copy all tags... */
-                pushItem(&temp, item);
-                /* ... but if hstore_match_only is set then don't take this 
-                   as a reason for keeping the object */
-                if (
-                    !Options->hstore_match_only
-                    && strcmp("osm_uid",item->key)
-                    && strcmp("osm_user",item->key)
-                    && strcmp("osm_timestamp",item->key)
-                    && strcmp("osm_version",item->key)
-                    && strcmp("osm_changeset",item->key)
-                   ) filter = 0;
-            } else if (Options->n_hstore_columns) {
-                /* does this column match any of the hstore column prefixes? */
-                int j;
-                for (j = 0; j < Options->n_hstore_columns; j++) {
-                    char *pos = strstr(item->key, Options->hstore_columns[j]);
-                    if (pos == item->key) {
-                        pushItem(&temp, item);
-                        /* ... but if hstore_match_only is set then don't take this 
-                           as a reason for keeping the object */
-                        if (
-                            !Options->hstore_match_only
-                            && strcmp("osm_uid",item->key)
-                            && strcmp("osm_user",item->key)
-                            && strcmp("osm_timestamp",item->key)
-                            && strcmp("osm_version",item->key)
-                            && strcmp("osm_changeset",item->key)
-                          ) filter = 0;
-                        break; 
-                    }
-                }
-                /* if not, skip the tag */
-                if (j == Options->n_hstore_columns) {
-                    freeItem(item);
-                }
-            } else {
-                freeItem(item);
-            }
-            item = NULL;
-        }
-    }
-
-    /* Move from temp list back to original list */
-    while( (item = popItem(&temp)) != NULL )
-        pushItem( tags, item );
-
-    *polygon = flags & FLAG_POLYGON;
-
-    /* Special case allowing area= to override anything else */
-    if ((area = getItem(tags, "area"))) {
-        if (!strcmp(area, "yes") || !strcmp(area, "true") ||!strcmp(area, "1"))
-            *polygon = 1;
-        else if (!strcmp(area, "no") || !strcmp(area, "false") || !strcmp(area, "0"))
-            *polygon = 0;
-    } else {
-        /* If we need to force this as a polygon, append an area tag */
-        if (add_area_tag) {
-            addItem(tags, "area", "yes", 0);
-            *polygon = 1;
-        }
-    }
-
-    return filter;
-}
 
 /*
 COPY planet_osm (osm_id, name, place, landuse, leisure, "natural", man_made, waterway, highway, railway, amenity, tourism, learning, bu
@@ -912,9 +651,8 @@ static int pgsql_out_way(osmid_t id, struct keyval *tags, struct osmNode *nodes,
         Options->mid->way_changed(id);
     }
 
-    if (pgsql_filter_tags(OSMTYPE_WAY, tags, &polygon) || add_z_order(tags, &roads))
+    if (tagtransform_filter_way_tags(tags, &polygon, &roads))
         return 0;
-
     /* Split long ways after around 1 degree or 100km */
     if (Options->projection == PROJ_LATLONG)
         split_at = 1;
@@ -952,194 +690,27 @@ static int pgsql_out_way(osmid_t id, struct keyval *tags, struct osmNode *nodes,
     return 0;
 }
 
-static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNode **xnodes, struct keyval *xtags, int *xcount, osmid_t *xid, const char **xrole)
+static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, int member_count, struct osmNode **xnodes, struct keyval *xtags, int *xcount, osmid_t *xid, const char **xrole)
 {
     int i, wkt_size;
-    int polygon = 0, roads = 0;
+    int roads = 0;
     int make_polygon = 0;
     int make_boundary = 0;
-    struct keyval tags, *p, poly_tags;
-    char *type;
+    int * members_superseeded;
     double split_at;
 
-#if 0
-    fprintf(stderr, "Got relation with counts:");
-    for (i=0; xcount[i]; i++)
-        fprintf(stderr, " %d", xcount[i]);
-    fprintf(stderr, "\n");
-#endif
-    /* Get the type, if there's no type we don't care */
-    type = getItem(rel_tags, "type");
-    if( !type )
-        return 0;
-
-    initList(&tags);
-    initList(&poly_tags);
-
-    /* Clone tags from relation */
-    p = rel_tags->next;
-    while (p != rel_tags) {
-        /* For routes, we convert name to route_name */
-        if ((strcmp(type, "route") == 0) && (strcmp(p->key, "name") ==0))
-            addItem(&tags, "route_name", p->value, 1);
-        else if (strcmp(p->key, "type")) /* drop type= */
-            addItem(&tags, p->key, p->value, 1);
-        p = p->next;
-    }
-
-    if( strcmp(type, "route") == 0 )
-    {
-        const char *state = getItem(rel_tags, "state");
-        const char *netw = getItem(rel_tags, "network");
-        int networknr = -1;
-
-        if (state == NULL) {
-            state = "";
-        }
-
-        if (netw != NULL) {
-            if (strcmp(netw, "lcn") == 0) {
-                networknr = 10;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "lcn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "lcn", "connection", 1);
-                } else {
-                    addItem(&tags, "lcn", "yes", 1);
-                }
-            } else if (strcmp(netw, "rcn") == 0) {
-                networknr = 11;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "rcn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "rcn", "connection", 1);
-                } else {
-                    addItem(&tags, "rcn", "yes", 1);
-                }
-            } else if (strcmp(netw, "ncn") == 0) {
-                networknr = 12;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "ncn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "ncn", "connection", 1);
-                } else {
-                    addItem(&tags, "ncn", "yes", 1);
-                }
-
-
-            } else if (strcmp(netw, "lwn") == 0) {
-                networknr = 20;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "lwn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "lwn", "connection", 1);
-                } else {
-                    addItem(&tags, "lwn", "yes", 1);
-                }
-            } else if (strcmp(netw, "rwn") == 0) {
-                networknr = 21;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "rwn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "rwn", "connection", 1);
-                } else {
-                    addItem(&tags, "rwn", "yes", 1);
-                }
-            } else if (strcmp(netw, "nwn") == 0) {
-                networknr = 22;
-                if (strcmp(state, "alternate") == 0) {
-                    addItem(&tags, "nwn", "alternate", 1);
-                } else if (strcmp(state, "connection") == 0) {
-                    addItem(&tags, "nwn", "connection", 1);
-                } else {
-                    addItem(&tags, "nwn", "yes", 1);
-                }
-            }
-        }
-
-        if (getItem(rel_tags, "preferred_color") != NULL) {
-            const char *a = getItem(rel_tags, "preferred_color");
-            if (strcmp(a, "0") == 0 || strcmp(a, "1") == 0 || strcmp(a, "2") == 0 || strcmp(a, "3") == 0 || strcmp(a, "4") == 0) {
-                addItem(&tags, "route_pref_color", a, 1);
-            } else {
-                addItem(&tags, "route_pref_color", "0", 1);
-            }
-        } else {
-            addItem(&tags, "route_pref_color", "0", 1);
-        }
-
-        if (getItem(rel_tags, "ref") != NULL) {
-            if (networknr == 10) {
-                addItem(&tags, "lcn_ref", getItem(rel_tags, "ref"), 1);
-            } else if (networknr == 11) {
-                addItem(&tags, "rcn_ref", getItem(rel_tags, "ref"), 1);
-            } else if (networknr == 12) {
-                addItem(&tags, "ncn_ref", getItem(rel_tags, "ref"), 1);
-            } else if (networknr == 20) {
-                addItem(&tags, "lwn_ref", getItem(rel_tags, "ref"), 1);
-            } else if (networknr == 21) {
-                addItem(&tags, "rwn_ref", getItem(rel_tags, "ref"), 1);
-            } else if (networknr == 22) {
-                addItem(&tags, "nwn_ref", getItem(rel_tags, "ref"), 1);
-            }
-        }
-    }
-    else if( strcmp( type, "boundary" ) == 0 )
-    {
-        /* Boundaries will get converted into multiple geometries:
-           - Linear features will end up in the line and roads tables (useful for admin boundaries)
-           - Polygon features also go into the polygon table (useful for national_forests)
-           The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
-        make_boundary = 1;
-    }
-    else if( strcmp( type, "multipolygon" ) == 0 && getItem(&tags, "boundary") )
-    {
-        /* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
-        make_boundary = 1;
-    }
-    else if( strcmp( type, "multipolygon" ) == 0 )
-    {
-        make_polygon = 1;
-
-        /* Copy the tags from the outer way(s) if the relation is untagged */
-        /* or if there is just a name tag, people seem to like naming relations */
-        if (!listHasData(&tags) || ((countList(&tags)==1) && getItem(&tags, "name"))) {
-            for (i=0; xcount[i]; i++) {
-                if (xrole[i] && !strcmp(xrole[i], "inner"))
-                    continue;
-
-                p = xtags[i].next;
-                while (p != &(xtags[i])) {
-                    addItem(&tags, p->key, p->value, 1);
-                    p = p->next;
-                }
-            }
-        }
+    members_superseeded = calloc(sizeof(int), member_count);
 
-        /* Collect a list of polygon-like tags, these are used later to
-           identify if an inner rings looks like it should be rendered seperately */
-        p = tags.next;
-        while (p != &tags) {
-            if (tag_indicates_polygon(OSMTYPE_WAY, p->key)) {
-                addItem(&poly_tags, p->key, p->value, 1);
-            }
-            p = p->next;
-        }
-    }
-    else
-    {
-        /* Unknown type, just exit */
-        resetList(&tags);
-        resetList(&poly_tags);
+    if (member_count == 0) {
+        free(members_superseeded);
         return 0;
     }
 
-    if (pgsql_filter_tags(OSMTYPE_WAY, &tags, &polygon) || add_z_order(&tags, &roads)) {
-        resetList(&tags);
-        resetList(&poly_tags);
+    if (tagtransform_filter_rel_member_tags(rel_tags, member_count, xtags, xrole, members_superseeded, &make_boundary, &make_polygon, &roads)) {
+        free(members_superseeded);
         return 0;
     }
-
+    
     /* Split long linear ways after around 1 degree or 100km (polygons not effected) */
     if (Options->projection == PROJ_LATLONG)
         split_at = 1;
@@ -1149,13 +720,11 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNod
     wkt_size = build_geometry(id, xnodes, xcount, make_polygon, Options->enable_multi, split_at);
 
     if (!wkt_size) {
-        resetList(&tags);
-        resetList(&poly_tags);
+        free(members_superseeded);
         return 0;
     }
 
-    for (i=0;i<wkt_size;i++)
-    {
+    for (i=0;i<wkt_size;i++) {
         char *wkt = get_wkt(i);
 
         if (wkt && strlen(wkt)) {
@@ -1166,13 +735,13 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNod
                 if ((area > 0.0) && enable_way_area) {
                     char tmp[32];
                     snprintf(tmp, sizeof(tmp), "%g", area);
-                    addItem(&tags, "way_area", tmp, 0);
+                    addItem(rel_tags, "way_area", tmp, 0);
                 }
-                write_wkts(-id, &tags, wkt, t_poly);
+                write_wkts(-id, rel_tags, wkt, t_poly);
             } else {
-                write_wkts(-id, &tags, wkt, t_line);
+                write_wkts(-id, rel_tags, wkt, t_line);
                 if (roads)
-                    write_wkts(-id, &tags, wkt, t_roads);
+                    write_wkts(-id, rel_tags, wkt, t_roads);
             }
         }
         free(wkt);
@@ -1180,29 +749,21 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNod
 
     clear_wkts();
 
-    /* If we are creating a multipolygon then we
-       mark each member so that we can skip them during iterate_ways
-       but only if the polygon-tags look the same as the outer ring */
+    /* Tagtransform will have marked those member ways of the relation that
+     * have fully been dealt with as part of the multi-polygon entry.
+     * Set them in the database as done and delete their entry to not
+     * have duplicates */
     if (make_polygon) {
         for (i=0; xcount[i]; i++) {
-            int match = 0;
-            struct keyval *p = poly_tags.next;
-            while (p != &poly_tags) {
-                const char *v = getItem(&xtags[i], p->key);
-                if (!v || strcmp(v, p->value)) {
-                    match = 0;
-                    break;
-                }
-                match = 1;
-                p = p->next;
-            }
-            if (match) {
+            if (members_superseeded[i]) {
                 Options->mid->ways_done(xid[i]);
                 pgsql_delete_way_from_output(xid[i]);
             }
         }
     }
 
+    free(members_superseeded);
+
     /* If we are making a boundary then also try adding any relations which form complete rings
        The linear variants will have already been processed above */
     if (make_boundary) {
@@ -1219,9 +780,9 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNod
                     if ((area > 0.0) && enable_way_area) {
                         char tmp[32];
                         snprintf(tmp, sizeof(tmp), "%g", area);
-                        addItem(&tags, "way_area", tmp, 0);
+                        addItem(rel_tags, "way_area", tmp, 0);
                     }
-                    write_wkts(-id, &tags, wkt, t_poly);
+                    write_wkts(-id, rel_tags, wkt, t_poly);
                 }
             }
             free(wkt);
@@ -1229,8 +790,6 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, struct osmNod
         clear_wkts();
     }
 
-    resetList(&tags);
-    resetList(&poly_tags);
     return 0;
 }
 
@@ -1431,6 +990,10 @@ static int pgsql_out_start(const struct output_options *options)
     }
     free(sql);
 
+    if (tagtransform_init(options)) {
+        fprintf(stderr, "Error: Failed to initialise tag processing.\n");
+        exit_nicely();
+    }
     expire_tiles_init(options);
 
     options->mid->start(options);
@@ -1517,9 +1080,18 @@ static void *pgsql_out_stop_one(void *arg)
         fprintf(stderr, "Copying %s to cluster by geometry finished\n", table->name);
         fprintf(stderr, "Creating geometry index on  %s\n", table->name);
         if (Options->tblsmain_index) {
-            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+            /* Use fillfactor 100 for un-updatable imports */
+            if (Options->slim && !Options->droptemp) {
+                pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+            } else {
+                pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) WITH (FILLFACTOR=100) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+            }
         } else {
-            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way);\n", table->name, table->name);
+            if (Options->slim && !Options->droptemp) {
+                pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way);\n", table->name, table->name);
+            } else {
+                pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) WITH (FILLFACTOR=100);\n", table->name, table->name);
+            }
         }
 
         /* slim mode needs this to be able to apply diffs */
@@ -1536,17 +1108,36 @@ static void *pgsql_out_stop_one(void *arg)
         if (Options->enable_hstore_index) {
             fprintf(stderr, "Creating hstore indexes on  %s\n", table->name);
             if (Options->tblsmain_index) {
-                if (HSTORE_NONE != (Options->enable_hstore))
-                    pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+                if (HSTORE_NONE != (Options->enable_hstore)) {
+                    if (Options->slim && !Options->droptemp) {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+                    } else {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags) WITH (FILLFACTOR=100) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
+                    }
+                }
                 for(i_column = 0; i_column < Options->n_hstore_columns; i_column++) {
-                    pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\") TABLESPACE %s;\n",
+                    if (Options->slim && !Options->droptemp) {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\") TABLESPACE %s;\n",
                                table->name, i_column,table->name, Options->hstore_columns[i_column], Options->tblsmain_index);
+                    } else {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\") WITH (FILLFACTOR=100) TABLESPACE %s;\n",
+                               table->name, i_column,table->name, Options->hstore_columns[i_column], Options->tblsmain_index);
+                    }
                 }
             } else {
-                if (HSTORE_NONE != (Options->enable_hstore))
-                    pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags);\n", table->name, table->name);
+                if (HSTORE_NONE != (Options->enable_hstore)) {
+                    if (Options->slim && !Options->droptemp) {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags);\n", table->name, table->name);
+                    } else {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_tags_index ON %s USING GIN (tags) WITH (FILLFACTOR=100);\n", table->name, table->name);
+                    }
+                }
                 for(i_column = 0; i_column < Options->n_hstore_columns; i_column++) {
-                    pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\");\n", table->name, i_column,table->name, Options->hstore_columns[i_column]);
+                    if (Options->slim && !Options->droptemp) {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\");\n", table->name, i_column,table->name, Options->hstore_columns[i_column]);
+                    } else {
+                        pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_hstore_%i_index ON %s USING GIN (\"%s\") WITH (FILLFACTOR=100);\n", table->name, i_column,table->name, Options->hstore_columns[i_column]);
+                    }
                 }
             }
         }
@@ -1599,6 +1190,8 @@ static void pgsql_out_stop()
      */    
     Options->mid->iterate_relations( pgsql_process_relation );
 
+    tagtransform_shutdown();
+
 #ifdef HAVE_PTHREAD
     if (Options->parallel_indexing) {
       for (i=0; i<NUM_TABLES; i++) {
@@ -1640,21 +1233,20 @@ static void pgsql_out_stop()
 
 static int pgsql_add_node(osmid_t id, double lat, double lon, struct keyval *tags)
 {
-  int polygon;
-  int filter = pgsql_filter_tags(OSMTYPE_NODE, tags, &polygon);
-  
   Options->mid->nodes_set(id, lat, lon, tags);
-  if( !filter )
-      pgsql_out_node(id, tags, lat, lon);
+  pgsql_out_node(id, tags, lat, lon);
+
   return 0;
 }
 
 static int pgsql_add_way(osmid_t id, osmid_t *nds, int nd_count, struct keyval *tags)
 {
   int polygon = 0;
+  int roads = 0;
+
 
   /* Check whether the way is: (1) Exportable, (2) Maybe a polygon */
-  int filter = pgsql_filter_tags(OSMTYPE_WAY, tags, &polygon);
+  int filter = tagtransform_filter_way_tags(tags, &polygon, &roads);
 
   /* If this isn't a polygon then it can not be part of a multipolygon
      Hence only polygons are "pending" */
@@ -1686,6 +1278,15 @@ static int pgsql_process_relation(osmid_t id, struct member *members, int member
   if(exists)
       pgsql_delete_relation_from_output(id);
 
+  if (tagtransform_filter_rel_tags(tags)) {
+      free(xid2);
+      free(xrole);
+      free(xcount);
+      free(xtags);
+      free(xnodes);
+      return 1;
+  }
+
   count = 0;
   for( i=0; i<member_count; i++ )
   {
@@ -1710,8 +1311,8 @@ static int pgsql_process_relation(osmid_t id, struct member *members, int member
   xid[count2] = 0;
   xrole[count2] = NULL;
 
-  /* At some point we might want to consider storing the retreived data in the members, rather than as seperate arrays */
-  pgsql_out_relation(id, tags, xnodes, xtags, xcount, xid, xrole);
+  /* At some point we might want to consider storing the retrieved data in the members, rather than as separate arrays */
+  pgsql_out_relation(id, tags, count2, xnodes, xtags, xcount, xid, xrole);
 
   for( i=0; i<count2; i++ )
   {
diff --git a/output-pgsql.h b/output-pgsql.h
index e918360..32af34e 100644
--- a/output-pgsql.h
+++ b/output-pgsql.h
@@ -8,6 +8,20 @@
 
 #include "output.h"
 
+#define FLAG_POLYGON 1    /* For polygon table */
+#define FLAG_LINEAR  2    /* For lines table */
+#define FLAG_NOCACHE 4    /* Optimisation: don't bother remembering this one */
+#define FLAG_DELETE  8    /* These tags should be simply deleted on sight */
+#define FLAG_PHSTORE 17   /* polygons without own column but listed in hstore this implies FLAG_POLYGON */
+
+/* Table columns, representing key= tags */
+struct taginfo {
+    char *name;
+    char *type;
+    int flags;
+    int count;
+};
+
 extern struct output_t out_pgsql;
 
 #endif
diff --git a/output.h b/output.h
index 8067957..8bfa7d1 100644
--- a/output.h
+++ b/output.h
@@ -54,6 +54,7 @@ struct output_options {
   int flat_node_cache_enabled;
   int excludepoly;
   const char *flat_node_file;
+  const char *tag_transform_script;
 };
 
 struct output_t {
diff --git a/parse-pbf.c b/parse-pbf.c
index 318e4c2..0d09df0 100644
--- a/parse-pbf.c
+++ b/parse-pbf.c
@@ -55,6 +55,7 @@ static uint32_t get_length(FILE *input)
   return ntohl(*((size_t *)buf));
 }
 
+#if 0
 static void *realloc_or_free(void *p, size_t len)
 {
   void *new = realloc(p, len);
@@ -65,6 +66,7 @@ static void *realloc_or_free(void *p, size_t len)
 
   return new;
 }
+#endif
 
 static BlockHeader *read_header(FILE *input, void *buf)
 {    
@@ -338,15 +340,13 @@ int processOsmDataDenseNodes(struct osmdata_t *osmdata, PrimitiveGroup *group, S
                 addIntItem(&(osmdata->tags), "osm_version", denseinfo->version[node_id], 0);
                 addIntItem(&(osmdata->tags), "osm_changeset", deltachangeset, 0);
                 
-#if 0
-                /* TODO */
                 if (deltauid != -1) { /* osmosis devs failed to read the specs */
-                    printuser(string_table->s[deltauser_sid]);
-                    printnumericattribute("osm_uid", deltauid);
+                    char * valstr;
+                    addIntItem(&(osmdata->tags), "osm_uid", deltauid, 0);
+                    valstr = calloc(string_table->s[deltauser_sid].len + 1, 1);
+                    memcpy(valstr, string_table->s[deltauser_sid].data, string_table->s[deltauser_sid].len);
+                    addItem(&(osmdata->tags), "osm_user", valstr,  0);
                 }
-                
-                printtimestamp("osm_timestamp", deltatimestamp);
-#endif
             }
             
             if (l < dense->n_keys_vals) {
diff --git a/style.lua b/style.lua
new file mode 100644
index 0000000..23616c1
--- /dev/null
+++ b/style.lua
@@ -0,0 +1,178 @@
+polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', 
+      'man_made', 'military', 'natural', 'office', 'place', 'power',
+      'public_transport', 'shop', 'sport', 'tourism', 'waterway',
+      'wetland', 'water', 'aeroway' }
+
+generic_keys = {'access','addr:housename','addr:housenumber','addr:interpolation','admin_level','aerialway','aeroway','amenity','area','barrier',
+   'bicycle','brand','bridge','boundary','building','capital','construction','covered','culvert','cutting','denomination','disused','ele',
+   'embarkment','foot','generation:source','harbour','highway','historic','hours','intermittent','junction','landuse','layer','leisure','lock',
+   'man_made','military','motor_car','name','natural','office','oneway','operator','place','poi','population','power','power_source','public_transport',
+   'railway','ref','religion','route','service','shop','sport','surface','toll','tourism','tower:type', 'tracktype','tunnel','water','waterway',
+   'wetland','width','wood','type'}
+
+function add_z_order(keyvalues)
+   z_order = 0
+   if (keyvalues["layer"] ~= nil ) then
+      z_order = 10*keyvalues["layer"]
+   end
+
+   
+   zordering_tags = {{ 'railway', nil, 5, 1}, { 'boundary', 'administrative', 0, 1}, 
+      { 'bridge', 'yes', 10, 0 }, { 'bridge', 'true', 10, 0 }, { 'bridge', 1, 10, 0 },
+      { 'tunel', 'yes', -10, 0}, { 'tunel', 'true', -10, 0}, { 'tunel', 1, -10, 0}, 
+      { 'highway', 'minor', 3, 0}, { 'highway', 'road', 3, 0 }, { 'highway', 'unclassified', 3, 0 },
+      { 'highway', 'residential', 3, 0 }, { 'highway', 'tertiary_link', 4, 0}, { 'highway', 'tertiary', 4, 0},
+      { 'highway', 'secondary_link', 6, 1}, { 'highway', 'secondary', 6, 1},
+      { 'highway', 'primary_link', 7, 1}, { 'highway', 'primary', 7, 1},
+      { 'highway', 'trunk_link', 8, 1}, { 'highway', 'trunk', 8, 1},
+      { 'highway', 'motorway_link', 9, 1}, { 'highway', 'motorway', 9, 1},
+}
+   
+   for i,k in ipairs(zordering_tags) do
+      if ((k[2]  and keyvalues[k[1]] == k[2]) or (k[2] == nil and keyvalues[k[1]] ~= nil)) then
+         if (k[4] == 1) then
+            roads = 1
+         end
+         z_order = z_order + k[3]
+      end
+   end
+
+   keyvalues["z_order"] = z_order
+
+   return keyvalues, roads
+
+end
+
+function filter_tags_generic(keyvalues, nokeys)
+   filter = 0
+   tagcount = 0
+
+   if nokeys == 0 then
+      filter = 1
+      return filter, keyvalues
+   end
+
+   delete_tags = { 'FIXME', 'note', 'source' }
+
+   for i,k in ipairs(delete_tags) do
+      keyvalues[k] = nil
+   end
+   
+   for k,v in pairs(keyvalues) do
+      for i, k2 in ipairs(generic_keys) do if k2 == k then tagcount = tagcount + 1; end end
+   end
+   if tagcount == 0 then
+      filter = 1
+   end
+
+   return filter, keyvalues
+end
+
+function filter_tags_node (keyvalues, nokeys)
+   return filter_tags_generic(keyvalues, nokeys)
+end
+
+function filter_basic_tags_rel (keyvalues, nokeys)
+
+   filter, keyvalues = filter_tags_generic(keyvalues, nokeys)
+   if filter == 1 then
+      return filter, keyvalues
+   end
+
+   if ((keyvalues["type"] ~= "route") and (keyvalues["type"] ~= "multipolygon") and (keyvalues["type"] ~= "boundary")) then
+      filter = 1
+      return filter, keyvalues
+   end
+
+   return filter, keyvalues
+end
+
+function filter_tags_way (keyvalues, nokeys)
+   filter = 0
+   poly = 0
+   tagcount = 0
+   roads = 0
+
+   filter, keyvalues = filter_tags_generic(keyvalues, nokeys)
+   if filter == 1 then
+      return filter, keyvalues, poly, roads
+   end
+
+
+   for i,k in ipairs(polygon_keys) do
+      if keyvalues[k] then
+         poly=1
+         break
+      end
+   end
+   
+
+   if ((keyvalues["area"] == "yes") or (keyvalues["area"] == "1") or (keyvalues["area"] == "true")) then
+      poly = 1;
+   elseif ((keyvalues["area"] == "no") or (keyvalues["area"] == "0") or (keyvalues["area"] == "false")) then
+      poly = 0;
+   end
+
+   keyvalues, roads = add_z_order(keyvalues)
+
+
+   return filter, keyvalues, poly, roads
+end
+
+function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, membercount)
+   
+   filter = 0
+   boundary = 0
+   polygon = 0
+   roads = 0
+   membersuperseeded = {}
+   for i = 1, membercount do
+      membersuperseeded[i] = 0
+   end
+
+   type = keyvalues["type"]
+   keyvalues["type"] = nil
+  
+
+   if (type == "boundary") then
+      boundary = 1
+   end
+   if ((type == "multipolygon") and keyvalues["boundary"]) then
+      boundary = 1
+   elseif (type == "multipolygon") then
+      polygon = 1
+      polytagcount = 0;
+      for i,k in ipairs(polygon_keys) do
+         if keyvalues[k] then
+            polytagcount = polytagcount + 1
+         end
+      end
+      if (polytagcount == 0) then
+         for i = 1,membercount do
+            if (roles[i] == "outer") then
+               for k,v in pairs(keyvaluemembers[i]) do
+                  keyvalues[k] = v
+               end
+            end
+         end
+      end
+      for i = 1,membercount do
+         superseeded = 1
+         for k,v in pairs(keyvaluemembers[i]) do
+            if ((keyvalues[k] == nil) or (keyvalues[k] ~= v)) then
+               for j,k2 in ipairs(generic_keys) do
+                  if (k == k2) then
+                     superseeded = 0;
+                     break
+                  end
+               end
+            end
+         end
+         membersuperseeded[i] = superseeded
+      end
+   end
+
+   keyvalues, roads = add_z_order(keyvalues)
+
+   return filter, keyvalues, membersuperseeded, boundary, polygon, roads
+end
diff --git a/tagtransform.c b/tagtransform.c
new file mode 100644
index 0000000..2814815
--- /dev/null
+++ b/tagtransform.c
@@ -0,0 +1,756 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "osmtypes.h"
+#include "keyvals.h"
+#include "tagtransform.h"
+#include "output-pgsql.h"
+#include "config.h"
+#include "wildcmp.h"
+
+#ifdef HAVE_LUA
+static lua_State *L;
+#endif
+
+static struct {
+    int offset;
+    const char *highway;
+    int roads;
+} layers[] = {
+    { 3, "minor",         0 },
+    { 3, "road",          0 },
+    { 3, "unclassified",  0 },
+    { 3, "residential",   0 },
+    { 4, "tertiary_link", 0 },
+    { 4, "tertiary",      0 },
+    { 6, "secondary_link",1 },
+    { 6, "secondary",     1 },
+    { 7, "primary_link",  1 },
+    { 7, "primary",       1 },
+    { 8, "trunk_link",    1 },
+    { 8, "trunk",         1 },
+    { 9, "motorway_link", 1 },
+    { 9, "motorway",      1 }
+};
+
+static const unsigned int nLayers = (sizeof(layers)/sizeof(*layers));
+
+const struct output_options *options;
+
+extern struct taginfo *exportList[4]; /* Indexed by enum table_id */
+extern int exportListCount[4];
+
+int transform_method = 0;
+
+static int add_z_order(struct keyval *tags, int *roads) {
+    const char *layer = getItem(tags, "layer");
+    const char *highway = getItem(tags, "highway");
+    const char *bridge = getItem(tags, "bridge");
+    const char *tunnel = getItem(tags, "tunnel");
+    const char *railway = getItem(tags, "railway");
+    const char *boundary = getItem(tags, "boundary");
+
+    int z_order = 0;
+    int l;
+    unsigned int i;
+    char z[13];
+
+    l = layer ? strtol(layer, NULL, 10) : 0;
+    z_order = 10 * l;
+    *roads = 0;
+
+    if (highway) {
+        for (i = 0; i < nLayers; i++) {
+            if (!strcmp(layers[i].highway, highway)) {
+                z_order += layers[i].offset;
+                *roads = layers[i].roads;
+                break;
+            }
+        }
+    }
+
+    if (railway && strlen(railway)) {
+        z_order += 5;
+        *roads = 1;
+    }
+    /* Administrative boundaries are rendered at low zooms so we prefer to use the roads table */
+    if (boundary && !strcmp(boundary, "administrative"))
+        *roads = 1;
+
+    if (bridge
+            && (!strcmp(bridge, "true") || !strcmp(bridge, "yes")
+                    || !strcmp(bridge, "1")))
+        z_order += 10;
+
+    if (tunnel
+            && (!strcmp(tunnel, "true") || !strcmp(tunnel, "yes")
+                    || !strcmp(tunnel, "1")))
+        z_order -= 10;
+
+    snprintf(z, sizeof(z), "%d", z_order);
+    addItem(tags, "z_order", z, 0);
+
+    return 0;
+}
+
+static unsigned int tagtransform_lua_filter_basic_tags(enum OsmType type, struct keyval *tags, int * polygon, int * roads) {
+#ifdef HAVE_LUA
+    int idx = 0;
+    int filter;
+    int count = 0;
+    struct keyval *item;
+    const char * key, * value;
+
+    *polygon = 0; *roads = 0;
+
+    switch (type) {
+    case OSMTYPE_NODE: {
+        lua_getglobal(L, "filter_tags_node");
+        break;
+    }
+    case OSMTYPE_WAY: {
+        lua_getglobal(L, "filter_tags_way");
+        break;
+    }
+    case OSMTYPE_RELATION: {
+        lua_getglobal(L, "filter_basic_tags_rel");
+        break;
+    }
+    }
+
+    lua_newtable(L);    /* key value table */
+
+    idx = 1;
+    while( (item = popItem(tags)) != NULL ) {
+        lua_pushstring(L, item->key);
+        lua_pushstring(L, item->value);
+        lua_rawset(L, -3);
+        freeItem(item);
+        count++;
+    }
+
+    //printf("C count %i\n", count);
+    lua_pushinteger(L, count);
+
+    if (lua_pcall(L,2,type == OSMTYPE_WAY ? 4 : 2,0)) {
+        fprintf(stderr, "Failed to execute lua function for basic tag processing: %s\n", lua_tostring(L, -1));
+        /* lua function failed */
+        return 1;
+    }
+
+    if (type == OSMTYPE_WAY) {
+        *roads = lua_tointeger(L, -1);
+        lua_pop(L,1);
+        *polygon = lua_tointeger(L, -1);
+        lua_pop(L,1);
+    }
+
+    lua_pushnil(L);
+    while (lua_next(L,-2) != 0) {
+        key = lua_tostring(L,-2);
+        value = lua_tostring(L,-1);
+        addItem(tags, key, value, 0);
+        lua_pop(L,1);
+    }
+
+    filter = lua_tointeger(L, -2);
+
+    lua_pop(L,2);
+
+    return filter;
+#else
+    return 1;
+#endif
+}
+
+
+/* Go through the given tags and determine the union of flags. Also remove
+ * any tags from the list that we don't know about */
+static unsigned int tagtransform_c_filter_basic_tags(enum OsmType type,
+        struct keyval *tags, int *polygon, int * roads) {
+    int i, filter = 1;
+    int flags = 0;
+    int add_area_tag = 0;
+    enum OsmType export_type;
+
+    const char *area;
+    struct keyval *item;
+    struct keyval temp;
+    initList(&temp);
+
+    if (type == OSMTYPE_RELATION) {export_type = OSMTYPE_WAY;} else {export_type = type;}
+
+    /* We used to only go far enough to determine if it's a polygon or not, but now we go through and filter stuff we don't need */
+    while ((item = popItem(tags)) != NULL ) {
+        if (type == OSMTYPE_RELATION && !strcmp("type", item->key)) {
+            pushItem(&temp, item);
+            item = NULL;
+            filter = 0;
+            continue;
+        }
+        /* Allow named islands to appear as polygons */
+        if (!strcmp("natural", item->key)
+                && !strcmp("coastline", item->value)) {
+            add_area_tag = 1;
+        }
+
+        /* Discard natural=coastline tags (we render these from a shapefile instead) */
+        if (!options->keep_coastlines && !strcmp("natural", item->key)
+                && !strcmp("coastline", item->value)) {
+            freeItem(item);
+            item = NULL;
+            continue;
+        }
+
+        for (i = 0; i < exportListCount[export_type]; i++) {
+            if (wildMatch(exportList[export_type][i].name, item->key)) {
+                if (exportList[export_type][i].flags & FLAG_DELETE) {
+                    freeItem(item);
+                    item = NULL;
+                    break;
+                }
+
+                filter = 0;
+                flags |= exportList[export_type][i].flags;
+
+                pushItem(&temp, item);
+                item = NULL;
+                break;
+            }
+        }
+
+        /** if tag not found in list of exports: */
+        if (i == exportListCount[export_type]) {
+            if (options->enable_hstore) {
+                /* with hstore, copy all tags... */
+                pushItem(&temp, item);
+                /* ... but if hstore_match_only is set then don't take this 
+                 as a reason for keeping the object */
+                if (!options->hstore_match_only && strcmp("osm_uid", item->key)
+                        && strcmp("osm_user", item->key)
+                        && strcmp("osm_timestamp", item->key)
+                        && strcmp("osm_version", item->key)
+                        && strcmp("osm_changeset", item->key))
+                    filter = 0;
+            } else if (options->n_hstore_columns) {
+                /* does this column match any of the hstore column prefixes? */
+                int j;
+                for (j = 0; j < options->n_hstore_columns; j++) {
+                    char *pos = strstr(item->key, options->hstore_columns[j]);
+                    if (pos == item->key) {
+                        pushItem(&temp, item);
+                        /* ... but if hstore_match_only is set then don't take this 
+                         as a reason for keeping the object */
+                        if (!options->hstore_match_only
+                                && strcmp("osm_uid", item->key)
+                                && strcmp("osm_user", item->key)
+                                && strcmp("osm_timestamp", item->key)
+                                && strcmp("osm_version", item->key)
+                                && strcmp("osm_changeset", item->key))
+                            filter = 0;
+                        break;
+                    }
+                }
+                /* if not, skip the tag */
+                if (j == options->n_hstore_columns) {
+                    freeItem(item);
+                }
+            } else {
+                freeItem(item);
+            }
+            item = NULL;
+        }
+    }
+
+    /* Move from temp list back to original list */
+    while ((item = popItem(&temp)) != NULL )
+        pushItem(tags, item);
+
+    *polygon = flags & FLAG_POLYGON;
+
+    /* Special case allowing area= to override anything else */
+    if ((area = getItem(tags, "area"))) {
+        if (!strcmp(area, "yes") || !strcmp(area, "true") || !strcmp(area, "1"))
+            *polygon = 1;
+        else if (!strcmp(area, "no") || !strcmp(area, "false")
+                || !strcmp(area, "0"))
+            *polygon = 0;
+    } else {
+        /* If we need to force this as a polygon, append an area tag */
+        if (add_area_tag) {
+            addItem(tags, "area", "yes", 0);
+            *polygon = 1;
+        }
+    }
+
+    if (!filter && (type == OSMTYPE_WAY)) {
+        add_z_order(tags,roads);
+    }
+
+    return filter;
+}
+
+
+static unsigned int tagtransform_lua_filter_rel_member_tags(struct keyval *rel_tags, int member_count,
+        struct keyval *member_tags,const char **member_role,
+        int * member_superseeded, int * make_boundary, int * make_polygon, int * roads) {
+#ifdef HAVE_LUA
+
+    int i;
+    int idx = 0;
+    int filter;
+    int count = 0;
+    struct keyval *item;
+    const char * key, * value;
+
+    lua_getglobal(L, "filter_tags_relation_member");
+
+    lua_newtable(L);    /* relations key value table */
+
+    idx = 1;
+    while( (item = popItem(rel_tags)) != NULL ) {
+        lua_pushstring(L, item->key);
+        lua_pushstring(L, item->value);
+        lua_rawset(L, -3);
+        freeItem(item);
+        count++;
+    }
+
+    lua_newtable(L);    /* member tags table */
+
+    for (i = 1; i <= member_count; i++) {
+        lua_pushnumber(L, i);
+        lua_newtable(L);    /* member key value table */
+        while( (item = popItem(&(member_tags[i - 1]))) != NULL ) {
+            lua_pushstring(L, item->key);
+            lua_pushstring(L, item->value);
+            lua_rawset(L, -3);
+            freeItem(item);
+            count++;
+        }
+        lua_rawset(L, -3);
+    }
+
+    lua_newtable(L);    /* member roles table */
+
+    for (i = 0; i < member_count; i++) {
+        lua_pushnumber(L, i + 1);
+        lua_pushstring(L, member_role[i]);
+        lua_rawset(L, -3);
+    }
+
+    lua_pushnumber(L, member_count);
+
+    if (lua_pcall(L,4,6,0)) {
+        fprintf(stderr, "Failed to execute lua function for relation tag processing: %s\n", lua_tostring(L, -1));
+        /* lua function failed */
+        return 1;
+    }
+
+    *roads = lua_tointeger(L, -1);
+    lua_pop(L,1);
+    *make_polygon = lua_tointeger(L, -1);
+    lua_pop(L,1);
+    *make_boundary = lua_tointeger(L,-1);
+    lua_pop(L,1);
+
+    lua_pushnil(L);
+    for (i = 0; i < member_count; i++) {
+        if (lua_next(L,-2)) {
+            member_superseeded[i] = lua_tointeger(L,-1);
+            lua_pop(L,1);
+        } else {
+            fprintf(stderr, "Failed to read member_superseeded from lua function\n");
+        }
+    }
+    lua_pop(L,2);
+
+    lua_pushnil(L);
+    while (lua_next(L,-2) != 0) {
+        key = lua_tostring(L,-2);
+        value = lua_tostring(L,-1);
+        addItem(rel_tags, key, value, 0);
+        lua_pop(L,1);
+    }
+    lua_pop(L,1);
+
+    filter = lua_tointeger(L, -1);
+
+    lua_pop(L,1);
+
+    return filter;
+#else
+    return 1;
+#endif
+}
+
+
+static unsigned int tagtransform_c_filter_rel_member_tags(
+        struct keyval *rel_tags, int member_count,
+        struct keyval *member_tags, const char **member_role,
+        int * member_superseeded, int * make_boundary, int * make_polygon, int * roads) {
+    char *type;
+    struct keyval tags, *p, *q, *qq, poly_tags;
+    int i, j;
+    int first_outerway, contains_tag;
+
+    /* Get the type, if there's no type we don't care */
+    type = getItem(rel_tags, "type");
+    if (!type)
+        return 1;
+
+    initList(&tags);
+    initList(&poly_tags);
+
+    /* Clone tags from relation */
+    p = rel_tags->next;
+    while (p != rel_tags) {
+        /* For routes, we convert name to route_name */
+        if ((strcmp(type, "route") == 0) && (strcmp(p->key, "name") == 0))
+            addItem(&tags, "route_name", p->value, 1);
+        else if (strcmp(p->key, "type")) /* drop type= */
+            addItem(&tags, p->key, p->value, 1);
+        p = p->next;
+    }
+
+    if (strcmp(type, "route") == 0) {
+        const char *state = getItem(rel_tags, "state");
+        const char *netw = getItem(rel_tags, "network");
+        int networknr = -1;
+
+        if (state == NULL ) {
+            state = "";
+        }
+
+        if (netw != NULL ) {
+            if (strcmp(netw, "lcn") == 0) {
+                networknr = 10;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "lcn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "lcn", "connection", 1);
+                } else {
+                    addItem(&tags, "lcn", "yes", 1);
+                }
+            } else if (strcmp(netw, "rcn") == 0) {
+                networknr = 11;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "rcn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "rcn", "connection", 1);
+                } else {
+                    addItem(&tags, "rcn", "yes", 1);
+                }
+            } else if (strcmp(netw, "ncn") == 0) {
+                networknr = 12;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "ncn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "ncn", "connection", 1);
+                } else {
+                    addItem(&tags, "ncn", "yes", 1);
+                }
+
+            } else if (strcmp(netw, "lwn") == 0) {
+                networknr = 20;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "lwn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "lwn", "connection", 1);
+                } else {
+                    addItem(&tags, "lwn", "yes", 1);
+                }
+            } else if (strcmp(netw, "rwn") == 0) {
+                networknr = 21;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "rwn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "rwn", "connection", 1);
+                } else {
+                    addItem(&tags, "rwn", "yes", 1);
+                }
+            } else if (strcmp(netw, "nwn") == 0) {
+                networknr = 22;
+                if (strcmp(state, "alternate") == 0) {
+                    addItem(&tags, "nwn", "alternate", 1);
+                } else if (strcmp(state, "connection") == 0) {
+                    addItem(&tags, "nwn", "connection", 1);
+                } else {
+                    addItem(&tags, "nwn", "yes", 1);
+                }
+            }
+        }
+
+        if (getItem(rel_tags, "preferred_color") != NULL ) {
+            const char *a = getItem(rel_tags, "preferred_color");
+            if (strcmp(a, "0") == 0 || strcmp(a, "1") == 0
+                    || strcmp(a, "2") == 0 || strcmp(a, "3") == 0
+                    || strcmp(a, "4") == 0) {
+                addItem(&tags, "route_pref_color", a, 1);
+            } else {
+                addItem(&tags, "route_pref_color", "0", 1);
+            }
+        } else {
+            addItem(&tags, "route_pref_color", "0", 1);
+        }
+
+        if (getItem(rel_tags, "ref") != NULL ) {
+            if (networknr == 10) {
+                addItem(&tags, "lcn_ref", getItem(rel_tags, "ref"), 1);
+            } else if (networknr == 11) {
+                addItem(&tags, "rcn_ref", getItem(rel_tags, "ref"), 1);
+            } else if (networknr == 12) {
+                addItem(&tags, "ncn_ref", getItem(rel_tags, "ref"), 1);
+            } else if (networknr == 20) {
+                addItem(&tags, "lwn_ref", getItem(rel_tags, "ref"), 1);
+            } else if (networknr == 21) {
+                addItem(&tags, "rwn_ref", getItem(rel_tags, "ref"), 1);
+            } else if (networknr == 22) {
+                addItem(&tags, "nwn_ref", getItem(rel_tags, "ref"), 1);
+            }
+        }
+    } else if (strcmp(type, "boundary") == 0) {
+        /* Boundaries will get converted into multiple geometries:
+         - Linear features will end up in the line and roads tables (useful for admin boundaries)
+         - Polygon features also go into the polygon table (useful for national_forests)
+         The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
+        *make_boundary = 1;
+    } else if (strcmp(type, "multipolygon") == 0
+            && getItem(&tags, "boundary")) {
+        /* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
+        *make_boundary = 1;
+    } else if (strcmp(type, "multipolygon") == 0) {
+        *make_polygon = 1;
+
+        /* Collect a list of polygon-like tags, these are used later to
+         identify if an inner rings looks like it should be rendered separately */
+        p = tags.next;
+        while (p != &tags) {
+            if (!strcmp(p->key, "area")) {
+                addItem(&poly_tags, p->key, p->value, 1);
+            } else {
+                for (i = 0; i < exportListCount[OSMTYPE_WAY]; i++) {
+                    if (strcmp(exportList[OSMTYPE_WAY][i].name, p->key) == 0) {
+                        if (exportList[OSMTYPE_WAY][i].flags & FLAG_POLYGON) {
+                            addItem(&poly_tags, p->key, p->value, 1);
+                        }
+                        break;
+                    }
+                }
+            }
+            p = p->next;
+        }
+
+        /* Copy the tags from the outer way(s) if the relation is untagged (with
+         * respect to tags that influence its polygon nature. Tags like name or fixme should be fine*/
+        if (!listHasData(&poly_tags)) {
+            first_outerway = 1;
+            for (i = 0; i < member_count; i++) {
+                if (member_role[i] && !strcmp(member_role[i], "inner"))
+                    continue;
+
+                /* insert all tags of the first outerway to the potential list of copied tags. */
+                if (first_outerway) {
+                    p = member_tags[i].next;
+                    while (p != &(member_tags[i])) {
+                        addItem(&poly_tags, p->key, p->value, 1);                        
+                        p = p->next;
+                    }
+                } else {
+                    /* Check if all of the tags in the list of potential tags are present on this way,
+                       otherwise remove from the list of potential tags. Tags need to be present on
+                       all outer ways to be copied over to the relation */
+                    q = poly_tags.next; 
+                    while (q != &poly_tags) {
+                        p = getTag(&(member_tags[i]), q->key);
+                        if ((p != NULL) && (strcmp(q->value, p->value) == 0)) {
+                            q = q->next;
+                        } else {
+                            /* This tag is not present on all member outer ways, so don't copy it over to relation */
+                            qq = q->next;
+                            removeTag(q);
+                            q = qq;
+                        }
+                    }
+                }
+                first_outerway = 0;
+            }
+            /* Copy the list identified outer way tags over to the relation */
+            q = poly_tags.next; 
+            while (q != &poly_tags) {
+                addItem(&tags, q->key, q->value, 1);                        
+                q = q->next;
+            }
+
+            /* We need to re-check and only keep polygon tags in the list of polytags */
+            q = poly_tags.next; 
+            while (q != &poly_tags) {
+                contains_tag = 0;
+                for (j = 0; j < exportListCount[OSMTYPE_WAY]; j++) {
+                    if (strcmp(exportList[OSMTYPE_WAY][j].name, q->key) == 0) {
+                        if (exportList[OSMTYPE_WAY][j].flags & FLAG_POLYGON) {
+                            contains_tag = 1;
+                            break;
+                        }
+                    }
+                }
+                if (contains_tag == 0) {
+                    qq = q->next;
+                    removeTag(q);
+                    q = qq;
+                } else {
+                    q = q->next;
+                }
+            }
+        }
+        resetList(&poly_tags);
+    } else {
+        /* Unknown type, just exit */
+        resetList(&tags);
+        resetList(&poly_tags);
+        return 1;
+    }
+
+    if (!listHasData(&tags)) {
+        resetList(&tags);
+        resetList(&poly_tags);
+        return 1;
+    }
+
+    /* If we are creating a multipolygon then we
+     mark each member so that we can skip them during iterate_ways
+     but only if the polygon-tags look the same as the outer ring */
+    if (make_polygon) {
+        for (i = 0; i < member_count; i++) {
+            int match = 1;
+            struct keyval *p = member_tags[i].next;
+            while (p != &(member_tags[i])) {
+                const char *v = getItem(&tags, p->key);
+                if (!v || strcmp(v, p->value)) {
+                    /* z_order and osm_ are automatically generated tags, so ignore them */
+                    if ((strcmp(p->key, "z_order") != 0) && (strcmp(p->key, "osm_user") != 0) && 
+                        (strcmp(p->key, "osm_version") != 0) && (strcmp(p->key, "osm_uid") != 0) &&
+                        (strcmp(p->key, "osm_changeset"))) {
+                        match = 0;
+                        break;
+                    }
+                }
+                p = p->next;
+            }
+            if (match) {
+                member_superseeded[i] = 1;
+            } else {
+                member_superseeded[i] = 0;
+            }
+        }
+    }
+
+    resetList(rel_tags);
+    cloneList(rel_tags, &tags);
+    resetList(&tags);
+
+    add_z_order(rel_tags, roads);
+
+    return 0;
+}
+
+static int tagtransform_lua_init() {
+#ifdef HAVE_LUA
+    L = luaL_newstate();
+    luaL_openlibs(L);
+    luaL_dofile(L, options->tag_transform_script);
+
+    lua_getglobal(L, "filter_tags_node");
+    if (!lua_isfunction (L, -1)) {
+        fprintf(stderr,"Tag transform style does not contain a function filter_tags_node\n");
+        return 1;
+    }
+    lua_pop(L,1);
+
+    lua_getglobal(L, "filter_tags_way");
+    if (!lua_isfunction (L, -1)) {
+        fprintf(stderr,"Tag transform style does not contain a function filter_tags_way\n");
+        return 1;
+    }
+    lua_pop(L,1);
+
+    lua_getglobal(L, "filter_basic_tags_rel");
+    if (!lua_isfunction (L, -1)) {
+        fprintf(stderr,"Tag transform style does not contain a function filter_basic_tags_rel\n");
+        return 1;
+    }
+
+    lua_getglobal(L, "filter_tags_relation_member");
+    if (!lua_isfunction (L, -1)) {
+        fprintf(stderr,"Tag transform style does not contain a function filter_tags_relation_member\n");
+        return 1;
+    }
+
+    return 0;
+#else
+    fprintf(stderr,"Error: Could not init lua tag transform, as lua support was not compiled into this version\n");
+    return 1;
+#endif
+}
+
+void tagtransform_lua_shutdown() {
+#ifdef HAVE_LUA
+    lua_close(L);
+#endif
+}
+
+unsigned int tagtransform_filter_node_tags(struct keyval *tags) {
+    int poly, roads;
+    if (transform_method) {
+        return tagtransform_lua_filter_basic_tags(OSMTYPE_NODE, tags, &poly, &roads);
+    } else {
+        return tagtransform_c_filter_basic_tags(OSMTYPE_NODE, tags, &poly, &roads);
+    }
+}
+
+/*
+ * This function gets called twice during initial import per way. Once from add_way and once from out_way
+ */
+unsigned int tagtransform_filter_way_tags(struct keyval *tags, int * polygon, int * roads) {
+    if (transform_method) {
+        return tagtransform_lua_filter_basic_tags(OSMTYPE_WAY, tags, polygon, roads);
+    } else {
+        return tagtransform_c_filter_basic_tags(OSMTYPE_WAY, tags, polygon, roads);
+    }
+}
+
+unsigned int tagtransform_filter_rel_tags(struct keyval *tags) {
+    int poly, roads;
+    if (transform_method) {
+        return tagtransform_lua_filter_basic_tags(OSMTYPE_RELATION, tags, &poly, &roads);
+    } else {
+        return tagtransform_c_filter_basic_tags(OSMTYPE_RELATION, tags, &poly, &roads);
+    }
+}
+
+unsigned int tagtransform_filter_rel_member_tags(struct keyval *rel_tags, int member_count, struct keyval *member_tags,const char **member_role, int * member_superseeded, int * make_boundary, int * make_polygon, int * roads) {
+    if (transform_method) {
+        return tagtransform_lua_filter_rel_member_tags(rel_tags, member_count, member_tags, member_role, member_superseeded, make_boundary, make_polygon, roads);
+    } else {
+        return tagtransform_c_filter_rel_member_tags(rel_tags, member_count, member_tags, member_role, member_superseeded, make_boundary, make_polygon, roads);
+    }
+}
+
+int tagtransform_init(const struct output_options *opts) {
+    options = opts;
+    if (opts->tag_transform_script) {
+        transform_method = 1;
+        fprintf(stderr, "Using lua based tag processing pipeline with script %s\n", opts->tag_transform_script);
+        return tagtransform_lua_init();
+    } else  {
+        transform_method = 0;
+        fprintf(stderr, "Using built-in tag processing pipeline\n");
+        return 0; //Nothing to initialise
+    }
+}
+
+void tagtransform_shutdown() {
+    if (transform_method)
+        tagtransform_lua_shutdown();
+}
diff --git a/tagtransform.h b/tagtransform.h
new file mode 100644
index 0000000..3fe1252
--- /dev/null
+++ b/tagtransform.h
@@ -0,0 +1,29 @@
+
+#ifndef TAGTRANSFORM_H
+#define TAGTRANSFORM_H
+
+#ifdef HAVE_LUA
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+#endif
+#include "output.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+unsigned int tagtransform_filter_node_tags(struct keyval *tags);
+unsigned int tagtransform_filter_way_tags(struct keyval *tags, int * polygon, int * roads);
+unsigned int tagtransform_filter_rel_tags(struct keyval *tags);
+unsigned int tagtransform_filter_rel_member_tags(struct keyval *rel_tags, int member_count, struct keyval *member_tags,const char **member_role, int * member_superseeded, int * make_boundary, int * make_polygon, int * roads);
+
+int tagtransform_init(const struct output_options *options);
+void tagtransform_shutdown();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //TAGTRANSFORM_H
diff --git a/tests/000466354.osc.gz b/tests/000466354.osc.gz
new file mode 100644
index 0000000..b5e0333
Binary files /dev/null and b/tests/000466354.osc.gz differ
diff --git a/tests/liechtenstein-2013-08-03.osm.pbf b/tests/liechtenstein-2013-08-03.osm.pbf
new file mode 100644
index 0000000..2bbc7d8
Binary files /dev/null and b/tests/liechtenstein-2013-08-03.osm.pbf differ
diff --git a/tests/regression-test.py b/tests/regression-test.py
new file mode 100644
index 0000000..ada11e3
--- /dev/null
+++ b/tests/regression-test.py
@@ -0,0 +1,605 @@
+import unittest
+import psycopg2
+import os
+from pwd import getpwnam
+import subprocess
+
+full_import_file="tests/liechtenstein-2013-08-03.osm.pbf"
+multipoly_import_file="tests/test_multipolygon.osm" #This file contains a number of different multi-polygon test cases
+diff_import_file="tests/000466354.osc.gz"
+diff_multipoly_import_file="tests/test_multipolygon_diff.osc" #This file contains a number of different multi-polygon diff processing test cases
+
+created_tablespace = 0
+
+#****************************************************************
+#****************************************************************
+sql_test_statements=[
+    ( 0, 'Basic point count', 'SELECT count(*) FROM planet_osm_point;', 1342 ),
+    ( 1, 'Basic line count', 'SELECT count(*) FROM planet_osm_line;', 3300 ),
+    ( 2, 'Basic road count', 'SELECT count(*) FROM planet_osm_roads;', 375 ),
+    ( 3, 'Basic polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4128 ),
+    ( 4,  'Basic latlon line count', 'SELECT count(*) FROM planet_osm_line;', 3298 ),
+    ( 5, 'Basic latlon road count', 'SELECT count(*) FROM planet_osm_roads;', 374 ),
+    ( 6, 'Basic post-diff point count', 'SELECT count(*) FROM planet_osm_point;', 1457 ),
+    ( 7, 'Basic post-diff line count', 'SELECT count(*) FROM planet_osm_line;', 3344 ),
+    ( 8, 'Basic post-diff road count', 'SELECT count(*) FROM planet_osm_roads;', 381 ),
+    ( 9, 'Basic post-diff polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4275 ),
+    ( 10, 'Absence of nodes table', 'SELECT count(*) FROM pg_tables WHERE tablename = \'planet_osm_nodes\'', 0),
+    ( 11, 'Absence of way table', 'SELECT count(*) FROM pg_tables WHERE tablename = \'planet_osm_ways\'', 0),
+    ( 12, 'Absence of rel line', 'SELECT count(*) FROM pg_tables WHERE tablename = \'planet_osm_rels\'', 0),
+    ( 13, 'Basic polygon area', 'SELECT round(sum(cast(ST_Area(way) as numeric)),0) FROM planet_osm_polygon;', 1223800814),
+    ( 14, 'Gazetteer place count', 'SELECT count(*) FROM place', 4500),
+    ( 15, 'Gazetteer place node count', 'SELECT count(*) FROM place WHERE osm_type = \'N\'', 779),
+    ( 16, 'Gazetteer place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 3699),
+    ( 17, 'Gazetteer place rel count', 'SELECT count(*) FROM place WHERE osm_type = \'R\'', 22),
+    ( 18, 'Gazetteer post-diff place count', 'SELECT count(*) FROM place', 4554),
+    ( 19, 'Gazetteer post-diff place node count', 'SELECT count(*) FROM place WHERE osm_type = \'N\'', 788),
+    ( 20, 'Gazetteer post-diff place way count', 'SELECT count(*) FROM place WHERE osm_type = \'W\'', 3744),
+    ( 21, 'Gazetteer post-diff place rel count', 'SELECT count(*) FROM place WHERE osm_type = \'R\'', 22),
+    ( 22, 'Gazetteer housenumber count', 'SELECT count(*) FROM place WHERE housenumber is not null', 199),
+    ( 23, 'Gazetteer post-diff housenumber count count', 'SELECT count(*) FROM place WHERE housenumber is not null', 199),
+    ( 24, 'Gazetteer isin count', 'SELECT count(*) FROM place WHERE isin is not null', 239),
+    ( 25, 'Gazetteer post-diff isin count count', 'SELECT count(*) FROM place WHERE isin is not null', 239),
+    ( 26, 'Multipolygon basic case (Tags from outer way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -15 and landuse = \'residential\' and name = \'Name_way\'', 12894),
+    ( 27, 'Multipolygon basic case (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -1 and landuse = \'residential\' and name = \'Name_rel\'', 12895),
+    ( 28, 'Multipolygon named inner - outer (Tags from way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -16 and landuse = \'residential\' and name = \'Name_way2\'', 12895),
+    ( 29, 'Multipolygon named inner - inner way',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 4 and landuse = \'farmland\' and name = \'Name_way3\'', 3144),
+    ( 30, 'Multipolygon named inner - outer (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -8 and landuse = \'residential\' and name = \'Name_rel2\'', 12894),
+    ( 31, 'Multipolygon named inner - inner way',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 5 and landuse = \'farmland\' and name = \'Name_way4\'', 3144),
+    ( 32, 'Multipolygon named same inner - outer (Tags from way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -17 and landuse = \'residential\' and name = \'Name_way16\'', 12895),
+    ( 33, 'Multipolygon named same inner - inner way absent',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 15', 0),
+    ( 34, 'Multipolygon non-area inner - outer (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -14 and landuse = \'residential\' and name = \'Name_way5\'', 12893),
+    ( 35, 'Multipolygon non-area inner - inner (Tags from way)',
+      'SELECT round(ST_Length(way)) FROM planet_osm_line WHERE osm_id = 6 and highway = \'residential\' and name = \'Name_way6\'', 228),
+    ( 36, 'Multipolygon 2 holes (Tags from way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -18 and landuse = \'residential\' and name = \'Name_way7\'', 11823),
+    ( 37, 'Multipolygon 2 holes (Tags from way)',
+      'SELECT ST_NumInteriorRing(way) FROM planet_osm_polygon WHERE osm_id = -18 and landuse = \'residential\' and name = \'Name_way7\'', 2),
+    ( 38, 'Multipolygon from multiple outer ways 0 holes (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -11 and landuse = \'residential\' and name = \'Name_rel6\'', 11528),
+    ( 39, 'Multipolygon from multiple outer and multiple inner ways 2 holes (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -3 and landuse = \'residential\' and name = \'Name_rel11\'',  9286),
+    ( 40, 'Multipolygon 2 holes (Tags from way)',
+      'SELECT ST_NumInteriorRing(way) FROM planet_osm_polygon WHERE osm_id = -3 and landuse = \'residential\' and name = \'Name_rel11\'', 2),
+    ( 41, 'Multipolygon with touching inner ways 1 hole (Tags from way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -19 and landuse = \'residential\' and name = \'Name_way8\'',  12167),
+    ( 42, 'Multipolygon with touching inner ways 1 hole (Tags from way)',
+      'SELECT ST_NumInteriorRing(way) FROM planet_osm_polygon WHERE osm_id = -19 and landuse = \'residential\' and name = \'Name_way8\'', 1),
+    ( 43, 'Multipolygon with 2 outer ways (Tags from relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -13 and landuse = \'farmland\' and name = \'Name_rel9\'',  17581),
+    ( 44, 'Multipolygon with 2 outer ways (Tags from relation)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -13 and landuse = \'farmland\' and name = \'Name_rel9\'', 2),
+    ( 45, 'Multipolygon with 2 outer ways (multigeometry)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -13 and landuse = \'farmland\' and name = \'Name_rel9\'', 1),
+    ( 46, 'Multipolygon with 2 outer ways (multigeometry)',
+      'SELECT ST_NumGeometries(way) FROM planet_osm_polygon WHERE osm_id = -13 and landuse = \'farmland\' and name = \'Name_rel9\'', 2),
+    ( 47, 'Multipolygon nested outer ways. Both outer and inner ways are from multiple ways (Tags from relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -7 and landuse = \'farmland\' and name = \'Name_rel15\'',  16169),
+    ( 48, 'Multipolygon nested outer ways. Both outer and inner ways are from multiple ways (Tags from relation)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -7 and landuse = \'farmland\' and name = \'Name_rel15\'',  2),
+    ( 49, 'Multipolygon nested outer ways. Both outer and inner ways are from multiple ways (multigeometry)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -7 and landuse = \'farmland\' and name = \'Name_rel15\'',  1),
+    ( 50, 'Multipolygon nested outer ways. Both outer and inner ways are from multiple ways (multigeometry)',
+      'SELECT ST_NumGeometries(way) FROM planet_osm_polygon WHERE osm_id = -7 and landuse = \'farmland\' and name = \'Name_rel15\'',  2),
+    ( 51, 'Basic hstore point count', 'SELECT count(*) FROM planet_osm_point;', 1360 ),
+    ( 52, 'Basic hstore line count', 'SELECT count(*) FROM planet_osm_line;', 3323 ),
+    ( 53, 'Basic hstore road count', 'SELECT count(*) FROM planet_osm_roads;', 375 ),
+    ( 54, 'Basic hstore polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4128 ),
+    ( 55, 'Basic post-diff point count', 'SELECT count(*) FROM planet_osm_point;', 1475 ),
+    ( 56, 'Basic post-diff line count', 'SELECT count(*) FROM planet_osm_line;', 3367 ),
+    ( 57, 'Basic post-diff road count', 'SELECT count(*) FROM planet_osm_roads;', 381 ),
+    ( 58, 'Basic post-diff polygon count', 'SELECT count(*) FROM planet_osm_polygon;', 4275 ),
+    ( 59, 'Extra hstore full tags point count',
+      'SELECT count(*) FROM planet_osm_point WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 1360),
+    ( 60, 'Extra hstore full tags line count',
+      'SELECT count(*) FROM planet_osm_line WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 3323),
+    ( 61, 'Extra hstore full tags polygon count',
+      'SELECT count(*) FROM planet_osm_polygon WHERE tags ? \'osm_user\' and tags ? \'osm_version\' and tags ? \'osm_uid\' and tags ? \'osm_changeset\'', 4128),
+    ( 62, 'Multipolygon copying of tags from outer with extra tags on relation',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -22', 20879),
+    ( 63, 'Multipolygon copying of tags from outer with extra tags on relation (abscence of way)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 84', 0),
+    ( 64, 'Multipolygon non copying of tags from outer with polygon tags on relation',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -24 and "natural" = \'water\'', 18501),
+    ( 65, 'Multipolygon non copying of tags from outer with polygon tags on relation (presence of way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 83 and "landuse" = \'farmland\'', 24859),
+    ( 66, 'Multipolygon diff moved point of outer way case (Tags from outer way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -15 and landuse = \'residential\' and name = \'Name_way\'', 24751),
+    ( 67, 'Multipolygon diff moved point of inner way case (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -1 and landuse = \'residential\' and name = \'Name_rel\'', 13949),
+    ( 68, 'Multipolygon point of inner way case (Tags from relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -25 and landuse = \'farmland\' and name = \'my name\'', 23886),
+    ( 69, 'Multipolygon point of inner way case (Tags from relation)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 90', 0),
+    ( 70, 'Multipolygon diff remove relation (tagged outer way gets re added)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 90 and landuse = \'farmland\'', 32626),
+    ( 71, 'Multipolygon diff remove relation',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -25', 0),
+    ( 72, 'Multipolygon tags on both inner and outer (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -34 and "natural" = \'water\'', 15246),
+    ( 73, 'Multipolygon tags on both inner and outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 113', 0),
+    ( 74, 'Multipolygon tags on both inner and outer (abscence of inner)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 118', 0),
+    ( 75, 'Multipolygon tags on both inner and outer diff change outer (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -34 and "landuse" = \'farmland\'', 15246),
+    ( 76, 'Multipolygon tags on both inner and outer diff change outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 113', 0),
+    ( 77, 'Multipolygon tags on both inner and outer diff change on outer (creation of inner)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 118 and "natural" = \'water\'', 1234),
+    ( 78, 'Multipolygon tags on outer (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -33 and "natural" = \'water\'', 15612),
+    ( 79, 'Multipolygon tags on outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 114', 0),
+    ( 80, 'Multipolygon tags on outer change of way tags (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -33 and "landuse" = \'cemetery\'', 15612),
+    ( 81, 'Multipolygon tags on outer (abscence of old relation)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -33 and "natural" = \'water\'', 0),
+    ( 82, 'Multipolygon tags on relation two outer (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -29 and "natural" = \'water\'', 68492),
+    ( 83, 'Multipolygon tags on relation two outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 109', 0),
+    ( 84, 'Multipolygon tags on relation two outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 104', 0),
+    ( 85, 'Multipolygon tags on relation two outer diff delete way (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -29 and "natural" = \'water\'', 29154),
+    ( 86, 'Multipolygon tags on relation two outer (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -35 and "natural" = \'water\'', 28730),
+    ( 87, 'Multipolygon tags on relation two outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 107', 0),
+    ( 88, 'Multipolygon tags on relation two outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 102', 0),
+    ( 89, 'Multipolygon tags on relation two outer diff remove way from relation (presence of relation)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = -35 and "natural" = \'water\'', 15736),
+    ( 90, 'Multipolygon tags on relation two outer diff remove way from relation (presence of single way)',
+      'SELECT round(ST_Area(way)) FROM planet_osm_polygon WHERE osm_id = 102 and "natural" = \'water\'', 12994),
+    ( 91, 'Basic line length', 'SELECT round(sum(ST_Length(way))) FROM planet_osm_line;', 4269394),
+    ( 92, 'Basic line length', 'SELECT round(sum(ST_Length(way))) FROM planet_osm_roads;', 2032023),
+    ( 93, 'Basic number of hstore points tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_point;', 4228),
+    ( 94, 'Basic number of hstore roads tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_roads;', 2316),
+    ( 95, 'Basic number of hstore lines tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_line;', 10897),
+    ( 96, 'Basic number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9540),
+    ( 97, 'Diff import number of hstore points tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_point;', 4352),
+    ( 98, 'Diff import number of hstore roads tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_roads;', 2340),
+    ( 99, 'Diff import number of hstore lines tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_line;', 11020),
+    ( 100, 'Diff import number of hstore polygons tags', 'SELECT sum(array_length(akeys(tags),1)) FROM planet_osm_polygon;', 9834),
+    #**** Tests to check if inner polygon appears when outer tags change after initially identicall inner and outer way tags in a multi-polygon ****
+    #**** These tests are currently broken and noted in trac ticket #2853 ****
+    ( 101, 'Multipolygon identical tags on inner and outer (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -31 and "natural" = \'heath\'', 32702),
+    ( 102, 'Multipolygon identical tags on inner and outer (abscence of outer)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 120', 0),
+    ( 103, 'Multipolygon identical tags on inner and outer (abscence of inner)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 112', 0),
+    ( 104, 'Multipolygon identical tags on inner and outer (presence of relation), post diff',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -31 and "natural" = \'water\'', 32702),
+    ( 105, 'Multipolygon identical tags on inner and outer (presece of inner)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = 112 and "natural" = \'heath\'', 1234),
+    #**** Test to check that only polygon tags that are present on all outer ways get copied over to the multi-polygon relation ****
+    ( 106, 'Multipolygon copy outer tags (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -38 and "natural" = \'water\'', 29340),
+    ( 107, 'Multipolygon copy outer tags (absence of partial outer tags)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -38 and "natural" = \'water\' and "man_made" = \'pier\'', 0),
+    ( 108, 'Multipolygon copy outer tags (absence of multi-polygon tagged outer way)',
+      'SELECT count(*) FROM planet_osm_line WHERE osm_id = 134 OR osm_id = 133', 0),
+    ( 109, 'Multipolygon copy outer tags (presence of additionally tagged outer way)',
+      'SELECT round(sum(ST_length(way))) FROM planet_osm_line WHERE (osm_id = 136 OR osm_id = 132) AND "man_made" = \'pier\'', 407),
+    ( 110, 'Multipolygon copy outer tags (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -37 and "natural" = \'water\'', 29952),
+    ( 111, 'Multipolygon copy outer tags (absence of partial outer tags)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = -37 and "natural" = \'water\' and "man_made" = \'pier\'', 0),
+    ( 112, 'Multipolygon copy outer tags (absence of multi-polygon tagged outer way)',
+      'SELECT count(*) FROM planet_osm_line WHERE osm_id = 128 OR osm_id = 125', 0),
+    ( 113, 'Multipolygon copy outer tags (presence of additionally tagged outer way)',
+      'SELECT round(sum(ST_length(way))) FROM planet_osm_line WHERE (osm_id = 126 OR osm_id = 124) AND "man_made" = \'pier\'', 276),
+    ( 114, 'Multipolygon copy outer tags (absence of multi-polygon tagged inner way)',
+      'SELECT count(*) FROM planet_osm_line WHERE osm_id = 123 OR osm_id = 121', 0),
+    ( 115, 'Multipolygon copy outer tags (presence of additionally tagged inner way)',
+      'SELECT round(sum(ST_length(way))) FROM planet_osm_line WHERE (osm_id = 127 OR osm_id = 122) AND "man_made" = \'pier\'', 318),
+    #**** Test to check that if polygon tags are on both outer ways and relation, polygons don't get duplicated in the db ****
+    ( 116, 'Multipolygon tags on both outer and relation (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -39 and "landuse" = \'forest\'', 10379),
+    ( 117, 'Multipolygon tags on both outer and relation (absence of outer way)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 138', 0),
+    ( 118, 'Multipolygon tags on both outer and relation with additional tags on relation (presence of relation)',
+      'SELECT round(sum(ST_Area(way))) FROM planet_osm_polygon WHERE osm_id = -40 and "landuse" = \'forest\'', 12397),
+    ( 119, 'Multipolygon tags on both outer and relation with additional tags on relation (absence of outer way)',
+      'SELECT count(*) FROM planet_osm_polygon WHERE osm_id = 140', 0),
+    ]
+#****************************************************************
+#****************************************************************
+
+
+class NonSlimRenderingTestSuite(unittest.TestSuite):
+    def __init__(self):
+        unittest.TestSuite.__init__(self,map(ThirdTestCase,
+                                             ("testOne",
+                                              "testTwo")))
+        self.addTest(BasicNonSlimTestCase("basic case",[], [0,1,2,3,10,13, 91, 92]))
+        self.addTest(BasicNonSlimTestCase("slim --drop case",["--slim","--drop"], [0,1,2,3, 10, 11, 12, 13, 91, 92]))
+        self.addTest(BasicNonSlimTestCase("lat lon projection",["-l"], [0,4,5,3,10, 11, 12]))
+        #Failing test 3,13 due to difference in handling mixture of tags on ways and relations, where the correct behaviour is non obvious
+        #self.addTest(BasicNonSlimTestCase("--tag-transform-script", ["--tag-transform-script", "style.lua"], [0,1,2,3,10,13,91,92]))
+        self.addTest(BasicNonSlimTestCase("--tag-transform-script", ["--tag-transform-script", "style.lua"], [0,1,2,10,91,92]))
+
+
+class SlimRenderingTestSuite(unittest.TestSuite):
+    def __init__(self):
+        unittest.TestSuite.__init__(self,map(ThirdTestCase,
+                                             ("testOne",
+                                              "testTwo")))
+        self.addTest(BasicSlimTestCase("basic case", [], [0,1,2,3,13, 91, 92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Parallel processing", ["--number-processes", "8", "-C100"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Parallel processing with non 100% node-cache", ["--number-processes", "8", "-C1", "--cache-strategy=dense"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Parallel processing with disabled node-cache", ["-C0"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        # Failes to do correct error checking. This needs fixing in osm2pgsql
+        # self.addTest(BasicSlimTestCase("Parallel processing with failing database conneciton (connection limit exceeded)", ["--number-processes", "32", "-C100"], [0,1,2,3],[6,7,8,9]))
+        # Counts are expected to be different in hstore, needs adjusted tests
+        self.addTest(BasicSlimTestCase("Hstore match only", ["-k", "--hstore-match-only"], [0,1,2,3],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Hstore name column", ["-z", "name:"], [0,1,2,3],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Hstore", ["-k"], [51,52,53,54],[55,56,57,58]))
+        self.addTest(BasicSlimTestCase("Hstore all", ["-j"], [51,52,53,54,93,94,95,96],[55,56,57,58, 97, 98, 99, 100]))
+        #tests dont check for osm_timestamp which is currently missing in the pbf parser
+        self.addTest(BasicSlimTestCase("Extra tags hstore match only", ["-x", "-k", "--hstore-match-only"], [0,1,2,3],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("Extra tags hstore all", ["-j", "-x"], [51,52,53,54,59,60,61],[55,56,57,58]))
+        
+        self.addTest(BasicSlimTestCase("--tablespace-main-data", ["--tablespace-main-data", "tablespacetest"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("--tablespace-main-index", ["--tablespace-main-index", "tablespacetest"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("--tablespace-slim-data", ["--tablespace-slim-data", "tablespacetest"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        self.addTest(BasicSlimTestCase("--tablespace-slim-index", ["--tablespace-slim-index", "tablespacetest"], [0,1,2,3,13,91,92],[6,7,8,9]))
+        #Failing test 3,13,9 due to difference in handling mixture of tags on ways and relations, where the correct behaviour is non obvious
+        #self.addTest(BasicNonSlimTestCase("--tag-transform-script", ["--tag-transform-script", "style.lua"], [0,1,2,3,10,13,91,92]))
+        self.addTest(BasicSlimTestCase("--tag-transform-script", ["--tag-transform-script", "style.lua"], [0,1,2,91,92],[6,7,8]))
+
+
+class SlimGazetteerTestSuite(unittest.TestSuite):
+    def __init__(self):
+        unittest.TestSuite.__init__(self,map(ThirdTestCase,
+                                             ("testOne",
+                                              "testTwo")))
+        self.addTest(BasicGazetteerTestCase("basic case", [], [14,15,16,17,22,24],[18,19,20,21,23,25]))
+
+
+class MultiPolygonSlimRenderingTestSuite(unittest.TestSuite):
+    def __init__(self):
+        unittest.TestSuite.__init__(self,map(ThirdTestCase,
+                                             ("testOne",
+                                              "testTwo")))
+        #Case 77 currently doesn't work
+        self.addTest(MultipolygonSlimTestCase("basic case", [],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 68, 69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("multi geometry", ["-G"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 45, 46, 47, 49, 50, 62, 63, 64, 65, 68, 69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 45, 46, 47, 49, 50, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("hstore case", ["-k"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,47,48,62,63,64,65,68,69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("hstore case", ["-k", "--hstore-match-only"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38, 39, 40,41,42, 43, 44, 47, 48,  62, 63, 64, 65, 68, 69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("Extra tags hstore match only", ["-x", "-k", "--hstore-match-only"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38, 39, 40,41,42, 43, 44, 47, 48,  62, 63, 64, 65, 68, 69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("Extra tags hstore match only", ["-x", "-j"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38, 39, 40,41,42, 43, 44, 47, 48,  62, 63, 64, 65, 68, 69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,
+                                               106,107,108,109,110,111,112,113,114,115,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63, 64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("lua tagtransform case", ["--tag-transform-script", "style.lua"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38, 39, 40, 41, 42, 43, 44, 47, 48,  62, 64, 65,68,69, 72, 73, 74, 78, 79, 82, 83, 84, 86, 87, 88,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42, 43, 44, 47, 48, 62, 63,64, 65, 66, 67, 70, 71, 75, 76, 79, 80, 81, 83, 84, 85, 87, 89, 90]))
+        self.addTest(MultipolygonSlimTestCase("lua tagtransform case with hstore", ["--tag-transform-script", "style.lua", "-k"],
+                                              [26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,47,48,62,63,64,65,68,69,72,73,74,78,79,82,83,84,86,87,88,116,117,118,119],
+                                              [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,47,48,62,63,64,65,66,67,70,71,75,76,79,80,81,83,84,85,87,89,90]))
+
+
+class CompleteTestSuite(unittest.TestSuite):
+    def __init__(self):
+        unittest.TestSuite.__init__(self, map(ThirdTestCase,
+                                             ("testOne",
+                                              "testTwo")))
+        self.addTest(NonSlimRenderingTestSuite())
+        self.addTest(SlimRenderingTestSuite())
+        self.addTest(MultiPolygonSlimRenderingTestSuite())
+        self.addTest(SlimGazetteerTestSuite())
+
+#****************************************************************
+class ThirdTestCase(unittest.TestCase):
+    def testOne(self):
+        assert 1 == 1
+    def testTwo(self):
+        assert 2 == 2
+
+#****************************************************************
+
+class BaseTestCase(unittest.TestCase):
+    def dbConnect(self):
+        try:
+            self.conn=psycopg2.connect("dbname='osm2pgsql-test'")
+            self.conn.autocommit = True
+            self.cur = self.conn.cursor()
+        except Exception, e:
+            print "I am unable to connect to the database." + e
+
+    def dbClose(self):
+        self.cur.close()
+        self.conn.close()
+
+    def executeStatements(self, seq):
+        print "*********************************"
+        self.dbConnect()
+        try:
+            for i in seq:
+                self.assertEqual(sql_test_statements[i][0], i, "test case numbers don't match up: " + str(i) + " =/=" + str(sql_test_statements[i][0]))
+                try:
+                    self.cur.execute(sql_test_statements[i][2])
+                    res = self.cur.fetchall()
+                except Exception, e:
+                    self.assertEqual(0, 1, str(sql_test_statements[i][0]) + ": Failed to execute " + sql_test_statements[i][1] +
+                                     " (" + sql_test_statements[i][2] + ") {" + str(self.parameters) +"}")
+                if (res == None):
+                        self.assertEqual(0, 1, str(sql_test_statements[i][0]) + ": Sql statement returned no results: " +
+                                         sql_test_statements[i][1] + " (" + sql_test_statements[i][2] + ") {" + str(self.parameters) +"}")
+                self.assertEqual(len(res), 1, str(sql_test_statements[i][0]) + ": Sql statement returned more than one result: " +
+                                 str(res) + "  -- " + sql_test_statements[i][1] + " (" + sql_test_statements[i][2] + ") {" + str(self.parameters) +"}")
+                self.assertEqual( res[0][0], sql_test_statements[i][3],
+                                  str(sql_test_statements[i][0]) + ": Failed " + sql_test_statements[i][1] + ", expected " + str(sql_test_statements[i][3]) + " but was " + str(res[0][0]) +
+                                  " (" + sql_test_statements[i][2] + ") {" + str(self.parameters) +"}")
+        finally:
+            self.dbClose()
+
+#****************************************************************
+
+class BaseNonSlimTestCase(BaseTestCase):
+    
+    def setUpGeneric(self, parameters, file):
+        returncode = subprocess.call(["./osm2pgsql", "-Sdefault.style", "-dosm2pgsql-test", "-C100"] + parameters + [full_import_file])
+        self.assertEqual( returncode, 0, "Execution of osm2pgsql with options: " + str(parameters) + " failed")
+
+class BaseSlimTestCase(BaseTestCase):    
+        
+    def setUpGeneric(self, parameters, file):
+        returncode = subprocess.call(["./osm2pgsql", "--slim", "-Sdefault.style", "-dosm2pgsql-test", "-C100"] + parameters + [file])
+        self.assertEqual( returncode, 0, "Execution of osm2pgsql --slim with options: " + str(parameters) + " failed")
+
+    def updateGeneric(self, parameters, file):
+        returncode = subprocess.call(["./osm2pgsql", "--slim", "--append", "-Sdefault.style", "-dosm2pgsql-test", "-C100"] + parameters + [file])
+        self.assertEqual( returncode, 0, "Execution of osm2pgsql --slim --append with options: " + str(parameters) + " failed")
+
+class BaseGazetteerTestCase(BaseTestCase):    
+        
+    def setUpGeneric(self, parameters, file):
+        returncode = subprocess.call(["./osm2pgsql", "--slim", "-Ogazetteer", "-Sdefault.style", "-dosm2pgsql-test", "-C100"] + parameters + [file])
+        self.assertEqual( returncode, 0, "Execution of osm2pgsql --slim -Ogazetteer with options: " + str(parameters) + " failed")
+
+    def updateGeneric(self, parameters, file):
+        returncode = subprocess.call(["./osm2pgsql", "--slim", "-Ogazetteer", "--append", "-Sdefault.style", "-dosm2pgsql-test", "-C100"] + parameters + [file])
+        self.assertEqual( returncode, 0, "Execution of osm2pgsql --slim -Ogazetteer --append with options: " + str(parameters) + " failed")
+
+#****************************************************************
+class BasicNonSlimTestCase(BaseNonSlimTestCase):
+
+    def __init__(self, name, parameters, initialStatements):
+        BaseNonSlimTestCase.__init__(self)
+        self.name = name
+        self.parameters = parameters
+        self.initialStatements = initialStatements
+
+    def setUp(self):
+        self.setUpGeneric(self.parameters, full_import_file)
+
+    def runTest(self):
+        print "****************************************"
+        print "Running initial import for " + self.name
+        self.executeStatements(self.initialStatements)
+
+
+class BasicSlimTestCase(BaseSlimTestCase):
+
+    def __init__(self, name, parameters, initialStatements, postDiffStatements):
+        BaseSlimTestCase.__init__(self)
+        self.name = name
+        self.parameters = parameters
+        self.initialStatements = initialStatements
+        self.postDiffStatements = postDiffStatements
+
+    def setUp(self):
+        self.setUpGeneric(self.parameters, full_import_file)
+
+
+    def runTest(self):
+        print "****************************************"
+        print "Running initial import for " + self.name
+        self.executeStatements(self.initialStatements)
+        print "Running diff-import for " + self.name
+        self.updateGeneric(self.parameters, diff_import_file)
+        self.executeStatements(self.postDiffStatements)
+
+class MultipolygonSlimTestCase(BaseSlimTestCase):
+
+    def __init__(self, name, parameters, initialStatements, postDiffStatements):
+        BaseSlimTestCase.__init__(self)
+        self.name = name
+        self.parameters = parameters
+        self.initialStatements = initialStatements
+        self.postDiffStatements = postDiffStatements
+
+    def setUp(self):
+        self.setUpGeneric(self.parameters, multipoly_import_file)
+
+
+    def runTest(self):
+        print "****************************************"
+        print "Running initial import for " + self.name
+        self.executeStatements(self.initialStatements)
+        print "Running diff-import for " + self.name
+        self.updateGeneric(self.parameters, diff_multipoly_import_file)
+        self.executeStatements(self.postDiffStatements)
+
+
+class BasicGazetteerTestCase(BaseGazetteerTestCase):
+
+    def __init__(self, name, parameters, initialStatements, postDiffStatements):
+        BaseGazetteerTestCase.__init__(self)
+        self.name = name
+        self.parameters = parameters
+        self.initialStatements = initialStatements
+        self.postDiffStatements = postDiffStatements
+
+    def setUp(self):
+        self.setUpGeneric(self.parameters, full_import_file)
+
+
+    def runTest(self):
+        print "****************************************"
+        print "Running initial import in gazetteer mode for " + self.name
+        self.executeStatements(self.initialStatements)
+        print "Running diff-import in gazetteer mode for " + self.name
+        self.updateGeneric(self.parameters, diff_import_file)
+        self.executeStatements(self.postDiffStatements)
+
+
+
+#****************************************************************
+#****************************************************************
+def setupDB():
+    print "Setting up test database"
+    try:
+        gen_conn=psycopg2.connect("dbname='template1'")
+        gen_conn.autocommit = True
+    except Exception, e:
+        print "I am unable to connect to the database."
+        exit()
+
+    try:
+        gen_cur = gen_conn.cursor()
+    except Exception, e:
+        gen_conn.close()
+        print "I am unable to connect to the database."
+        exit()
+
+    try:
+        gen_cur.execute("""DROP DATABASE IF EXISTS \"osm2pgsql-test\"""")
+        gen_cur.execute("""CREATE DATABASE \"osm2pgsql-test\" WITH ENCODING 'UTF8'""")
+    except Exception, e:
+        print "Failed to create osm2pgsql-test db" + e.pgerror
+        exit();
+    finally:
+        gen_cur.close()
+        gen_conn.close()
+
+    try:
+        test_conn=psycopg2.connect("dbname='osm2pgsql-test'")
+        test_conn.autocommit = True
+    except Exception, e:
+        print "I am unable to connect to the database." + e
+        exit()
+
+    try:
+        test_cur = test_conn.cursor()
+    except Exception, e:
+        print "I am unable to connect to the database." + e
+        gen_conn.close()
+        exit()
+
+    try:
+        try:
+            global created_tablespace
+            test_cur.execute("""SELECT spcname FROM pg_tablespace WHERE spcname = 'tablespacetest'""")
+            if test_cur.fetchone():
+                print "We already have a tablespace, can use that"
+                created_tablespace = 0
+            else:
+                print "For the test, we need to create a tablespace. This needs root privilidges"
+                created_tablespace = 1
+                ### This makes postgresql read from /tmp
+                ## Does this have security implications like opening this to a possible symlink attack?
+                try:
+                    os.mkdir("/tmp/psql-tablespace")
+                    returncode = subprocess.call(["/usr/bin/sudo", "/bin/chown", "postgres.postgres", "/tmp/psql-tablespace"])
+                    test_cur.execute("""CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'""")
+                except Exception, e:
+                    os.rmdir("/tmp/psql-tablespace")
+                    self.assertEqual(0, 1, "Failed to create tablespace")
+        except Exception, e:
+            print "Failed to create directory for tablespace" + str(e)
+
+
+        try:
+            test_cur.execute("""CREATE EXTENSION postgis;""")
+        except:
+            test_conn.rollback()
+            # Guess the directory from the postgres version.
+            # TODO: make the postgisdir configurable. Probably
+            # only works on Debian-based distributions at the moment.
+            postgisdir = ('/usr/share/postgresql/%d.%d/contrib' %
+                        (test_conn.server_version / 10000, (test_conn.server_version / 100) % 100))
+            for fl in os.listdir(postgisdir):
+                if fl.startswith('postgis'):
+                    newdir = os.path.join(postgisdir, fl)
+                    if os.path.isdir(newdir):
+                        postgisdir = newdir
+                        break
+            else:
+                raise Exception('Cannot find postgis directory.')
+            pgscript = open(os.path.join(postgisdir, 'postgis.sql'),'r').read()
+            test_cur.execute(pgscript)
+            pgscript = open(os.path.join(postgisdir, 'spatial_ref_sys.sql'), 'r').read()
+            test_cur.execute(pgscript)
+
+        try:
+            test_cur.execute("""CREATE EXTENSION hstore;""")
+
+        except Exception, e:
+            print "I am unable to create extensions: " + e.pgerror
+            exit()
+    finally:
+        test_cur.close()
+        test_conn.close()
+
+def tearDownDB():
+    print "Cleaning up test database"
+    try:
+        gen_conn=psycopg2.connect("dbname='template1'")
+        gen_conn.autocommit = True
+        gen_cur = gen_conn.cursor()
+    except Exception, e:
+        print "I am unable to connect to the database."
+        exit()
+
+    try:
+        gen_cur.execute("""DROP DATABASE IF EXISTS \"osm2pgsql-test\"""")
+        if (created_tablespace == 1):
+            gen_cur.execute("""DROP TABLESPACE IF EXISTS \"tablespacetest\"""")
+    except Exception, e:
+        print "Failed to clean up osm2pgsql-test db" + e.pgerror
+        exit();
+
+    gen_cur.close()
+    gen_conn.close()
+    if (created_tablespace == 1):
+        returncode = subprocess.call(["/usr/bin/sudo", "/bin/rmdir", "/tmp/psql-tablespace"])
+
+
+
+ts2 = CompleteTestSuite()
+try:
+    setupDB()
+    runner = unittest.TextTestRunner()
+    runner.run(ts2)
+finally:
+    tearDownDB()
diff --git a/tests/regression-test.sh b/tests/regression-test.sh
index 4fdac9a..f1ae77d 100755
--- a/tests/regression-test.sh
+++ b/tests/regression-test.sh
@@ -17,8 +17,15 @@ function setup_db {
     echo "Initialising test db"
     dropdb osm2pgsql-test > /dev/null || true
     createdb -E UTF8 osm2pgsql-test
-    psql -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql -d osm2pgsql-test > /dev/null
-    psql -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql -d osm2pgsql-test > /dev/null
+    if [ -d "/usr/share/postgresql/9.1/contrib/postgis-1.5/" ]; then
+        postgis_dir=/usr/share/postgresql/9.1/contrib/postgis-1.5
+    fi
+    if [ -z $postgis_dir ]; then
+        psql -c "CREATE EXTENSION postgis;" -d osm2pgsql-test &> /dev/null
+    else
+        psql -f $postgis_dir/postgis.sql -d osm2pgsql-test > /dev/null
+        psql -f $postgis_dir/spatial_ref_sys.sql -d osm2pgsql-test > /dev/null
+    fi
     psql -c "CREATE EXTENSION hstore;" -d osm2pgsql-test &> /dev/null
     sudo rm -rf /tmp/psql-tablespace || true
     mkdir /tmp/psql-tablespace
@@ -28,12 +35,11 @@ function setup_db {
 }
 
 function teardown_db {
+    echo "Cleaning up"
     dropdb osm2pgsql-test #To remove any objects that might still be in the table space
     psql -c "DROP TABLESPACE tablespacetest" -d postgres
     sudo rm -rf /tmp/psql-tablespace
     rm -f $test_output $test_output.*
-    dropdb osm2pgsql-test
-
 }
 
 function psql_test {
@@ -71,6 +77,10 @@ function test_osm2pgsql_slim {
     psql_test "Number of nodes imported" "SELECT count(*) FROM ${dbprefix}_nodes;"
     psql_test "Number of ways imported" "SELECT count(*) FROM ${dbprefix}_ways;"
     psql_test "Number of relations imported" "SELECT count(*) FROM ${dbprefix}_rels;"
+    psql_test "Length of lines imported" "SELECT sum(ST_length(way)) FROM ${dbprefix}_line;"
+    psql_test "Length of roads imported" "SELECT sum(ST_length(way)) FROM ${dbprefix}_roads;"
+    psql_test "Area of polygons imported" "SELECT sum(ST_area(way)) FROM ${dbprefix}_polygon;"
+
 
     echo "***Testing osm2pgsql diff import with the following parameters: \"" $1 "\"***"
     ./osm2pgsql --slim --append -d osm2pgsql-test $1 $planetdiff
@@ -81,6 +91,10 @@ function test_osm2pgsql_slim {
     psql_test "Number of nodes imported" "SELECT count(*) FROM ${dbprefix}_nodes;"
     psql_test "Number of ways imported" "SELECT count(*) FROM ${dbprefix}_ways;"
     psql_test "Number of relations imported" "SELECT count(*) FROM ${dbprefix}_rels;"
+    psql_test "Length of lines imported" "SELECT sum(ST_length(way)) FROM ${dbprefix}_line;"
+    psql_test "Length of roads imported" "SELECT sum(ST_length(way)) FROM ${dbprefix}_roads;"
+    psql_test "Area of polygons imported" "SELECT sum(ST_area(way)) FROM ${dbprefix}_polygon;"
+
     compare_results
 }
 
@@ -119,26 +133,24 @@ function test_osm2pgsql_nonslim {
     psql_test "Number of lines imported" "SELECT count(*) FROM planet_osm_line;"
     psql_test "Number of roads imported" "SELECT count(*) FROM planet_osm_roads;"
     psql_test "Number of polygon imported" "SELECT count(*) FROM planet_osm_polygon;"
+    psql_test "Length of lines imported" "SELECT sum(ST_length(way)) FROM planet_osm_line;"
+    psql_test "Length of roads imported" "SELECT sum(ST_length(way)) FROM planet_osm_roads;"
+    psql_test "Area of polygons imported" "SELECT sum(ST_area(way)) FROM planet_osm_polygon;"
+
+    
     compare_results
 }
 
 
 test_osm2pgsql_nonslim "-S default.style -C 100"
-test_osm2pgsql_nonslim "-S default.style -C 100"
-echo ========== OK SO FAR =============
-test_osm2pgsql_nonslim "-S default.style -l -C 100"
 test_osm2pgsql_nonslim "--slim --drop -S default.style -C 100"
+reset_results #results depend on projection, so we have to reset them
+test_osm2pgsql_nonslim "-S default.style -l -C 100"
 reset_results
 
 echo ========== NOW DOING SLIM =============
 test_osm2pgsql_slim "-S default.style -C 100"
-test_osm2pgsql_slim "-S default.style -l -C 100"
-test_osm2pgsql_slim "-k -S default.style -C 100"
-test_osm2pgsql_slim "-j -S default.style -C 100"
-test_osm2pgsql_slim "-K -S default.style -C 100"
-test_osm2pgsql_slim "-x -S default.style -C 100"
 test_osm2pgsql_slim "-p planet_osm2 -S default.style -C 100" "planet_osm2"
-test_osm2pgsql_slim "--bbox -90.0,-180.0,90.0,180.0 -S default.style -C 100"
 test_osm2pgsql_slim "--number-processes 6 -S default.style -C 100"
 test_osm2pgsql_slim "-I -S default.style -C 100"
 test_osm2pgsql_slim "-e 16:16 -S default.style -C 100"
@@ -149,9 +161,30 @@ test_osm2pgsql_slim "-S default.style -C 100 --tablespace-main-index tablespacet
 test_osm2pgsql_slim "-S default.style -C 100 --tablespace-slim-data tablespacetest"
 test_osm2pgsql_slim "-S default.style -C 100 --tablespace-slim-index tablespacetest"
 reset_results
+test_osm2pgsql_slim "-S default.style -C 100 --tag-transform-script style.lua"
+test_osm2pgsql_slim "-S default.style -C 100 --number-processes 6 --tag-transform-script style.lua"
+reset_results #Using multi-geometry effects the number of elements in the database
+test_osm2pgsql_slim "-G -S default.style -C 100"
+reset_results #Using hsotre effects the number of elements in the database
+test_osm2pgsql_slim "-k -S default.style -C 100"
+reset_results #Using hsotre effects the number of elements in the database
+test_osm2pgsql_slim "-j -S default.style -C 100"
+test_osm2pgsql_slim "-j --number-processes 6 -S default.style -C 100"
+test_osm2pgsql_slim "-j --hstore-add-index -S default.style -C 100"
+reset_results
+test_osm2pgsql_slim "-K -S default.style -C 100"
+reset_results
+test_osm2pgsql_slim "-x -S default.style -C 100"
+reset_results
+test_osm2pgsql_slim "--bbox -90.0,-180.0,90.0,180.0 -S default.style -C 100"
+reset_results
+test_osm2pgsql_slim "-S default.style -l -C 100"
+reset_results
 
-#test_osm2pgsql_gazetteer "-C 100"
-#test_osm2pgsql_gazetteer "--bbox -90.0,-180.0,90.0,180.0 -C 100"
+echo ========== NOW DOING GAZETTEER =============
+test_osm2pgsql_gazetteer "-C 100"
+reset_results
+test_osm2pgsql_gazetteer "--bbox -90.0,-180.0,90.0,180.0 -C 100"
 
 teardown_db
 
diff --git a/tests/test_multipolygon.osm b/tests/test_multipolygon.osm
new file mode 100644
index 0000000..d379644
--- /dev/null
+++ b/tests/test_multipolygon.osm
@@ -0,0 +1,1508 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='true' generator='JOSM'>
+  <bounds minlat='-0.0142117' minlon='-0.0065596' maxlat='0.0046137' maxlon='0.0211707' origin='OpenStreetMap server' />
+  <node id='1' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0019769' lon='-4.795E-4' />
+  <node id='2' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020205' lon='-0.0018769' />
+  <node id='3' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020279' lon='0.0028363' />
+  <node id='4' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020312' lon='0.0061232' />
+  <node id='5' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020446' lon='0.0019087' />
+  <node id='6' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020446' lon='0.0050649' />
+  <node id='7' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020464' lon='-0.0036694' />
+  <node id='8' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002048' lon='0.0070977' />
+  <node id='9' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020547' lon='4.654E-4' />
+  <node id='10' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020815' lon='0.0021096' />
+  <node id='12' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00209' lon='-0.0050668' />
+  <node id='13' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0021518' lon='0.0101183' />
+  <node id='14' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0021685' lon='0.0119166' />
+  <node id='15' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022054' lon='0.0017848' />
+  <node id='16' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022087' lon='0.0011887' />
+  <node id='17' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002227' lon='-7.971E-4' />
+  <node id='18' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022288' lon='0.0014399' />
+  <node id='19' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022422' lon='0.009559' />
+  <node id='20' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022456' lon='7.031E-4' />
+  <node id='21' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022468' lon='-0.0013886' />
+  <node id='22' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022623' lon='0.0082731' />
+  <node id='23' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023282' lon='-0.0039711' />
+  <node id='24' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023481' lon='-0.0045626' />
+  <node id='25' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023561' lon='0.0103226' />
+  <node id='26' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023896' lon='0.0117223' />
+  <node id='27' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024465' lon='0.0092945' />
+  <node id='28' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024498' lon='0.0033855' />
+  <node id='29' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024632' lon='0.0088993' />
+  <node id='30' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024833' lon='0.0084774' />
+  <node id='31' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024867' lon='0.0020058' />
+  <node id='32' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0025001' lon='0.0041541' />
+  <node id='33' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0025905' lon='0.0105972' />
+  <node id='34' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026173' lon='0.0114377' />
+  <node id='35' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026399' lon='-7.931E-4' />
+  <node id='36' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026575' lon='0.0055137' />
+  <node id='37' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026756' lon='-0.0014085' />
+  <node id='38' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027144' lon='6.161E-4' />
+  <node id='39' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027345' lon='0.0061098' />
+  <node id='40' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027411' lon='-0.0039671' />
+  <node id='41' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027646' lon='0.0013327' />
+  <node id='42' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027768' lon='-0.0045825' />
+  <node id='43' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027914' lon='0.0057079' />
+  <node id='44' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027948' lon='0.0071479' />
+  <node id='45' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028182' lon='9.945E-4' />
+  <node id='46' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028216' lon='0.003198' />
+  <node id='47' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002845' lon='0.0022737' />
+  <node id='48' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002845' lon='0.0093581' />
+  <node id='49' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028701' lon='-0.0019921' />
+  <node id='50' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028785' lon='0.0016877' />
+  <node id='51' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028818' lon='0.0089495' />
+  <node id='52' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029019' lon='2.711E-4' />
+  <node id='53' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029053' lon='0.0085611' />
+  <node id='54' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029138' lon='-0.0033895' />
+  <node id='55' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029416' lon='-4.199E-4' />
+  <node id='56' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029654' lon='-0.0017261' />
+  <node id='57' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029723' lon='0.0026253' />
+  <node id='58' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029823' lon='0.0061935' />
+  <node id='59' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030091' lon='0.0105436' />
+  <node id='60' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030091' lon='0.011421' />
+  <node id='61' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030111' lon='-0.0036098' />
+  <node id='62' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030325' lon='0.0018819' />
+  <node id='63' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030349' lon='-0.004916' />
+  <node id='64' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030861' lon='0.00471' />
+  <node id='65' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030861' lon='0.0073354' />
+  <node id='66' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031441' lon='-1.4E-4' />
+  <node id='67' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003152' lon='-0.0022938' />
+  <node id='68' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031564' lon='0.0102857' />
+  <node id='69' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031719' lon='-0.0028853' />
+  <node id='70' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031877' lon='-0.0015375' />
+  <node id='71' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032301' lon='0.0116822' />
+  <node id='72' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032335' lon='0.0033654' />
+  <node id='73' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032402' lon='0.0095992' />
+  <node id='74' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032937' lon='0.0021967' />
+  <node id='75' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033004' lon='0.0048439' />
+  <node id='76' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033272' lon='0.0100848' />
+  <node id='77' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033306' lon='0.0083367' />
+  <node id='78' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033507' lon='0.0017915' />
+  <node id='79' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033574' lon='0.0118463' />
+  <node id='80' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033942' lon='-4.576E-4' />
+  <node id='81' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003414' lon='-0.0010492' />
+  <node id='82' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034444' lon='0.0031946' />
+  <node id='83' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034511' lon='0.0025048' />
+  <node id='84' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034578' lon='0.0059624' />
+  <node id='85' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034746' lon='0.0116788' />
+  <node id='86' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035114' lon='0.009636' />
+  <node id='87' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035181' lon='0.0101451' />
+  <node id='88' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035649' lon='-0.0022898' />
+  <node id='89' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035717' lon='0.0016475' />
+  <node id='90' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035851' lon='3.08E-4' />
+  <node id='91' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035918' lon='0.0083535' />
+  <node id='92' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0036006' lon='-0.0029052' />
+  <node id='93' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003642' lon='0.0115114' />
+  <node id='94' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0036688' lon='0.0103125' />
+  <node id='95' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037123' lon='9.007E-4' />
+  <node id='96' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037425' lon='0.0063978' />
+  <node id='97' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037559' lon='0.0094284' />
+  <node id='98' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038071' lon='-4.537E-4' />
+  <node id='99' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038195' lon='0.0086917' />
+  <node id='100' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038195' lon='0.0113473' />
+  <node id='101' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038295' lon='0.0105168' />
+  <node id='102' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038349' lon='-0.0019325' />
+  <node id='103' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038428' lon='-0.001069' />
+  <node id='104' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038496' lon='0.0024746' />
+  <node id='105' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038587' lon='-0.0032386' />
+  <node id='106' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003863' lon='0.0031846' />
+  <node id='107' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038798' lon='0.0105101' />
+  <node id='108' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039099' lon='0.0073254' />
+  <node id='109' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00392' lon='0.0050515' />
+  <node id='110' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039233' lon='0.0106239' />
+  <node id='111' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039267' lon='0.0092811' />
+  <node id='112' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00393' lon='0.0112301' />
+  <node id='113' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039367' lon='0.0089228' />
+  <node id='114' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039735' lon='0.002267' />
+  <node id='115' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039869' lon='0.0034826' />
+  <node id='116' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039936' lon='0.002036' />
+  <node id='117' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003997' lon='0.0015805' />
+  <node id='118' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003997' lon='0.0107412' />
+  <node id='119' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040037' lon='0.0111564' />
+  <node id='120' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040204' lon='9.309E-4' />
+  <node id='121' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040373' lon='-0.0029806' />
+  <node id='122' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040606' lon='0.0108416' />
+  <node id='123' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040774' lon='0.011076' />
+  <node id='124' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004081' lon='-0.004378' />
+  <node id='125' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041042' lon='0.0023675' />
+  <node id='126' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041088' lon='-8.05E-5' />
+  <node id='127' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041326' lon='-0.0013866' />
+  <node id='128' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004151' lon='0.0053529' />
+  <node id='129' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041577' lon='0.0016408' />
+  <node id='130' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041711' lon='0.010845' />
+  <node id='131' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041812' lon='0.0045492' />
+  <node id='132' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041912' lon='0.0092442' />
+  <node id='133' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041912' lon='0.0110559' />
+  <node id='134' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042013' lon='0.0088859' />
+  <node id='135' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042247' lon='0.0107646' />
+  <node id='136' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042314' lon='6.127E-4' />
+  <node id='137' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042415' lon='0.0111497' />
+  <node id='138' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042716' lon='0.0106608' />
+  <node id='139' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043064' lon='-0.0012852' />
+  <node id='140' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043118' lon='0.0087084' />
+  <node id='141' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043185' lon='0.0094452' />
+  <node id='142' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043185' lon='0.0112435' />
+  <node id='143' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043192' lon='-0.0032823' />
+  <node id='144' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043352' lon='0.0105235' />
+  <node id='145' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004339' lon='-0.0038738' />
+  <node id='146' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043501' lon='-0.0026826' />
+  <node id='147' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043553' lon='0.0046028' />
+  <node id='148' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043553' lon='0.0048071' />
+  <node id='149' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044089' lon='0.0113406' />
+  <node id='150' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004439' lon='0.0103226' />
+  <node id='151' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044424' lon='0.0054099' />
+  <node id='152' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044524' lon='0.0042311' />
+  <node id='153' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044558' lon='0.0051855' />
+  <node id='154' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045228' lon='0.0097767' />
+  <node id='155' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045261' lon='0.0029167' />
+  <node id='156' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045261' lon='0.0044822' />
+  <node id='157' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045294' lon='0.0049511' />
+  <node id='158' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045395' lon='0.0115348' />
+  <node id='159' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045629' lon='0.001537' />
+  <node id='160' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045663' lon='0.0101183' />
+  <node id='161' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045864' lon='0.0084439' />
+  <node id='162' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045883' lon='-0.0015869' />
+  <node id='163' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045897' lon='0.005651' />
+  <node id='164' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046082' lon='-0.0021784' />
+  <node id='165' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046467' lon='0.0050616' />
+  <node id='166' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046534' lon='0.0048037' />
+  <node id='167' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046634' lon='0.0054634' />
+  <node id='168' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046868' lon='0.0116889' />
+  <node id='169' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047237' lon='0.0045325' />
+  <node id='170' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047321' lon='-0.0032783' />
+  <node id='171' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047678' lon='-0.0038937' />
+  <node id='172' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048275' lon='0.0052726' />
+  <node id='173' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048375' lon='0.0050951' />
+  <node id='174' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048576' lon='0.0043182' />
+  <node id='175' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048978' lon='0.0027292' />
+  <node id='176' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0049213' lon='0.0018049' />
+  <node id='177' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0049916' lon='0.0054501' />
+  <node id='178' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050012' lon='-0.0015829' />
+  <node id='179' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.005002' lon='-0.002921' />
+  <node id='180' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050117' lon='0.0046698' />
+  <node id='181' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050259' lon='-0.0042272' />
+  <node id='182' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050369' lon='-0.0021983' />
+  <node id='183' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050485' lon='0.0021565' />
+  <node id='184' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0052711' lon='-0.0012256' />
+  <node id='185' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.005295' lon='-0.0025318' />
+  <node id='186' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.534E-4' lon='0.0051708' />
+  <node id='187' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.534E-4' lon='0.005727' />
+  <node id='188' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.931E-4' lon='0.007316' />
+  <node id='189' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0010196' lon='0.0039261' />
+  <node id='190' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0016817' lon='0.0038202' />
+  <node id='191' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0016817' lon='0.0051046' />
+  <node id='192' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0018009' lon='0.0070246' />
+  <node id='193' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0018141' lon='0.005674' />
+  <node id='194' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022345' lon='0.0127873' />
+  <node id='195' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022532' lon='0.0154465' />
+  <node id='196' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022907' lon='0.0157742' />
+  <node id='197' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0023094' lon='0.0174034' />
+  <node id='198' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0025903' lon='0.0131806' />
+  <node id='199' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0026277' lon='0.0149596' />
+  <node id='200' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0027214' lon='0.0161581' />
+  <node id='201' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0027495' lon='0.0170476' />
+  <node id='202' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0031708' lon='0.0150345' />
+  <node id='203' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003227' lon='0.0131431' />
+  <node id='204' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0032925' lon='0.0161487' />
+  <node id='205' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0034049' lon='0.0169165' />
+  <node id='206' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0034517' lon='0.012675' />
+  <node id='207' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0035453' lon='0.0154652' />
+  <node id='208' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0036109' lon='0.0158585' />
+  <node id='209' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0037045' lon='0.0171787' />
+  <node id='210' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0038918' lon='0.0150439' />
+  <node id='211' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0039292' lon='0.016851' />
+  <node id='212' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003948' lon='0.0126937' />
+  <node id='213' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003948' lon='0.0153997' />
+  <node id='214' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0041914' lon='0.0157461' />
+  <node id='215' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042008' lon='0.016542' />
+  <node id='216' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042476' lon='0.014763' />
+  <node id='217' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042757' lon='0.0131619' />
+  <node id='218' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0046408' lon='0.0130121' />
+  <node id='219' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0046689' lon='0.0147817' />
+  <node id='220' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0047064' lon='0.0157368' />
+  <node id='221' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0047625' lon='0.0164858' />
+  <node id='222' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0048281' lon='0.0125065' />
+  <node id='223' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0049311' lon='0.0150439' />
+  <node id='224' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0049779' lon='0.0153716' />
+  <node id='225' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0050903' lon='0.0167105' />
+  <node id='226' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.005297' lon='0.0124904' />
+  <node id='227' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0053654' lon='0.0150095' />
+  <node id='228' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0056388' lon='0.0128907' />
+  <node id='229' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0057071' lon='0.0145897' />
+  <node id='230' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0060586' lon='0.01292' />
+  <node id='231' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0061465' lon='0.014492' />
+  <node id='232' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0063515' lon='0.0124611' />
+  <node id='233' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0063808' lon='0.0150291' />
+  <node id='234' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0057861' lon='-0.0011599' />
+  <node id='235' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0058028' lon='0.0050004' />
+  <node id='236' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.005826' lon='-0.0024561' />
+  <node id='237' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0058559' lon='-0.0028849' />
+  <node id='238' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0058812' lon='0.0060159' />
+  <node id='239' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0058858' lon='-3.822E-4' />
+  <node id='240' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0059058' lon='-0.0040814' />
+  <node id='241' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0059158' lon='0.0011933' />
+  <node id='242' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0059556' lon='0.0017317' />
+  <node id='243' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0060454' lon='0.0036561' />
+  <node id='244' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0061451' lon='-0.0019576' />
+  <node id='245' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0062149' lon='-0.0013892' />
+  <node id='246' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.006243' lon='0.0064403' />
+  <node id='247' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0062448' lon='-0.0036427' />
+  <node id='248' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0062747' lon='-0.0031142' />
+  <node id='249' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0063046' lon='0.0089607' />
+  <node id='250' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0063744' lon='0.007485' />
+  <node id='251' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0064718' lon='0.0042579' />
+  <node id='252' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0067234' lon='-0.0036327' />
+  <node id='253' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0067633' lon='-0.0031142' />
+  <node id='254' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0068929' lon='-0.0019975' />
+  <node id='255' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0069029' lon='0.0079238' />
+  <node id='256' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0069129' lon='0.0086317' />
+  <node id='257' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0070425' lon='-0.0040116' />
+  <node id='258' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.007079' lon='0.0041398' />
+  <node id='259' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0070824' lon='-0.0014491' />
+  <node id='260' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0071387' lon='0.0066914' />
+  <node id='261' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0071422' lon='-0.0027553' />
+  <node id='262' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0071621' lon='0.0098282' />
+  <node id='263' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.007202' lon='-0.0022268' />
+  <node id='264' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0073017' lon='-5.517E-4' />
+  <node id='265' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0073516' lon='-0.0011798' />
+  <node id='266' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0074214' lon='0.0131985' />
+  <node id='267' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0075012' lon='0.0103667' />
+  <node id='268' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0075211' lon='9.54E-4' />
+  <node id='269' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.007541' lon='0.0014625' />
+  <node id='270' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.007561' lon='0.0077842' />
+  <node id='271' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.007571' lon='-0.0039917' />
+  <node id='272' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0076009' lon='0.0065544' />
+  <node id='273' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0076308' lon='-0.0026655' />
+  <node id='274' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0076906' lon='0.0085121' />
+  <node id='275' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0077704' lon='-0.0011898' />
+  <node id='276' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0077804' lon='0.0125803' />
+  <node id='277' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0078302' lon='-0.0021869' />
+  <node id='278' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0078302' lon='0.0032274' />
+  <node id='279' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0078502' lon='-0.0036327' />
+  <node id='280' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0078801' lon='0.0103268' />
+  <node id='281' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0079199' lon='-4.52E-4' />
+  <node id='282' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0079399' lon='0.0073255' />
+  <node id='283' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0079698' lon='-0.0029647' />
+  <node id='284' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0080396' lon='0.009569' />
+  <node id='285' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0080496' lon='7.645E-4' />
+  <node id='286' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0080588' lon='0.0046807' />
+  <node id='287' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0080994' lon='0.0124606' />
+  <node id='288' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0081293' lon='0.0089508' />
+  <node id='289' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0082846' lon='0.005559' />
+  <node id='290' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0082988' lon='0.0014924' />
+  <node id='291' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0083188' lon='0.0029582' />
+  <node id='292' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0083886' lon='-0.0036228' />
+  <node id='293' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0084285' lon='0.0036163' />
+  <node id='294' timestamp='2013-08-30T00:11:06Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0084983' lon='0.0130389' />
+  <node id='295' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0085581' lon='-0.0030444' />
+  <node id='296' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0086877' lon='0.0051717' />
+  <node id='297' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0087775' lon='-0.0040017' />
+  <node id='298' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0087874' lon='-0.0021769' />
+  <node id='299' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0088173' lon='0.0072358' />
+  <node id='300' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0088373' lon='0.0091103' />
+  <node id='301' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0089071' lon='-0.0026256' />
+  <node id='302' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0089171' lon='-0.0011798' />
+  <node id='303' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.008937' lon='-6.813E-4' />
+  <node id='304' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0090367' lon='0.0099878' />
+  <node id='305' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0091264' lon='0.0011833' />
+  <node id='306' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0091564' lon='3.956E-4' />
+  <node id='307' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.009276' lon='0.0074751' />
+  <node id='308' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.009276' lon='0.0129791' />
+  <node id='309' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0094156' lon='0.0086317' />
+  <node id='310' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0095851' lon='0.0027189' />
+  <node id='311' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0095951' lon='0.0108852' />
+  <node id='312' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0096449' lon='0.0034368' />
+  <node id='313' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0097347' lon='0.0123808' />
+  <node id='314' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0099042' lon='0.0048028' />
+  <node id='315' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0099142' lon='0.0071959' />
+  <node id='316' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0100737' lon='0.0107655' />
+  <node id='317' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0100936' lon='0.0084722' />
+  <node id='318' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0102532' lon='0.006478' />
+  <node id='319' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0105324' lon='0.0120618' />
+  <node id='320' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0105922' lon='0.0089308' />
+  <node id='321' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0107119' lon='0.0100476' />
+  <node id='322' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5' lat='-0.0110309' lon='0.0126999' />
+  <node id='323' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010602168912259166' lon='0.014604380990630909' />
+  <node id='324' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010881359163824562' lon='0.016179811723581298' />
+  <node id='325' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010342920821294321' lon='0.01637923333534717' />
+  <node id='326' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010143499212715457' lon='0.015142819342398766' />
+  <node id='327' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010901301324640851' lon='0.014185595605922582' />
+  <node id='328' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.011240318058313784' lon='0.016698307914172567' />
+  <node id='329' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009904193282258823' lon='0.01693761384829161' />
+  <node id='330' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009784540316965457' lon='0.014285306411805516' />
+  <node id='331' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.008548126339863718' lon='0.014624323151807497' />
+  <node id='332' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.008588010661770935' lon='0.016179811723581298' />
+  <node id='333' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.008029630154699997' lon='0.016339349012993998' />
+  <node id='334' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.007989745832736546' lon='0.014803802602396781' />
+  <node id='335' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.008927027397812303' lon='0.014305248572982104' />
+  <node id='336' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.008946969558746297' lon='0.016817960881232087' />
+  <node id='337' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.007590902612892312' lon='0.016558712785936455' />
+  <node id='338' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.00761084477389342' lon='0.014225479928275758' />
+  <node id='339' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010043788408379788' lon='-0.0017481911741705812' />
+  <node id='340' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010063730569249365' lon='-0.001209752822402728' />
+  <node id='341' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009784540316965457' lon='-0.001149926338872966' />
+  <node id='342' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009784540316965457' lon='-0.001708306851817407' />
+  <node id='343' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010342920821294321' lon='-0.002147034397702325' />
+  <node id='344' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010342920821294321' lon='-0.001030273371813443' />
+  <node id='345' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009525292225350803' lon='-8.109095988709837E-4' />
+  <node id='346' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.00946546574264261' lon='-0.0020074392694662147' />
+  <node id='347' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.00996401976488934' lon='-0.003722465130652713' />
+  <node id='348' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010023846247508995' lon='-0.002944720844765814' />
+  <node id='349' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009704771673412807' lon='-0.002904836522412638' />
+  <node id='350' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009664887351629419' lon='-0.003562927841240015' />
+  <node id='351' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010263152177877675' lon='-0.004041539709478108' />
+  <node id='352' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.010283094338733707' lon='-0.002665530588293592' />
+  <node id='353' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009425581420831412' lon='-0.0025857619435872437' />
+  <node id='354' timestamp='2013-09-21T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='9' lat='-0.009365754938106057' lon='-0.004001655387124934' />
+  <way id='1' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='12' />
+    <nd ref='7' />
+    <nd ref='61' />
+    <nd ref='63' />
+    <nd ref='12' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way' />
+  </way>
+  <way id='2' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='146' />
+    <nd ref='139' />
+    <nd ref='184' />
+    <nd ref='185' />
+    <nd ref='146' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way16' />
+  </way>
+  <way id='3' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='2' />
+    <nd ref='1' />
+    <nd ref='55' />
+    <nd ref='56' />
+    <nd ref='2' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way2' />
+  </way>
+  <way id='4' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='21' />
+    <nd ref='17' />
+    <nd ref='35' />
+    <nd ref='37' />
+    <nd ref='21' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_way3' />
+  </way>
+  <way id='5' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='81' />
+    <nd ref='80' />
+    <nd ref='98' />
+    <nd ref='103' />
+    <nd ref='81' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_way4' />
+  </way>
+  <way id='6' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='145' />
+    <nd ref='143' />
+    <nd ref='170' />
+    <nd ref='171' />
+    <nd ref='145' />
+    <tag k='highway' v='residential' />
+    <tag k='name' v='Name_way6' />
+  </way>
+  <way id='7' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='9' />
+    <nd ref='5' />
+    <nd ref='62' />
+    <nd ref='52' />
+    <nd ref='9' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way7' />
+  </way>
+  <way id='8' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='22' />
+    <nd ref='19' />
+    <nd ref='73' />
+    <nd ref='77' />
+    <nd ref='22' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way8' />
+  </way>
+  <way id='9' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='166' />
+    <nd ref='169' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='10' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='156' />
+    <nd ref='147' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='11' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='148' />
+    <nd ref='157' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='12' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='157' />
+    <nd ref='166' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='13' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='169' />
+    <nd ref='156' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='14' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='148' />
+    <nd ref='147' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='15' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='164' />
+    <nd ref='162' />
+    <nd ref='178' />
+    <nd ref='182' />
+    <nd ref='164' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='16' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='165' />
+    <nd ref='153' />
+  </way>
+  <way id='17' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='60' />
+    <nd ref='59' />
+  </way>
+  <way id='18' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='125' />
+    <nd ref='155' />
+  </way>
+  <way id='19' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='159' />
+    <nd ref='129' />
+  </way>
+  <way id='20' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='155' />
+    <nd ref='175' />
+  </way>
+  <way id='21' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='47' />
+    <nd ref='31' />
+  </way>
+  <way id='22' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='173' />
+    <nd ref='165' />
+  </way>
+  <way id='23' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='59' />
+    <nd ref='33' />
+  </way>
+  <way id='24' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='129' />
+    <nd ref='125' />
+  </way>
+  <way id='25' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='175' />
+    <nd ref='183' />
+  </way>
+  <way id='26' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='31' />
+    <nd ref='10' />
+  </way>
+  <way id='27' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='57' />
+    <nd ref='47' />
+  </way>
+  <way id='28' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='172' />
+    <nd ref='167' />
+  </way>
+  <way id='29' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='131' />
+    <nd ref='128' />
+  </way>
+  <way id='30' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='10' />
+    <nd ref='3' />
+  </way>
+  <way id='31' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='152' />
+    <nd ref='131' />
+  </way>
+  <way id='32' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='159' />
+    <nd ref='176' />
+  </way>
+  <way id='33' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='172' />
+    <nd ref='173' />
+  </way>
+  <way id='34' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='28' />
+    <nd ref='46' />
+  </way>
+  <way id='35' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='163' />
+    <nd ref='177' />
+  </way>
+  <way id='36' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='46' />
+    <nd ref='57' />
+  </way>
+  <way id='37' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='151' />
+    <nd ref='167' />
+  </way>
+  <way id='38' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='177' />
+    <nd ref='180' />
+  </way>
+  <way id='39' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='183' />
+    <nd ref='176' />
+  </way>
+  <way id='40' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='163' />
+    <nd ref='128' />
+  </way>
+  <way id='41' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='153' />
+    <nd ref='151' />
+  </way>
+  <way id='42' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='174' />
+    <nd ref='152' />
+  </way>
+  <way id='43' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='3' />
+    <nd ref='28' />
+  </way>
+  <way id='44' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='180' />
+    <nd ref='174' />
+  </way>
+  <way id='45' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='14' />
+    <nd ref='79' />
+    <nd ref='76' />
+  </way>
+  <way id='46' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='114' />
+    <nd ref='115' />
+    <nd ref='72' />
+  </way>
+  <way id='47' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='96' />
+    <nd ref='58' />
+    <nd ref='65' />
+  </way>
+  <way id='48' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='39' />
+    <nd ref='4' />
+    <nd ref='8' />
+  </way>
+  <way id='49' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='68' />
+    <nd ref='25' />
+    <nd ref='26' />
+  </way>
+  <way id='50' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='114' />
+    <nd ref='74' />
+    <nd ref='72' />
+  </way>
+  <way id='51' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='65' />
+    <nd ref='108' />
+    <nd ref='96' />
+  </way>
+  <way id='52' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='8' />
+    <nd ref='44' />
+    <nd ref='39' />
+  </way>
+  <way id='53' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='78' />
+    <nd ref='116' />
+    <nd ref='136' />
+  </way>
+  <way id='54' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='136' />
+    <nd ref='90' />
+    <nd ref='78' />
+  </way>
+  <way id='55' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='26' />
+    <nd ref='71' />
+    <nd ref='68' />
+  </way>
+  <way id='56' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='76' />
+    <nd ref='13' />
+    <nd ref='14' />
+  </way>
+  <way id='57' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='33' />
+    <nd ref='34' />
+    <nd ref='60' />
+  </way>
+  <way id='58' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='91' />
+    <nd ref='86' />
+    <nd ref='154' />
+    <nd ref='161' />
+    <nd ref='91' />
+  </way>
+  <way id='59' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='87' />
+    <nd ref='85' />
+    <nd ref='168' />
+    <nd ref='160' />
+    <nd ref='87' />
+  </way>
+  <way id='60' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='18' />
+    <nd ref='15' />
+    <nd ref='50' />
+    <nd ref='41' />
+    <nd ref='18' />
+  </way>
+  <way id='61' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='94' />
+    <nd ref='93' />
+    <nd ref='158' />
+    <nd ref='150' />
+    <nd ref='94' />
+  </way>
+  <way id='62' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='24' />
+    <nd ref='23' />
+    <nd ref='40' />
+    <nd ref='42' />
+    <nd ref='24' />
+  </way>
+  <way id='63' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='95' />
+    <nd ref='89' />
+    <nd ref='117' />
+    <nd ref='120' />
+    <nd ref='95' />
+  </way>
+  <way id='64' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='27' />
+    <nd ref='29' />
+    <nd ref='51' />
+    <nd ref='48' />
+    <nd ref='27' />
+  </way>
+  <way id='65' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='70' />
+    <nd ref='66' />
+    <nd ref='126' />
+    <nd ref='127' />
+    <nd ref='70' />
+  </way>
+  <way id='66' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='124' />
+    <nd ref='121' />
+    <nd ref='179' />
+    <nd ref='181' />
+    <nd ref='124' />
+  </way>
+  <way id='67' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='99' />
+    <nd ref='97' />
+    <nd ref='141' />
+    <nd ref='140' />
+    <nd ref='99' />
+  </way>
+  <way id='68' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='118' />
+    <nd ref='119' />
+    <nd ref='137' />
+    <nd ref='135' />
+    <nd ref='118' />
+  </way>
+  <way id='69' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='113' />
+    <nd ref='111' />
+    <nd ref='132' />
+    <nd ref='134' />
+    <nd ref='113' />
+  </way>
+  <way id='70' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='75' />
+    <nd ref='43' />
+    <nd ref='84' />
+    <nd ref='109' />
+    <nd ref='75' />
+  </way>
+  <way id='71' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='54' />
+    <nd ref='49' />
+    <nd ref='102' />
+    <nd ref='105' />
+    <nd ref='54' />
+  </way>
+  <way id='72' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='20' />
+    <nd ref='16' />
+    <nd ref='45' />
+    <nd ref='38' />
+    <nd ref='20' />
+  </way>
+  <way id='73' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='30' />
+    <nd ref='29' />
+    <nd ref='51' />
+    <nd ref='53' />
+    <nd ref='30' />
+  </way>
+  <way id='74' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='69' />
+    <nd ref='67' />
+    <nd ref='88' />
+    <nd ref='92' />
+    <nd ref='69' />
+  </way>
+  <way id='75' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='110' />
+    <nd ref='112' />
+    <nd ref='142' />
+    <nd ref='138' />
+    <nd ref='110' />
+  </way>
+  <way id='76' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='83' />
+    <nd ref='82' />
+    <nd ref='106' />
+    <nd ref='104' />
+    <nd ref='83' />
+  </way>
+  <way id='77' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='122' />
+    <nd ref='123' />
+    <nd ref='133' />
+    <nd ref='130' />
+    <nd ref='122' />
+  </way>
+  <way id='78' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='32' />
+    <nd ref='6' />
+    <nd ref='36' />
+    <nd ref='64' />
+    <nd ref='32' />
+  </way>
+  <way id='79' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='101' />
+    <nd ref='100' />
+    <nd ref='149' />
+    <nd ref='144' />
+    <nd ref='107' />
+    <nd ref='101' />
+  </way>
+  <way id='80' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <nd ref='187' />
+    <nd ref='188' />
+    <nd ref='192' />
+    <nd ref='193' />
+    <nd ref='187' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='81' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <nd ref='189' />
+    <nd ref='186' />
+    <nd ref='191' />
+    <nd ref='190' />
+    <nd ref='189' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='82' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='194' />
+    <nd ref='195' />
+    <nd ref='207' />
+    <nd ref='206' />
+    <nd ref='194' />
+    <tag k='landuse' v='vineyard' />
+  </way>
+  <way id='83' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='196' />
+    <nd ref='197' />
+    <nd ref='209' />
+    <nd ref='208' />
+    <nd ref='196' />
+    <tag k='landuse' v='farmland' />
+  </way>
+  <way id='84' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='212' />
+    <nd ref='210' />
+    <nd ref='223' />
+    <nd ref='222' />
+    <nd ref='212' />
+    <tag k='landuse' v='vineyard' />
+  </way>
+  <way id='85' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='213' />
+    <nd ref='211' />
+    <nd ref='225' />
+    <nd ref='224' />
+    <nd ref='213' />
+    <tag k='landuse' v='vineyard' />
+    <tag k='name' v='unique-relation-way-tag-name' />
+  </way>
+  <way id='86' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='198' />
+    <nd ref='199' />
+    <nd ref='202' />
+    <nd ref='203' />
+    <nd ref='198' />
+  </way>
+  <way id='87' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='200' />
+    <nd ref='201' />
+    <nd ref='205' />
+    <nd ref='204' />
+    <nd ref='200' />
+  </way>
+  <way id='88' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='217' />
+    <nd ref='216' />
+    <nd ref='219' />
+    <nd ref='218' />
+    <nd ref='217' />
+  </way>
+  <way id='89' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='214' />
+    <nd ref='215' />
+    <nd ref='221' />
+    <nd ref='220' />
+    <nd ref='214' />
+  </way>
+  <way id='90' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4'>
+    <nd ref='226' />
+    <nd ref='227' />
+    <nd ref='233' />
+    <nd ref='232' />
+    <nd ref='226' />
+    <tag k='landuse' v='farmland' />
+  </way>
+  <way id='91' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4'>
+    <nd ref='228' />
+    <nd ref='229' />
+    <nd ref='231' />
+    <nd ref='230' />
+    <nd ref='228' />
+  </way>
+  <way id='92' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='260' />
+    <nd ref='272' />
+  </way>
+  <way id='93' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='272' />
+    <nd ref='289' />
+  </way>
+  <way id='94' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='258' />
+    <nd ref='251' />
+  </way>
+  <way id='95' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='246' />
+    <nd ref='260' />
+  </way>
+  <way id='96' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='238' />
+    <nd ref='246' />
+  </way>
+  <way id='97' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='251' />
+    <nd ref='235' />
+  </way>
+  <way id='98' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='289' />
+    <nd ref='286' />
+  </way>
+  <way id='99' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='286' />
+    <nd ref='258' />
+  </way>
+  <way id='100' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='235' />
+    <nd ref='238' />
+  </way>
+  <way id='101' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='244' />
+    <nd ref='245' />
+    <nd ref='259' />
+    <nd ref='254' />
+    <nd ref='244' />
+  </way>
+  <way id='102' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='277' />
+    <nd ref='275' />
+    <nd ref='302' />
+    <nd ref='298' />
+    <nd ref='277' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='103' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='293' />
+    <nd ref='296' />
+    <nd ref='314' />
+    <nd ref='312' />
+    <nd ref='293' />
+    <tag k='natural' v='heath' />
+  </way>
+  <way id='104' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='242' />
+    <nd ref='243' />
+    <nd ref='278' />
+    <nd ref='269' />
+    <nd ref='242' />
+  </way>
+  <way id='105' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='271' />
+    <nd ref='273' />
+    <nd ref='301' />
+    <nd ref='297' />
+    <nd ref='271' />
+  </way>
+  <way id='106' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='250' />
+    <nd ref='249' />
+    <nd ref='288' />
+    <nd ref='282' />
+    <nd ref='250' />
+  </way>
+  <way id='107' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='281' />
+    <nd ref='285' />
+    <nd ref='306' />
+    <nd ref='303' />
+    <nd ref='281' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='108' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='307' />
+    <nd ref='309' />
+    <nd ref='317' />
+    <nd ref='315' />
+    <nd ref='307' />
+  </way>
+  <way id='109' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='239' />
+    <nd ref='241' />
+    <nd ref='268' />
+    <nd ref='264' />
+    <nd ref='239' />
+  </way>
+  <way id='110' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='290' />
+    <nd ref='291' />
+    <nd ref='310' />
+    <nd ref='305' />
+    <nd ref='290' />
+    <tag k='natural' v='heath' />
+  </way>
+  <way id='111' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='255' />
+    <nd ref='256' />
+    <nd ref='274' />
+    <nd ref='270' />
+    <nd ref='255' />
+  </way>
+  <way id='112' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='267' />
+    <nd ref='276' />
+    <nd ref='287' />
+    <nd ref='280' />
+    <nd ref='267' />
+    <tag k='natural' v='heath' />
+  </way>
+  <way id='113' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='240' />
+    <nd ref='237' />
+    <nd ref='261' />
+    <nd ref='257' />
+    <nd ref='240' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='114' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='236' />
+    <nd ref='234' />
+    <nd ref='265' />
+    <nd ref='263' />
+    <nd ref='236' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='115' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='311' />
+    <nd ref='313' />
+    <nd ref='319' />
+    <nd ref='316' />
+    <nd ref='311' />
+  </way>
+  <way id='116' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='299' />
+    <nd ref='300' />
+    <nd ref='320' />
+    <nd ref='318' />
+    <nd ref='299' />
+  </way>
+  <way id='117' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='279' />
+    <nd ref='283' />
+    <nd ref='295' />
+    <nd ref='292' />
+    <nd ref='279' />
+  </way>
+  <way id='118' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='247' />
+    <nd ref='248' />
+    <nd ref='253' />
+    <nd ref='252' />
+    <nd ref='247' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='119' timestamp='2013-08-30T00:11:07Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='304' />
+    <nd ref='308' />
+    <nd ref='322' />
+    <nd ref='321' />
+    <nd ref='304' />
+    <tag k='natural' v='heath' />
+  </way>
+  <way id='120' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='262' />
+    <nd ref='266' />
+    <nd ref='294' />
+    <nd ref='284' />
+    <nd ref='262' />
+    <tag k='natural' v='heath' />
+  </way>
+  <way id='121' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='323' />
+    <nd ref='326' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='122' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='324' />
+    <nd ref='323' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='123' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='325' />
+    <nd ref='324' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='124' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='327' />
+    <nd ref='330' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='125' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='328' />
+    <nd ref='327' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='126' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='329' />
+    <nd ref='328' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='127' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='326' />
+    <nd ref='325' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='128' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='330' />
+    <nd ref='329' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='129' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='331' />
+    <nd ref='334' />
+  </way>
+  <way id='130' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='332' />
+    <nd ref='331' />
+  </way>
+  <way id='131' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='333' />
+    <nd ref='332' />
+  </way>
+  <way id='132' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='335' />
+    <nd ref='338' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='133' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='336' />
+    <nd ref='335' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='134' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='337' />
+    <nd ref='336' />
+    <tag k='natural' v='water' />
+  </way>
+  <way id='135' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='334' />
+    <nd ref='333' />
+  </way>
+  <way id='136' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <nd ref='338' />
+    <nd ref='337' />
+    <tag k='man_made' v='pier' />
+    <tag k='natural' v='water' />
+  </way>
+    <way id='137' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <nd ref='342' />
+    <nd ref='341' />
+    <nd ref='340' />
+    <nd ref='339' />
+    <nd ref='342' />
+    <tag k='landuse' v='forest' />
+  </way>
+  <way id='138'  timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <nd ref='346' />
+    <nd ref='345' />
+    <nd ref='344' />
+    <nd ref='343' />
+    <nd ref='346' />
+    <tag k='landuse' v='forest' />
+  </way>
+  <way id='139'  timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <nd ref='350' />
+    <nd ref='349' />
+    <nd ref='348' />
+    <nd ref='347' />
+    <nd ref='350' />
+    <tag k='landuse' v='forest' />
+  </way>
+  <way id='140' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <nd ref='354' />
+    <nd ref='353' />
+    <nd ref='352' />
+    <nd ref='351' />
+    <nd ref='354' />
+    <tag k='landuse' v='forest' />
+  </way>
+  <relation id='1' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='71' role='outer' />
+    <member type='way' ref='74' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='2' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='52' role='outer' />
+    <member type='way' ref='48' role='outer' />
+    <member type='way' ref='47' role='outer' />
+    <member type='way' ref='51' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel10' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='3' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='29' role='outer' />
+    <member type='way' ref='40' role='outer' />
+    <member type='way' ref='35' role='outer' />
+    <member type='way' ref='38' role='outer' />
+    <member type='way' ref='44' role='outer' />
+    <member type='way' ref='42' role='outer' />
+    <member type='way' ref='31' role='outer' />
+    <member type='way' ref='9' role='inner' />
+    <member type='way' ref='13' role='inner' />
+    <member type='way' ref='10' role='inner' />
+    <member type='way' ref='14' role='inner' />
+    <member type='way' ref='11' role='inner' />
+    <member type='way' ref='12' role='inner' />
+    <member type='way' ref='16' role='inner' />
+    <member type='way' ref='41' role='inner' />
+    <member type='way' ref='37' role='inner' />
+    <member type='way' ref='28' role='inner' />
+    <member type='way' ref='33' role='inner' />
+    <member type='way' ref='22' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel11' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='4' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='69' role='outer' />
+    <member type='way' ref='58' role='outer' />
+    <member type='way' ref='67' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel12' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='5' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='41' role='outer' />
+    <member type='way' ref='37' role='outer' />
+    <member type='way' ref='28' role='outer' />
+    <member type='way' ref='33' role='outer' />
+    <member type='way' ref='22' role='outer' />
+    <member type='way' ref='16' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel12' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='6' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='68' role='outer' />
+    <member type='way' ref='79' role='outer' />
+    <member type='way' ref='59' role='outer' />
+    <member type='way' ref='77' role='inner' />
+    <member type='way' ref='75' role='inner' />
+    <member type='way' ref='61' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel13' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='7' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='17' role='outer' />
+    <member type='way' ref='23' role='outer' />
+    <member type='way' ref='57' role='outer' />
+    <member type='way' ref='45' role='outer' />
+    <member type='way' ref='56' role='outer' />
+    <member type='way' ref='49' role='inner' />
+    <member type='way' ref='55' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel15' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='8' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='65' role='outer' />
+    <member type='way' ref='5' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel2' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='9' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='54' role='outer' />
+    <member type='way' ref='53' role='outer' />
+    <member type='way' ref='63' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel3' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='10' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='50' role='outer' />
+    <member type='way' ref='46' role='outer' />
+    <member type='way' ref='76' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel4' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='11' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='30' role='outer' />
+    <member type='way' ref='43' role='outer' />
+    <member type='way' ref='34' role='outer' />
+    <member type='way' ref='36' role='outer' />
+    <member type='way' ref='27' role='outer' />
+    <member type='way' ref='21' role='outer' />
+    <member type='way' ref='26' role='outer' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel6' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='12' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='25' role='outer' />
+    <member type='way' ref='32' role='outer' />
+    <member type='way' ref='39' role='outer' />
+    <member type='way' ref='20' role='outer' />
+    <member type='way' ref='19' role='outer' />
+    <member type='way' ref='18' role='outer' />
+    <member type='way' ref='24' role='outer' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel8' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='13' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='70' role='outer' />
+    <member type='way' ref='78' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel9' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='14' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='66' role='outer' />
+    <member type='way' ref='6' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way5' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='15' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='1' role='outer' />
+    <member type='way' ref='62' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='16' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='3' role='outer' />
+    <member type='way' ref='4' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='17' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='2' role='outer' />
+    <member type='way' ref='15' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='18' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='7' role='outer' />
+    <member type='way' ref='60' role='inner' />
+    <member type='way' ref='72' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='19' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='8' role='outer' />
+    <member type='way' ref='64' role='inner' />
+    <member type='way' ref='73' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='20' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <member type='way' ref='80' role='outer' />
+    <member type='way' ref='81' role='outer' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='21' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <member type='way' ref='82' role='outer' />
+    <member type='way' ref='86' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='22' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='84' role='outer' />
+    <member type='way' ref='88' role='inner' />
+    <tag k='fixme' v='this is a random fixme' />
+    <tag k='name' v='rel name something' />
+    <tag k='note' v='this is a random note' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='23' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='85' role='outer' />
+    <member type='way' ref='89' role='inner' />
+    <tag k='fixme' v='this is a random fixme' />
+    <tag k='note' v='this is a random note' />
+    <tag k='random_tag' v='this is a random random_tag' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='24' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='83' role='outer' />
+    <member type='way' ref='87' role='inner' />
+    <tag k='natural' v='water' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='25' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4'>
+    <member type='way' ref='90' role='outer' />
+    <member type='way' ref='91' role='inner' />
+    <tag k='brand' v='my brand' />
+    <tag k='name' v='my name' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='26' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='106' role='outer' />
+    <member type='way' ref='111' role='inner' />
+    <tag k='natural' v='heath' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='27' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='116' role='outer' />
+    <member type='way' ref='108' role='inner' />
+    <tag k='natural' v='heath' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='28' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='105' role='outer' />
+    <member type='way' ref='117' role='inner' />
+    <tag k='natural' v='water' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='29' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='104' role='outer' />
+    <member type='way' ref='109' role='outer' />
+    <tag k='natural' v='water' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='30' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='92' role='outer' />
+    <member type='way' ref='93' role='outer' />
+    <member type='way' ref='98' role='outer' />
+    <member type='way' ref='99' role='outer' />
+    <member type='way' ref='94' role='outer' />
+    <member type='way' ref='97' role='outer' />
+    <member type='way' ref='100' role='outer' />
+    <member type='way' ref='96' role='outer' />
+    <member type='way' ref='95' role='outer' />
+    <tag k='natural' v='water' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='31' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='120' role='outer' />
+    <member type='way' ref='112' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='32' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='103' role='outer' />
+    <member type='way' ref='110' role='outer' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='33' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='114' role='outer' />
+    <member type='way' ref='101' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='34' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='113' role='outer' />
+    <member type='way' ref='118' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='35' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='107' role='outer' />
+    <member type='way' ref='102' role='outer' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='36' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='119' role='outer' />
+    <member type='way' ref='115' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='37' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <member type='way' ref='128' role='outer' />
+    <member type='way' ref='126' role='outer' />
+    <member type='way' ref='125' role='outer' />
+    <member type='way' ref='124' role='outer' />
+    <member type='way' ref='127' role='inner' />
+    <member type='way' ref='123' role='inner' />
+    <member type='way' ref='122' role='inner' />
+    <member type='way' ref='121' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='38' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+    <member type='way' ref='136' role='outer' />
+    <member type='way' ref='134' role='outer' />
+    <member type='way' ref='133' role='outer' />
+    <member type='way' ref='132' role='outer' />
+    <member type='way' ref='135' role='inner' />
+    <member type='way' ref='131' role='inner' />
+    <member type='way' ref='130' role='inner' />
+    <member type='way' ref='129' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='39' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <member type='way' ref='138' role='outer' />
+    <member type='way' ref='137' role='inner' />
+    <tag k='landuse' v='forest' />
+    <tag k='name' v='relation_name' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='40' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='9'>
+    <member type='way' ref='140' role='outer' />
+    <member type='way' ref='139' role='inner' />
+    <tag k='landuse' v='forest' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+
+</osm>
diff --git a/tests/test_multipolygon_diff.osc b/tests/test_multipolygon_diff.osc
new file mode 100644
index 0000000..1f35612
--- /dev/null
+++ b/tests/test_multipolygon_diff.osc
@@ -0,0 +1,193 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osmChange version="0.6" generator="Osmosis 0.40.1">
+  <modify>
+    <node id="7" version="2" timestamp="2013-08-07T15:58:06Z" uid="5" user="Test123" changeset="1" lat="-0.0010452" lon="-0.0031759"/>
+    <node id="88" version="2" timestamp="2013-08-07T15:58:07Z" uid="5" user="Test123" changeset="1" lat="-0.0034521" lon="-0.0025154"/>
+  </modify>
+  <create>
+    <node id="110739" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0117967" lon="0.0073064"/>
+    <node id="110737" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.011878" lon="0.0082495"/>
+    <node id="110735" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0113739" lon="0.0083145"/>
+    <node id="110734" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0111951" lon="0.0072739"/>
+    <node id="110730" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.011943" lon="0.0068349"/>
+    <node id="110728" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0124308" lon="0.0088023"/>
+    <node id="110726" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0110162" lon="0.0088673"/>
+    <node id="110725" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5" lat="-0.0108536" lon="0.0067049"/>
+  </create>
+  <modify>
+    <way id="15" version="1" timestamp="2013-08-07T15:58:09Z" uid="5" user="Test123" changeset="1">
+      <nd ref="182"/>
+      <nd ref="164"/>
+      <nd ref="162"/>
+      <tag k="landuse" v="residential"/>
+    </way>
+    <way id="66" version="1" timestamp="2013-08-07T15:58:10Z" uid="5" user="Test123" changeset="1">
+      <nd ref="181"/>
+      <nd ref="124"/>
+      <nd ref="121"/>
+    </way>
+  </modify>
+  <delete>
+    <way id="97" version="1" timestamp="2013-08-30T00:51:24Z" uid="5" user="Test123" changeset="5">
+      <nd ref="251"/>
+      <nd ref="235"/>
+    </way>
+  </delete>
+  <modify>
+    <way id="100" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5">
+      <nd ref="251"/>
+      <nd ref="235"/>
+      <nd ref="238"/>
+    </way>
+  </modify>
+  <delete>
+    <way id="104" version="1" timestamp="2013-08-30T00:51:24Z" uid="5" user="Test123" changeset="5">
+      <nd ref="242"/>
+      <nd ref="243"/>
+      <nd ref="278"/>
+      <nd ref="269"/>
+      <nd ref="242"/>
+    </way>
+  </delete>
+  <modify>
+    <way id="106" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5">
+      <nd ref="250"/>
+      <nd ref="249"/>
+      <nd ref="288"/>
+      <nd ref="282"/>
+      <nd ref="250"/>
+      <tag k="landuse" v="farmland"/>
+    </way>
+    <way id="113" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5">
+      <nd ref="240"/>
+      <nd ref="237"/>
+      <nd ref="261"/>
+      <nd ref="257"/>
+      <nd ref="240"/>
+      <tag k="landuse" v="farmland"/>
+    </way>
+    <way id="114" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5">
+      <nd ref="236"/>
+      <nd ref="234"/>
+      <nd ref="265"/>
+      <nd ref="263"/>
+      <nd ref="236"/>
+      <tag k="landuse" v="cemetery"/>
+    </way>
+    <way id="119" version="1" timestamp="2013-08-30T00:11:07Z" uid="5" user="Test123" changeset="5">
+      <nd ref="304"/>
+      <nd ref="308"/>
+      <nd ref="322"/>
+      <nd ref="321"/>
+      <nd ref="304"/>
+    </way>
+    <way id='120' timestamp='2013-08-30T00:11:08Z' uid='5' user='Test123' visible='true' version='1' changeset='5'>
+      <nd ref='262' />
+      <nd ref='266' />
+      <nd ref='294' />
+      <nd ref='284' />
+      <nd ref='262' />
+      <tag k='natural' v='water' />
+    </way>
+  </modify>
+  <create>
+    <way id="101420" version="1" timestamp="2013-08-07T15:58:08Z" uid="5" user="Test123" changeset="1">
+      <nd ref="121"/>
+      <nd ref="179"/>
+      <nd ref="181"/>
+    </way>
+    <way id="101426" version="1" timestamp="2013-08-07T15:58:08Z" uid="5" user="Test123" changeset="2">
+      <nd ref="162"/>
+      <nd ref="178"/>
+      <nd ref="182"/>
+      <tag k="landuse" v="residential"/>
+    </way>
+    <way id="110736" version="1" timestamp="2013-08-07T15:58:08Z" uid="5" user="Test123" changeset="1">
+      <nd ref="110734"/>
+      <nd ref="110735"/>
+      <nd ref="110737"/>
+      <nd ref="110739"/>
+      <nd ref="110734"/>
+    </way>
+    <way id="110727" version="1" timestamp="2013-08-07T15:58:08Z" uid="5" user="Test123" changeset="1">
+      <nd ref="110725"/>
+      <nd ref="110726"/>
+      <nd ref="110728"/>
+      <nd ref="110730"/>
+      <nd ref="110725"/>
+    </way>
+  </create>
+  <modify>
+    <relation id="14" version="2" timestamp="2013-08-07T15:58:12Z" uid="5" user="Test123" changeset="1">
+      <member type="way" ref="66" role="outer"/>
+      <member type="way" ref="101420" role="outer"/>
+      <member type="way" ref="6" role="inner"/>
+      <tag k="landuse" v="residential"/>
+      <tag k="name" v="Name_way5"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="17" version="2" timestamp="2013-08-07T15:58:12Z" uid="5" user="Test123" changeset="1">
+      <member type="way" ref="2" role="outer"/>
+      <member type="way" ref="15" role="inner"/>
+      <member type="way" ref="101426" role="inner"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+  </modify>
+  <delete>
+    <relation id="25" version="1" timestamp="2013-08-30T00:51:24Z" uid="5" user="Test123" changeset="4">
+      <member type="way" ref="90" role="outer"/>
+      <member type="way" ref="91" role="inner"/>
+      <tag k="brand" v="my brand"/>
+      <tag k="name" v="my name"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+  </delete>
+  <modify>
+    <relation id="26" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="106" role="outer"/>
+      <member type="way" ref="111" role="inner"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="27" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="110736" role="inner"/>
+      <member type="way" ref="110727" role="outer"/>
+      <member type="way" ref="116" role="outer"/>
+      <member type="way" ref="108" role="inner"/>
+      <tag k="natural" v="heath"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="28" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="105" role="outer"/>
+      <member type="way" ref="117" role="inner"/>
+      <tag k="landuse" v="cemetery"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="29" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="109" role="outer"/>
+      <tag k="natural" v="water"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="30" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="92" role="outer"/>
+      <member type="way" ref="93" role="outer"/>
+      <member type="way" ref="98" role="outer"/>
+      <member type="way" ref="99" role="outer"/>
+      <member type="way" ref="94" role="outer"/>
+      <member type="way" ref="100" role="outer"/>
+      <member type="way" ref="96" role="outer"/>
+      <member type="way" ref="95" role="outer"/>
+      <tag k="natural" v="water"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="35" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="107" role="outer"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+    <relation id="36" version="1" timestamp="2013-08-30T00:11:08Z" uid="5" user="Test123" changeset="5">
+      <member type="way" ref="119" role="outer"/>
+      <member type="way" ref="115" role="inner"/>
+      <tag k="landuse" v="farmland"/>
+      <tag k="type" v="multipolygon"/>
+    </relation>
+  </modify>
+</osmChange>
diff --git a/tests/test_multipolygon_postdiff.osm b/tests/test_multipolygon_postdiff.osm
new file mode 100644
index 0000000..2eafbec
--- /dev/null
+++ b/tests/test_multipolygon_postdiff.osm
@@ -0,0 +1,987 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='true' generator='JOSM'>
+  <bounds minlat='-0.2' minlon='-0.1' maxlat='0.0' maxlon='0.1' origin='OpenStreetMap server' />
+  <bounds minlat='-0.0199918' minlon='-0.0319309' maxlat='0.0321498' maxlon='0.0448753' origin='OpenStreetMap server' />
+  <node id='1' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0019769' lon='-4.795E-4' />
+  <node id='2' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020205' lon='-0.0018769' />
+  <node id='3' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020279' lon='0.0028363' />
+  <node id='4' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020312' lon='0.0061232' />
+  <node id='5' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020446' lon='0.0019087' />
+  <node id='6' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020446' lon='0.0050649' />
+  <node id='7' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='2' changeset='1' lat='-0.0010452121450191022' lon='-0.003175856691018204' />
+  <node id='8' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002048' lon='0.0070977' />
+  <node id='9' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020547' lon='4.654E-4' />
+  <node id='10' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0020815' lon='0.0021096' />
+  <node id='12' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00209' lon='-0.0050668' />
+  <node id='13' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0021518' lon='0.0101183' />
+  <node id='14' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0021685' lon='0.0119166' />
+  <node id='15' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022054' lon='0.0017848' />
+  <node id='16' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022087' lon='0.0011887' />
+  <node id='17' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002227' lon='-7.971E-4' />
+  <node id='18' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022288' lon='0.0014399' />
+  <node id='19' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022422' lon='0.009559' />
+  <node id='20' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022456' lon='7.031E-4' />
+  <node id='21' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022468' lon='-0.0013886' />
+  <node id='22' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0022623' lon='0.0082731' />
+  <node id='23' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023282' lon='-0.0039711' />
+  <node id='24' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023481' lon='-0.0045626' />
+  <node id='25' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023561' lon='0.0103226' />
+  <node id='26' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0023896' lon='0.0117223' />
+  <node id='27' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024465' lon='0.0092945' />
+  <node id='28' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024498' lon='0.0033855' />
+  <node id='29' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024632' lon='0.0088993' />
+  <node id='30' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024833' lon='0.0084774' />
+  <node id='31' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0024867' lon='0.0020058' />
+  <node id='32' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0025001' lon='0.0041541' />
+  <node id='33' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0025905' lon='0.0105972' />
+  <node id='34' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026173' lon='0.0114377' />
+  <node id='35' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026399' lon='-7.931E-4' />
+  <node id='36' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026575' lon='0.0055137' />
+  <node id='37' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0026756' lon='-0.0014085' />
+  <node id='38' timestamp='2013-08-07T15:58:06Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027144' lon='6.161E-4' />
+  <node id='39' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027345' lon='0.0061098' />
+  <node id='40' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027411' lon='-0.0039671' />
+  <node id='41' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027646' lon='0.0013327' />
+  <node id='42' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027768' lon='-0.0045825' />
+  <node id='43' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027914' lon='0.0057079' />
+  <node id='44' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0027948' lon='0.0071479' />
+  <node id='45' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028182' lon='9.945E-4' />
+  <node id='46' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028216' lon='0.003198' />
+  <node id='47' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002845' lon='0.0022737' />
+  <node id='48' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.002845' lon='0.0093581' />
+  <node id='49' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028701' lon='-0.0019921' />
+  <node id='50' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028785' lon='0.0016877' />
+  <node id='51' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0028818' lon='0.0089495' />
+  <node id='52' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029019' lon='2.711E-4' />
+  <node id='53' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029053' lon='0.0085611' />
+  <node id='54' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029138' lon='-0.0033895' />
+  <node id='55' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029416' lon='-4.199E-4' />
+  <node id='56' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029654' lon='-0.0017261' />
+  <node id='57' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029723' lon='0.0026253' />
+  <node id='58' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0029823' lon='0.0061935' />
+  <node id='59' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030091' lon='0.0105436' />
+  <node id='60' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030091' lon='0.011421' />
+  <node id='61' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030111' lon='-0.0036098' />
+  <node id='62' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030325' lon='0.0018819' />
+  <node id='63' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030349' lon='-0.004916' />
+  <node id='64' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030861' lon='0.00471' />
+  <node id='65' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0030861' lon='0.0073354' />
+  <node id='66' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031441' lon='-1.4E-4' />
+  <node id='67' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003152' lon='-0.0022938' />
+  <node id='68' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031564' lon='0.0102857' />
+  <node id='69' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031719' lon='-0.0028853' />
+  <node id='70' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0031877' lon='-0.0015375' />
+  <node id='71' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032301' lon='0.0116822' />
+  <node id='72' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032335' lon='0.0033654' />
+  <node id='73' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032402' lon='0.0095992' />
+  <node id='74' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0032937' lon='0.0021967' />
+  <node id='75' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033004' lon='0.0048439' />
+  <node id='76' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033272' lon='0.0100848' />
+  <node id='77' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033306' lon='0.0083367' />
+  <node id='78' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033507' lon='0.0017915' />
+  <node id='79' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033574' lon='0.0118463' />
+  <node id='80' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0033942' lon='-4.576E-4' />
+  <node id='81' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003414' lon='-0.0010492' />
+  <node id='82' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034444' lon='0.0031946' />
+  <node id='83' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034511' lon='0.0025048' />
+  <node id='84' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034578' lon='0.0059624' />
+  <node id='85' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0034746' lon='0.0116788' />
+  <node id='86' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035114' lon='0.009636' />
+  <node id='87' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035181' lon='0.0101451' />
+  <node id='88' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='2' changeset='1' lat='-0.003452090101020654' lon='-0.0025154197983916784' />
+  <node id='89' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035717' lon='0.0016475' />
+  <node id='90' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035851' lon='3.08E-4' />
+  <node id='91' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0035918' lon='0.0083535' />
+  <node id='92' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0036006' lon='-0.0029052' />
+  <node id='93' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003642' lon='0.0115114' />
+  <node id='94' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0036688' lon='0.0103125' />
+  <node id='95' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037123' lon='9.007E-4' />
+  <node id='96' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037425' lon='0.0063978' />
+  <node id='97' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0037559' lon='0.0094284' />
+  <node id='98' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038071' lon='-4.537E-4' />
+  <node id='99' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038195' lon='0.0086917' />
+  <node id='100' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038195' lon='0.0113473' />
+  <node id='101' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038295' lon='0.0105168' />
+  <node id='102' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038349' lon='-0.0019325' />
+  <node id='103' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038428' lon='-0.001069' />
+  <node id='104' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038496' lon='0.0024746' />
+  <node id='105' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038587' lon='-0.0032386' />
+  <node id='106' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003863' lon='0.0031846' />
+  <node id='107' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0038798' lon='0.0105101' />
+  <node id='108' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039099' lon='0.0073254' />
+  <node id='109' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00392' lon='0.0050515' />
+  <node id='110' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039233' lon='0.0106239' />
+  <node id='111' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039267' lon='0.0092811' />
+  <node id='112' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.00393' lon='0.0112301' />
+  <node id='113' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039367' lon='0.0089228' />
+  <node id='114' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039735' lon='0.002267' />
+  <node id='115' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039869' lon='0.0034826' />
+  <node id='116' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0039936' lon='0.002036' />
+  <node id='117' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003997' lon='0.0015805' />
+  <node id='118' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.003997' lon='0.0107412' />
+  <node id='119' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040037' lon='0.0111564' />
+  <node id='120' timestamp='2013-08-07T15:58:07Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040204' lon='9.309E-4' />
+  <node id='121' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040373' lon='-0.0029806' />
+  <node id='122' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040606' lon='0.0108416' />
+  <node id='123' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0040774' lon='0.011076' />
+  <node id='124' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004081' lon='-0.004378' />
+  <node id='125' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041042' lon='0.0023675' />
+  <node id='126' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041088' lon='-8.05E-5' />
+  <node id='127' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041326' lon='-0.0013866' />
+  <node id='128' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004151' lon='0.0053529' />
+  <node id='129' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041577' lon='0.0016408' />
+  <node id='130' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041711' lon='0.010845' />
+  <node id='131' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041812' lon='0.0045492' />
+  <node id='132' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041912' lon='0.0092442' />
+  <node id='133' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0041912' lon='0.0110559' />
+  <node id='134' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042013' lon='0.0088859' />
+  <node id='135' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042247' lon='0.0107646' />
+  <node id='136' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042314' lon='6.127E-4' />
+  <node id='137' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042415' lon='0.0111497' />
+  <node id='138' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0042716' lon='0.0106608' />
+  <node id='139' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043064' lon='-0.0012852' />
+  <node id='140' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043118' lon='0.0087084' />
+  <node id='141' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043185' lon='0.0094452' />
+  <node id='142' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043185' lon='0.0112435' />
+  <node id='143' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043192' lon='-0.0032823' />
+  <node id='144' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043352' lon='0.0105235' />
+  <node id='145' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004339' lon='-0.0038738' />
+  <node id='146' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043501' lon='-0.0026826' />
+  <node id='147' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043553' lon='0.0046028' />
+  <node id='148' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0043553' lon='0.0048071' />
+  <node id='149' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044089' lon='0.0113406' />
+  <node id='150' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.004439' lon='0.0103226' />
+  <node id='151' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044424' lon='0.0054099' />
+  <node id='152' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044524' lon='0.0042311' />
+  <node id='153' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0044558' lon='0.0051855' />
+  <node id='154' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045228' lon='0.0097767' />
+  <node id='155' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045261' lon='0.0029167' />
+  <node id='156' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045261' lon='0.0044822' />
+  <node id='157' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045294' lon='0.0049511' />
+  <node id='158' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045395' lon='0.0115348' />
+  <node id='159' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045629' lon='0.001537' />
+  <node id='160' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045663' lon='0.0101183' />
+  <node id='161' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045864' lon='0.0084439' />
+  <node id='162' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045883' lon='-0.0015869' />
+  <node id='163' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0045897' lon='0.005651' />
+  <node id='164' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046082' lon='-0.0021784' />
+  <node id='165' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046467' lon='0.0050616' />
+  <node id='166' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046534' lon='0.0048037' />
+  <node id='167' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046634' lon='0.0054634' />
+  <node id='168' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0046868' lon='0.0116889' />
+  <node id='169' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047237' lon='0.0045325' />
+  <node id='170' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047321' lon='-0.0032783' />
+  <node id='171' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0047678' lon='-0.0038937' />
+  <node id='172' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048275' lon='0.0052726' />
+  <node id='173' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048375' lon='0.0050951' />
+  <node id='174' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048576' lon='0.0043182' />
+  <node id='175' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0048978' lon='0.0027292' />
+  <node id='176' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0049213' lon='0.0018049' />
+  <node id='177' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0049916' lon='0.0054501' />
+  <node id='178' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050012' lon='-0.0015829' />
+  <node id='179' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.005002' lon='-0.002921' />
+  <node id='180' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050117' lon='0.0046698' />
+  <node id='181' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050259' lon='-0.0042272' />
+  <node id='182' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050369' lon='-0.0021983' />
+  <node id='183' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0050485' lon='0.0021565' />
+  <node id='184' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.0052711' lon='-0.0012256' />
+  <node id='185' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1' lat='-0.005295' lon='-0.0025318' />
+  <node id='186' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.534E-4' lon='0.0051708' />
+  <node id='187' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.534E-4' lon='0.005727' />
+  <node id='188' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-9.931E-4' lon='0.007316' />
+  <node id='189' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0010196' lon='0.0039261' />
+  <node id='190' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0016817' lon='0.0038202' />
+  <node id='191' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0016817' lon='0.0051046' />
+  <node id='192' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0018009' lon='0.0070246' />
+  <node id='193' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2' lat='-0.0018141' lon='0.005674' />
+  <node id='194' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022345' lon='0.0127873' />
+  <node id='195' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022532' lon='0.0154465' />
+  <node id='196' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0022907' lon='0.0157742' />
+  <node id='197' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0023094' lon='0.0174034' />
+  <node id='198' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0025903' lon='0.0131806' />
+  <node id='199' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0026277' lon='0.0149596' />
+  <node id='200' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0027214' lon='0.0161581' />
+  <node id='201' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0027495' lon='0.0170476' />
+  <node id='202' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0031708' lon='0.0150345' />
+  <node id='203' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003227' lon='0.0131431' />
+  <node id='204' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0032925' lon='0.0161487' />
+  <node id='205' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0034049' lon='0.0169165' />
+  <node id='206' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0034517' lon='0.012675' />
+  <node id='207' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0035453' lon='0.0154652' />
+  <node id='208' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0036109' lon='0.0158585' />
+  <node id='209' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0037045' lon='0.0171787' />
+  <node id='210' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0038918' lon='0.0150439' />
+  <node id='211' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0039292' lon='0.016851' />
+  <node id='212' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003948' lon='0.0126937' />
+  <node id='213' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.003948' lon='0.0153997' />
+  <node id='214' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0041914' lon='0.0157461' />
+  <node id='215' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042008' lon='0.016542' />
+  <node id='216' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042476' lon='0.014763' />
+  <node id='217' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0042757' lon='0.0131619' />
+  <node id='218' timestamp='2013-08-28T03:36:12Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0046408' lon='0.0130121' />
+  <node id='219' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0046689' lon='0.0147817' />
+  <node id='220' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0047064' lon='0.0157368' />
+  <node id='221' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0047625' lon='0.0164858' />
+  <node id='222' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0048281' lon='0.0125065' />
+  <node id='223' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0049311' lon='0.0150439' />
+  <node id='224' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0049779' lon='0.0153716' />
+  <node id='225' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3' lat='-0.0050903' lon='0.0167105' />
+  <node id='226' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.005297' lon='0.0124904' />
+  <node id='227' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0053654' lon='0.0150095' />
+  <node id='228' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0056388' lon='0.0128907' />
+  <node id='229' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0057071' lon='0.0145897' />
+  <node id='230' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0060586' lon='0.01292' />
+  <node id='231' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0061465' lon='0.014492' />
+  <node id='232' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0063515' lon='0.0124611' />
+  <node id='233' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4' lat='-0.0063808' lon='0.0150291' />
+  <way id='1' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='12' />
+    <nd ref='7' />
+    <nd ref='61' />
+    <nd ref='63' />
+    <nd ref='12' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way' />
+  </way>
+  <way id='2' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='146' />
+    <nd ref='139' />
+    <nd ref='184' />
+    <nd ref='185' />
+    <nd ref='146' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way16' />
+  </way>
+  <way id='3' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='2' />
+    <nd ref='1' />
+    <nd ref='55' />
+    <nd ref='56' />
+    <nd ref='2' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way2' />
+  </way>
+  <way id='4' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='21' />
+    <nd ref='17' />
+    <nd ref='35' />
+    <nd ref='37' />
+    <nd ref='21' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_way3' />
+  </way>
+  <way id='5' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='81' />
+    <nd ref='80' />
+    <nd ref='98' />
+    <nd ref='103' />
+    <nd ref='81' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_way4' />
+  </way>
+  <way id='6' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='145' />
+    <nd ref='143' />
+    <nd ref='170' />
+    <nd ref='171' />
+    <nd ref='145' />
+    <tag k='highway' v='residential' />
+    <tag k='name' v='Name_way6' />
+  </way>
+  <way id='7' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='9' />
+    <nd ref='5' />
+    <nd ref='62' />
+    <nd ref='52' />
+    <nd ref='9' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way7' />
+  </way>
+  <way id='8' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='22' />
+    <nd ref='19' />
+    <nd ref='73' />
+    <nd ref='77' />
+    <nd ref='22' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way8' />
+  </way>
+  <way id='9' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='166' />
+    <nd ref='169' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='10' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='156' />
+    <nd ref='147' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='11' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='148' />
+    <nd ref='157' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='12' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='157' />
+    <nd ref='166' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='13' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='169' />
+    <nd ref='156' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='14' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='148' />
+    <nd ref='147' />
+    <tag k='highway' v='cycleway' />
+  </way>
+  <way id='15' action='modify' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='182' />
+    <nd ref='164' />
+    <nd ref='162' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='16' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='165' />
+    <nd ref='153' />
+  </way>
+  <way id='17' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='60' />
+    <nd ref='59' />
+  </way>
+  <way id='18' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='125' />
+    <nd ref='155' />
+  </way>
+  <way id='19' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='159' />
+    <nd ref='129' />
+  </way>
+  <way id='20' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='155' />
+    <nd ref='175' />
+  </way>
+  <way id='21' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='47' />
+    <nd ref='31' />
+  </way>
+  <way id='22' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='173' />
+    <nd ref='165' />
+  </way>
+  <way id='23' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='59' />
+    <nd ref='33' />
+  </way>
+  <way id='24' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='129' />
+    <nd ref='125' />
+  </way>
+  <way id='25' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='175' />
+    <nd ref='183' />
+  </way>
+  <way id='26' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='31' />
+    <nd ref='10' />
+  </way>
+  <way id='27' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='57' />
+    <nd ref='47' />
+  </way>
+  <way id='28' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='172' />
+    <nd ref='167' />
+  </way>
+  <way id='29' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='131' />
+    <nd ref='128' />
+  </way>
+  <way id='30' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='10' />
+    <nd ref='3' />
+  </way>
+  <way id='31' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='152' />
+    <nd ref='131' />
+  </way>
+  <way id='32' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='159' />
+    <nd ref='176' />
+  </way>
+  <way id='33' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='172' />
+    <nd ref='173' />
+  </way>
+  <way id='34' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='28' />
+    <nd ref='46' />
+  </way>
+  <way id='35' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='163' />
+    <nd ref='177' />
+  </way>
+  <way id='36' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='46' />
+    <nd ref='57' />
+  </way>
+  <way id='37' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='151' />
+    <nd ref='167' />
+  </way>
+  <way id='38' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='177' />
+    <nd ref='180' />
+  </way>
+  <way id='39' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='183' />
+    <nd ref='176' />
+  </way>
+  <way id='40' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='163' />
+    <nd ref='128' />
+  </way>
+  <way id='41' timestamp='2013-08-07T15:58:09Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='153' />
+    <nd ref='151' />
+  </way>
+  <way id='42' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='174' />
+    <nd ref='152' />
+  </way>
+  <way id='43' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='3' />
+    <nd ref='28' />
+  </way>
+  <way id='44' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='180' />
+    <nd ref='174' />
+  </way>
+  <way id='45' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='14' />
+    <nd ref='79' />
+    <nd ref='76' />
+  </way>
+  <way id='46' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='114' />
+    <nd ref='115' />
+    <nd ref='72' />
+  </way>
+  <way id='47' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='96' />
+    <nd ref='58' />
+    <nd ref='65' />
+  </way>
+  <way id='48' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='39' />
+    <nd ref='4' />
+    <nd ref='8' />
+  </way>
+  <way id='49' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='68' />
+    <nd ref='25' />
+    <nd ref='26' />
+  </way>
+  <way id='50' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='114' />
+    <nd ref='74' />
+    <nd ref='72' />
+  </way>
+  <way id='51' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='65' />
+    <nd ref='108' />
+    <nd ref='96' />
+  </way>
+  <way id='52' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='8' />
+    <nd ref='44' />
+    <nd ref='39' />
+  </way>
+  <way id='53' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='78' />
+    <nd ref='116' />
+    <nd ref='136' />
+  </way>
+  <way id='54' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='136' />
+    <nd ref='90' />
+    <nd ref='78' />
+  </way>
+  <way id='55' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='26' />
+    <nd ref='71' />
+    <nd ref='68' />
+  </way>
+  <way id='56' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='76' />
+    <nd ref='13' />
+    <nd ref='14' />
+  </way>
+  <way id='57' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='33' />
+    <nd ref='34' />
+    <nd ref='60' />
+  </way>
+  <way id='58' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='91' />
+    <nd ref='86' />
+    <nd ref='154' />
+    <nd ref='161' />
+    <nd ref='91' />
+  </way>
+  <way id='59' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='87' />
+    <nd ref='85' />
+    <nd ref='168' />
+    <nd ref='160' />
+    <nd ref='87' />
+  </way>
+  <way id='60' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='18' />
+    <nd ref='15' />
+    <nd ref='50' />
+    <nd ref='41' />
+    <nd ref='18' />
+  </way>
+  <way id='61' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='94' />
+    <nd ref='93' />
+    <nd ref='158' />
+    <nd ref='150' />
+    <nd ref='94' />
+  </way>
+  <way id='62' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='24' />
+    <nd ref='23' />
+    <nd ref='40' />
+    <nd ref='42' />
+    <nd ref='24' />
+  </way>
+  <way id='63' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='95' />
+    <nd ref='89' />
+    <nd ref='117' />
+    <nd ref='120' />
+    <nd ref='95' />
+  </way>
+  <way id='64' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='27' />
+    <nd ref='29' />
+    <nd ref='51' />
+    <nd ref='48' />
+    <nd ref='27' />
+  </way>
+  <way id='65' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='70' />
+    <nd ref='66' />
+    <nd ref='126' />
+    <nd ref='127' />
+    <nd ref='70' />
+  </way>
+  <way id='66' action='modify' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='181' />
+    <nd ref='124' />
+    <nd ref='121' />
+  </way>
+  <way id='67' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='99' />
+    <nd ref='97' />
+    <nd ref='141' />
+    <nd ref='140' />
+    <nd ref='99' />
+  </way>
+  <way id='68' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='118' />
+    <nd ref='119' />
+    <nd ref='137' />
+    <nd ref='135' />
+    <nd ref='118' />
+  </way>
+  <way id='69' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='113' />
+    <nd ref='111' />
+    <nd ref='132' />
+    <nd ref='134' />
+    <nd ref='113' />
+  </way>
+  <way id='70' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='75' />
+    <nd ref='43' />
+    <nd ref='84' />
+    <nd ref='109' />
+    <nd ref='75' />
+  </way>
+  <way id='71' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='54' />
+    <nd ref='49' />
+    <nd ref='102' />
+    <nd ref='105' />
+    <nd ref='54' />
+  </way>
+  <way id='72' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='20' />
+    <nd ref='16' />
+    <nd ref='45' />
+    <nd ref='38' />
+    <nd ref='20' />
+  </way>
+  <way id='73' timestamp='2013-08-07T15:58:10Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='30' />
+    <nd ref='29' />
+    <nd ref='51' />
+    <nd ref='53' />
+    <nd ref='30' />
+  </way>
+  <way id='74' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='69' />
+    <nd ref='67' />
+    <nd ref='88' />
+    <nd ref='92' />
+    <nd ref='69' />
+  </way>
+  <way id='75' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='110' />
+    <nd ref='112' />
+    <nd ref='142' />
+    <nd ref='138' />
+    <nd ref='110' />
+  </way>
+  <way id='76' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='83' />
+    <nd ref='82' />
+    <nd ref='106' />
+    <nd ref='104' />
+    <nd ref='83' />
+  </way>
+  <way id='77' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='122' />
+    <nd ref='123' />
+    <nd ref='133' />
+    <nd ref='130' />
+    <nd ref='122' />
+  </way>
+  <way id='78' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='32' />
+    <nd ref='6' />
+    <nd ref='36' />
+    <nd ref='64' />
+    <nd ref='32' />
+  </way>
+  <way id='79' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='101' />
+    <nd ref='100' />
+    <nd ref='149' />
+    <nd ref='144' />
+    <nd ref='107' />
+    <nd ref='101' />
+  </way>
+  <way id='80' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <nd ref='187' />
+    <nd ref='188' />
+    <nd ref='192' />
+    <nd ref='193' />
+    <nd ref='187' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='81' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <nd ref='189' />
+    <nd ref='186' />
+    <nd ref='191' />
+    <nd ref='190' />
+    <nd ref='189' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='82' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='194' />
+    <nd ref='195' />
+    <nd ref='207' />
+    <nd ref='206' />
+    <nd ref='194' />
+    <tag k='landuse' v='vineyard' />
+  </way>
+  <way id='83' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='196' />
+    <nd ref='197' />
+    <nd ref='209' />
+    <nd ref='208' />
+    <nd ref='196' />
+    <tag k='landuse' v='farmland' />
+  </way>
+  <way id='84' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='212' />
+    <nd ref='210' />
+    <nd ref='223' />
+    <nd ref='222' />
+    <nd ref='212' />
+    <tag k='landuse' v='vineyard' />
+  </way>
+  <way id='85' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='213' />
+    <nd ref='211' />
+    <nd ref='225' />
+    <nd ref='224' />
+    <nd ref='213' />
+    <tag k='landuse' v='vineyard' />
+    <tag k='name' v='unique-relation-way-tag-name' />
+  </way>
+  <way id='86' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='198' />
+    <nd ref='199' />
+    <nd ref='202' />
+    <nd ref='203' />
+    <nd ref='198' />
+  </way>
+  <way id='87' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='200' />
+    <nd ref='201' />
+    <nd ref='205' />
+    <nd ref='204' />
+    <nd ref='200' />
+  </way>
+  <way id='88' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='217' />
+    <nd ref='216' />
+    <nd ref='219' />
+    <nd ref='218' />
+    <nd ref='217' />
+  </way>
+  <way id='89' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <nd ref='214' />
+    <nd ref='215' />
+    <nd ref='221' />
+    <nd ref='220' />
+    <nd ref='214' />
+  </way>
+  <way id='90' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4'>
+    <nd ref='226' />
+    <nd ref='227' />
+    <nd ref='233' />
+    <nd ref='232' />
+    <nd ref='226' />
+    <tag k='landuse' v='farmland' />
+  </way>
+  <way id='91' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='1' changeset='4'>
+    <nd ref='228' />
+    <nd ref='229' />
+    <nd ref='231' />
+    <nd ref='230' />
+    <nd ref='228' />
+  </way>
+  <way id='101426' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <nd ref='162' />
+    <nd ref='178' />
+    <nd ref='182' />
+    <tag k='landuse' v='residential' />
+  </way>
+  <way id='101420' timestamp='2013-08-07T15:58:08Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <nd ref='121' />
+    <nd ref='179' />
+    <nd ref='181' />
+  </way>
+  <relation id='1' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='71' role='outer' />
+    <member type='way' ref='74' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='2' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='52' role='outer' />
+    <member type='way' ref='48' role='outer' />
+    <member type='way' ref='47' role='outer' />
+    <member type='way' ref='51' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel10' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='3' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='29' role='outer' />
+    <member type='way' ref='40' role='outer' />
+    <member type='way' ref='35' role='outer' />
+    <member type='way' ref='38' role='outer' />
+    <member type='way' ref='44' role='outer' />
+    <member type='way' ref='42' role='outer' />
+    <member type='way' ref='31' role='outer' />
+    <member type='way' ref='9' role='inner' />
+    <member type='way' ref='13' role='inner' />
+    <member type='way' ref='10' role='inner' />
+    <member type='way' ref='14' role='inner' />
+    <member type='way' ref='11' role='inner' />
+    <member type='way' ref='12' role='inner' />
+    <member type='way' ref='16' role='inner' />
+    <member type='way' ref='41' role='inner' />
+    <member type='way' ref='37' role='inner' />
+    <member type='way' ref='28' role='inner' />
+    <member type='way' ref='33' role='inner' />
+    <member type='way' ref='22' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel11' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='4' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='69' role='outer' />
+    <member type='way' ref='58' role='outer' />
+    <member type='way' ref='67' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel12' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='5' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='41' role='outer' />
+    <member type='way' ref='37' role='outer' />
+    <member type='way' ref='28' role='outer' />
+    <member type='way' ref='33' role='outer' />
+    <member type='way' ref='22' role='outer' />
+    <member type='way' ref='16' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel12' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='6' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='68' role='outer' />
+    <member type='way' ref='79' role='outer' />
+    <member type='way' ref='59' role='outer' />
+    <member type='way' ref='77' role='inner' />
+    <member type='way' ref='75' role='inner' />
+    <member type='way' ref='61' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel13' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='7' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='17' role='outer' />
+    <member type='way' ref='23' role='outer' />
+    <member type='way' ref='57' role='outer' />
+    <member type='way' ref='45' role='outer' />
+    <member type='way' ref='56' role='outer' />
+    <member type='way' ref='49' role='inner' />
+    <member type='way' ref='55' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel15' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='8' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='65' role='outer' />
+    <member type='way' ref='5' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel2' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='9' timestamp='2013-08-07T15:58:11Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='54' role='outer' />
+    <member type='way' ref='53' role='outer' />
+    <member type='way' ref='63' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel3' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='10' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='50' role='outer' />
+    <member type='way' ref='46' role='outer' />
+    <member type='way' ref='76' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel4' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='11' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='30' role='outer' />
+    <member type='way' ref='43' role='outer' />
+    <member type='way' ref='34' role='outer' />
+    <member type='way' ref='36' role='outer' />
+    <member type='way' ref='27' role='outer' />
+    <member type='way' ref='21' role='outer' />
+    <member type='way' ref='26' role='outer' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel6' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='12' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='25' role='outer' />
+    <member type='way' ref='32' role='outer' />
+    <member type='way' ref='39' role='outer' />
+    <member type='way' ref='20' role='outer' />
+    <member type='way' ref='19' role='outer' />
+    <member type='way' ref='18' role='outer' />
+    <member type='way' ref='24' role='outer' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_rel8' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='13' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='70' role='outer' />
+    <member type='way' ref='78' role='outer' />
+    <tag k='landuse' v='farmland' />
+    <tag k='name' v='Name_rel9' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='14' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='2' changeset='1'>
+    <member type='way' ref='66' role='outer' />
+    <member type='way' ref='101420' role='outer' />
+    <member type='way' ref='6' role='inner' />
+    <tag k='landuse' v='residential' />
+    <tag k='name' v='Name_way5' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='15' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='1' role='outer' />
+    <member type='way' ref='62' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='16' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='3' role='outer' />
+    <member type='way' ref='4' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='17' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='2' changeset='1'>
+    <member type='way' ref='2' role='outer' />
+    <member type='way' ref='15' role='inner' />
+    <member type='way' ref='101426' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='18' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='7' role='outer' />
+    <member type='way' ref='60' role='inner' />
+    <member type='way' ref='72' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='19' timestamp='2013-08-07T15:58:12Z' uid='5' user='Test123' visible='true' version='1' changeset='1'>
+    <member type='way' ref='8' role='outer' />
+    <member type='way' ref='64' role='inner' />
+    <member type='way' ref='73' role='inner' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='20' timestamp='2013-08-07T16:19:36Z' uid='5' user='Test123' visible='true' version='1' changeset='2'>
+    <member type='way' ref='80' role='outer' />
+    <member type='way' ref='81' role='outer' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='21' timestamp='2013-08-28T03:36:13Z' uid='5' user='Test123' visible='true' version='1' changeset='3'>
+    <member type='way' ref='82' role='outer' />
+    <member type='way' ref='86' role='inner' />
+    <tag k='landuse' v='farmland' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='22' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='84' role='outer' />
+    <member type='way' ref='88' role='inner' />
+    <tag k='fixme' v='this is a random fixme' />
+    <tag k='name' v='rel name something' />
+    <tag k='note' v='this is a random note' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='23' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='85' role='outer' />
+    <member type='way' ref='89' role='inner' />
+    <tag k='fixme' v='this is a random fixme' />
+    <tag k='note' v='this is a random note' />
+    <tag k='random_tag' v='this is a random random_tag' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+  <relation id='24' timestamp='2013-08-28T04:15:15Z' uid='5' user='Test123' visible='true' version='2' changeset='4'>
+    <member type='way' ref='83' role='outer' />
+    <member type='way' ref='87' role='inner' />
+    <tag k='natural' v='water' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+</osm>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osm2pgsql.git



More information about the Pkg-grass-devel mailing list