[osm2pgrouting] 01/03: Imported Upstream version 2.0.0-release

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Apr 29 17:11:09 UTC 2016


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

sebastic pushed a commit to branch master
in repository osm2pgrouting.

commit ad5b8bfd75134435a5ea427c9fad9634ef84afc3
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Apr 29 19:03:40 2016 +0200

    Imported Upstream version 2.0.0-release
---
 .gitignore                          |  10 +
 AUTHORS.txt                         |   7 +
 CMakeLists.txt                      |  30 +++
 COPYING                             | 339 +++++++++++++++++++++++++
 Makefile.orig                       |  29 +++
 Readme.md                           |  56 +++++
 Vagrantfile                         |  22 ++
 cmake/FindPostgreSQL.cmake          | 181 ++++++++++++++
 mapconfig.xml                       |  48 ++++
 mapconfig_for_cars.xml              |  22 ++
 src/Class.cpp                       |  40 +++
 src/Class.h                         |  47 ++++
 src/Configuration.cpp               |  53 ++++
 src/Configuration.h                 |  76 ++++++
 src/ConfigurationParserCallback.cpp | 116 +++++++++
 src/ConfigurationParserCallback.h   |  76 ++++++
 src/Export2DB.cpp                   | 486 ++++++++++++++++++++++++++++++++++++
 src/Export2DB.h                     |  90 +++++++
 src/Node.cpp                        |  40 +++
 src/Node.h                          |  62 +++++
 src/OSMDocument.cpp                 | 172 +++++++++++++
 src/OSMDocument.h                   |  73 ++++++
 src/OSMDocumentParserCallback.cpp   | 362 +++++++++++++++++++++++++++
 src/OSMDocumentParserCallback.h     |  79 ++++++
 src/Relation.cpp                    |  50 ++++
 src/Relation.h                      |  74 ++++++
 src/Type.cpp                        |  44 ++++
 src/Type.h                          |  54 ++++
 src/Way.cpp                         |  62 +++++
 src/Way.h                           | 101 ++++++++
 src/XMLParser.cpp                   |  93 +++++++
 src/XMLParser.h                     |  95 +++++++
 src/math_functions.cpp              |  41 +++
 src/math_functions.h                |  31 +++
 src/osm2pgrouting.cpp               | 258 +++++++++++++++++++
 src/stdafx.h                        |  25 ++
 src/utils.cpp                       |  12 +
 src/utils.h                         |   7 +
 tools/vagrant/bootstrap.sh          |  22 ++
 tools/vagrant/packaging.sh          |  15 ++
 tools/vagrant/packaging.sh.sample   |  15 ++
 41 files changed, 3515 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..498eec4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+tools
+bin/*
+Sample/*
+osm2pgrouting
+tools/vagrant/packaging.sh
+*.o
+*~
+.project
+.cproject
+.vagrant
diff --git a/AUTHORS.txt b/AUTHORS.txt
new file mode 100644
index 0000000..2b36a1d
--- /dev/null
+++ b/AUTHORS.txt
@@ -0,0 +1,7 @@
+Project contributors:
+
+Daniel Wendt (primary author) 
+Anton Patrushev
+Daniel Kastl
+Jordan Anderson
+J Kishore Kumar
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6b0402b
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,30 @@
+PROJECT(osm2pgrouting)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
+set (SHARE_DIR "/usr/share/osm2pgrouting")
+
+FIND_PACKAGE(PostgreSQL REQUIRED)
+FIND_PACKAGE(EXPAT REQUIRED)
+FIND_PACKAGE(Boost REQUIRED)
+
+FILE(GLOB SRC "${CMAKE_SOURCE_DIR}/src/*.cpp" "${CMAKE_SOURCE_DIR}/src/*.h")
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
+
+INCLUDE_DIRECTORIES(src ${PostgreSQL_INCLUDE_DIRS} ${EXPAT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+link_directories(${PostgreSQL_LIBRARY_DIRS})
+
+ADD_EXECUTABLE(osm2pgrouting ${SRC})
+TARGET_LINK_LIBRARIES(osm2pgrouting ${PostgreSQL_LIBRARIES} ${EXPAT_LIBRARIES})
+
+INSTALL(TARGETS osm2pgrouting
+  RUNTIME DESTINATION "/usr/share/bin"
+)
+
+INSTALL(FILES
+    "${CMAKE_SOURCE_DIR}/COPYING"
+    "${CMAKE_SOURCE_DIR}/Readme.md"
+    "${CMAKE_SOURCE_DIR}/mapconfig.xml"
+    "${CMAKE_SOURCE_DIR}/mapconfig_for_cars.xml"
+    DESTINATION "${SHARE_DIR}")
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/Makefile.orig b/Makefile.orig
new file mode 100644
index 0000000..8dc5529
--- /dev/null
+++ b/Makefile.orig
@@ -0,0 +1,29 @@
+CC = g++
+
+CFLAGS = -ggdb3 -D_FILE_OFFSET_BITS=64
+
+OBJ = bin/Export2DB.o bin/math_functions.o bin/Node.o bin/OSMDocumentParserCallback.o bin/Way.o bin/OSMDocument.o bin/Type.o bin/Class.o bin/Configuration.o bin/ConfigurationParserCallback.o bin/Relation.o bin/XMLParser.o
+
+INC_DIRS = -I./ -Isrc -I/usr/include/pgsql -I/usr/include/postgresql -I/usr/local/pgsql/include
+
+LIB_DIRS = -L/usr/local/pgsql/lib -L/usr/local/lib/pgsql
+
+LIBS = -lexpat -lpq
+
+MAIN = src/osm2pgrouting.cpp
+
+all: osm2pgrouting
+
+osm2pgrouting : bin $(OBJ) $(MAIN)
+	$(CC) $(CFLAGS) $(MAIN) $(OBJ) $(INC_DIRS) $(LIB_DIRS) $(LIBS) -o bin/$@
+	
+
+bin:
+	mkdir -p bin
+  
+bin/%.o : src/%.cpp
+	$(CC) -o $@ $(INC_DIRS) $(CFLAGS) -c $<
+
+clean:
+	rm -rf bin
+	rm -f osm2pgrouting
diff --git a/Readme.md b/Readme.md
new file mode 100644
index 0000000..5657f28
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,56 @@
+# osm2pgrouting
+
+## Requirements
+
+Before you can use this tool for importing Openstreetmap data you need to install:
+
+1. postgresql
+2. postgis
+3. pgrouting
+4. boost
+5. expat
+6. cmake
+
+and to prepare a database.
+
+## Documentation
+
+See in the documentation of the pgrouting website for more informations: http://pgrouting.org
+
+## Installation
+
+For compiling this tool, you will need boost, libpq, expat and cmake:
+Then just type the following in the root directory:
+
+```
+cmake -H. -Bbuild
+cd build/
+make
+make install
+```
+
+## How to use
+
+Start the program like this:
+
+```
+osm2pgrouting -file your-OSM-XML-File.osm -conf mapconfig.xml -dbname routing -user postgres -clean
+```
+
+A complete list of arguments are:
+
+```
+required: 
+-file <file>  			-- name of your osm xml file
+-dbname <dbname> 		-- name of your database
+-user <user> 			-- name of the user, which have write access to the database
+-conf <file> 			-- name of your configuration xml file
+
+optional:
+-host <host>  			-- host of your postgresql database (default: 127.0.0.1)
+-port <port> 			-- port of your database (default: 5432)
+-prefixtables <prefix> 	-- add at the beginning of table names
+-passwd <passwd> 		-- password for database access
+-clean 					-- drop previously created tables
+-skipnodes				-- do not load nodes into the node table (reduces runtime) 
+```
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 0000000..1f281ae
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,22 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+pgbox    = ENV['BOX'] || "precise64"
+
+Vagrant.configure("2") do |config|
+
+  # Vagrant box configuration
+  config.vm.box = pgbox
+  config.vm.box_url = "http://files.vagrantup.com/%s.box" % [pgbox]
+
+  # Bootstrap script
+  config.vm.provision :shell, :path => "tools/vagrant/bootstrap.sh"
+
+  # Forward SSH agent to host
+  config.ssh.forward_agent = true
+
+  # Create synced folder for GnuPG keys
+  config.vm.synced_folder "~/.gnupg", "/home/vagrant/.gnupg"
+  config.vm.synced_folder "../", "/home/vagrant/repos"
+
+end
diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake
new file mode 100644
index 0000000..6455c99
--- /dev/null
+++ b/cmake/FindPostgreSQL.cmake
@@ -0,0 +1,181 @@
+# Find the PostgreSQL installation.
+#
+# ----------------------------------------------------------------------------
+# Usage:
+# In your CMakeLists.txt file do something like this:
+# ...
+# # PostgreSQL
+# FIND_PACKAGE(PostgreSQL)
+# ...
+# if( PostgreSQL_FOUND )
+#   include_directories(${PostgreSQL_INCLUDE_DIRS})
+#   link_directories(${PostgreSQL_LIBRARY_DIRS})
+# endif( PostgreSQL_FOUND )
+# ...
+# Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement.
+#
+#
+# In Windows, we make the assumption that, if the PostgreSQL files are installed, the default directory
+# will be C:\Program Files\PostgreSQL.
+#
+
+#=============================================================================
+# Copyright 2004-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# ----------------------------------------------------------------------------
+# History:
+# This module is derived from the module originally found in the VTK source tree.
+#
+# ----------------------------------------------------------------------------
+# Note:
+# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
+# version mumber of the implementation of PostgreSQL.
+# In Windows the default installation of PostgreSQL uses that as part of the path.
+# E.g C:\Program Files\PostgreSQL\8.4.
+# Currently, the following version numbers are known to this module:
+# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
+#
+# To use this variable just do something like this:
+# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
+# before calling FIND_PACKAGE(PostgreSQL) in your CMakeLists.txt file.
+# This will mean that the versions you set here will be found first in the order
+# specified before the default ones are searched.
+#
+# ----------------------------------------------------------------------------
+# You may need to manually set:
+#  PostgreSQL_INCLUDE_DIR  - the path to where the PostgreSQL include files are.
+#  PostgreSQL_LIBRARY_DIR  - The path to where the PostgreSQL library files are.
+# If FindPostgreSQL.cmake cannot find the include files or the library files.
+#
+# ----------------------------------------------------------------------------
+# The following variables are set if PostgreSQL is found:
+#  PostgreSQL_FOUND         - Set to true when PostgreSQL is found.
+#  PostgreSQL_INCLUDE_DIRS  - Include directories for PostgreSQL
+#  PostgreSQL_LIBRARY_DIRS  - Link directories for PostgreSQL libraries
+#  PostgreSQL_LIBRARIES     - The PostgreSQL libraries.
+#
+# ----------------------------------------------------------------------------
+# If you have installed PostgreSQL in a non-standard location.
+# (Please note that in the following comments, it is assumed that <Your Path>
+# points to the root directory of the include directory of PostgreSQL.)
+# Then you have three options.
+# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
+#    PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
+# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
+#    to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
+#    SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
+# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
+#    installed PostgreSQL, e.g. <Your Path>.
+#
+# ----------------------------------------------------------------------------
+
+set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
+set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
+set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
+set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
+set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
+
+
+set(PostgreSQL_ROOT_DIRECTORIES $ENV{PostgreSQL_ROOT})
+if(PostgreSQL_ROOT_DIRECTORIES)
+  file(TO_CMAKE_PATH ${PostgreSQL_ROOT_DIRECTORIES} PostgreSQL_ROOT_DIRECTORIES)
+endif(PostgreSQL_ROOT_DIRECTORIES)
+
+set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
+    "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
+
+# Define additional search paths for root directories.
+if ( WIN32 )
+  foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} )
+    set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" )
+  endforeach(suffix)
+endif( WIN32 )
+set( PostgreSQL_ROOT_DIRECTORIES
+   ${PostgreSQL_ROOT_DIRECTORIES}
+   ${PostgreSQL_ROOT}
+   ${PostgreSQL_ADDITIONAL_SEARCH_PATHS}
+)
+
+#
+# Look for an installation.
+#
+find_path(PostgreSQL_INCLUDE_DIR
+  NAMES libpq-fe.h
+  PATHS
+   # Look in other places.
+   ${PostgreSQL_ROOT_DIRECTORIES}
+  PATH_SUFFIXES
+    postgresql
+    include
+  # Help the user find it if we cannot.
+  DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
+)
+
+# The PostgreSQL library.
+set (PostgreSQL_LIBRARY_TO_FIND pq)
+# Setting some more prefixes for the library
+set (PostgreSQL_LIB_PREFIX "")
+if ( WIN32 )
+  set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
+  set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
+endif()
+
+find_library( PostgreSQL_LIBRARY
+ NAMES ${PostgreSQL_LIBRARY_TO_FIND}
+ PATHS
+   ${PostgreSQL_ROOT_DIRECTORIES}
+ PATH_SUFFIXES
+   lib
+)
+get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
+
+# Did we find anything?
+set( PostgreSQL_FOUND 0 )
+if ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
+  set( PostgreSQL_FOUND 1 )
+else ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
+  if ( POSTGRES_REQUIRED )
+    message( FATAL_ERROR "PostgreSQL is required. ${PostgreSQL_ROOT_DIR_MESSAGE}" )
+  endif ( POSTGRES_REQUIRED )
+endif (EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
+
+# Now try to get the include and library path.
+if(PostgreSQL_FOUND)
+
+  if(EXISTS "${PostgreSQL_INCLUDE_DIR}")
+    set(PostgreSQL_INCLUDE_DIRS
+      ${PostgreSQL_INCLUDE_DIR}
+    )
+  endif(EXISTS "${PostgreSQL_INCLUDE_DIR}")
+
+  if(EXISTS "${PostgreSQL_LIBRARY_DIR}")
+    set(PostgreSQL_LIBRARY_DIRS
+      ${PostgreSQL_LIBRARY_DIR}
+    )
+    set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
+  endif(EXISTS "${PostgreSQL_LIBRARY_DIR}")
+
+  #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
+  #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
+  #message("Final PostgreSQL libraries:   ${PostgreSQL_LIBRARIES}")
+endif(PostgreSQL_FOUND)
+
+if(NOT PostgreSQL_FOUND)
+  if(NOT PostgreSQL_FIND_QUIETLY)
+    message(STATUS "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}")
+  else(NOT PostgreSQL_FIND_QUIETLY)
+    if(PostgreSQL_FIND_REQUIRED)
+      message(FATAL_ERROR "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}")
+    endif(PostgreSQL_FIND_REQUIRED)
+  endif(NOT PostgreSQL_FIND_QUIETLY)
+endif(NOT PostgreSQL_FOUND)
diff --git a/mapconfig.xml b/mapconfig.xml
new file mode 100644
index 0000000..2ee4f9d
--- /dev/null
+++ b/mapconfig.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+  <type name="highway" id="1">
+    <class name="motorway" id="101" />
+    <class name="motorway_link" id="102" />
+    <class name="motorway_junction" id="103" />
+    <class name="trunk" id="104" />
+    <class name="trunk_link" id="105" />    
+    <class name="primary" id="106" />
+    <class name="primary_link" id="107" />    
+    <class name="secondary" id="108" />
+    <class name="secondary_link" id="124" />
+    <class name="tertiary" id="109" />
+    <class name="tertiary_link" id="125" />
+    <class name="residential" id="110" />
+    <class name="living_street" id="111" />
+    <class name="service" id="112" />
+    <class name="track" id="113" />
+    <class name="pedestrian" id="114" />
+    <class name="services" id="115" />
+    <class name="bus_guideway" id="116" />
+    <class name="path" id="117" />
+    <class name="cycleway" id="118" />
+    <class name="footway" id="119" />
+    <class name="bridleway" id="120" />
+    <class name="byway" id="121" />
+    <class name="steps" id="122" />
+        
+    <class name="unclassified" id="123" />
+    <class name="road" id="100" />
+  </type>
+  <type name="cycleway" id="2">
+    <class name="lane" id="201" />
+    <class name="track" id="202" />
+    <class name="opposite_lane" id="203" />
+    <class name="opposite" id="204" />
+  </type>  
+  <type name="tracktype" id="3">
+    <class name="grade1" id="301" />
+    <class name="grade2" id="302" />
+    <class name="grade3" id="303" />
+    <class name="grade4" id="304" />
+    <class name="grade5" id="305" />
+  </type>  
+  <type name="junction" id="4">
+    <class name="roundabout" id="401" />
+  </type>  
+</configuration>
diff --git a/mapconfig_for_cars.xml b/mapconfig_for_cars.xml
new file mode 100644
index 0000000..77f8454
--- /dev/null
+++ b/mapconfig_for_cars.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+  <type name="highway" id="1">
+    <class name="motorway" id="101" priority="1.0" maxspeed="130" />
+    <class name="motorway_link" id="102" priority="1.0" maxspeed="130" />
+    <class name="motorway_junction" id="103" priority="1.0" maxspeed="130" />
+    <class name="trunk" id="104"  priority="1.05" maxspeed="110" />
+    <class name="trunk_link" id="105"  priority="1.05" maxspeed="110" />    
+    <class name="primary" id="106"  priority="1.15" maxspeed="90" />
+    <class name="primary_link" id="107"  priority="1.15" maxspeed="90" />    
+    <class name="secondary" id="108"  priority="1.5" maxspeed="90" />
+    <class name="secondary_link" id="109"  priority="1.5" maxspeed="90"/>  
+    <class name="tertiary" id="110"  priority="1.75" maxspeed="90" />
+    <class name="tertiary_link" id="111"  priority="1.75" maxspeed="90" />  
+    <class name="residential" id="112"  priority="2.5" maxspeed="50" />
+    <class name="living_street" id="113"  priority="3" maxspeed="20" />
+    <class name="service" id="114"  priority="2.5" maxspeed="50" />
+        
+    <class name="unclassified" id="117" priority="3" maxspeed="90"/>
+    <class name="road" id="100" priority="5" maxspeed="50" />
+  </type> 
+</configuration>
diff --git a/src/Class.cpp b/src/Class.cpp
new file mode 100644
index 0000000..b46b102
--- /dev/null
+++ b/src/Class.cpp
@@ -0,0 +1,40 @@
+/***************************************************************************
+*   Copyright (C) 2008 by Daniel Wendt                                    *
+*   gentoo.murray at gmail.com                                               *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+                  
+#include "stdafx.h"
+#include "Class.h"
+
+namespace osm
+{
+
+Class::Class(long long id, std::string name, double priority, int default_maxspeed)
+:
+  id(id),
+  name(name),
+  priority(priority),
+  default_maxspeed(default_maxspeed)
+{
+}
+
+Class::~Class()
+{
+}
+
+} // end namespace osm
diff --git a/src/Class.h b/src/Class.h
new file mode 100644
index 0000000..15cec05
--- /dev/null
+++ b/src/Class.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+*   Copyright (C) 2008 by Daniel Wendt                                    *
+*   gentoo.murray at gmail.com                                               *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+                  
+#ifndef CLASS_H
+#define CLASS_H
+
+namespace osm
+{
+
+class Class
+{
+public:
+	long long id;
+	std::string name;
+	double priority;
+	int default_maxspeed;
+public:
+	/** 
+	 *	Constructor
+	 *	@param id ID of the class
+	 *	@param name name of the class
+	 */
+	Class( long long id, std::string name, double priority,int default_maxspeed);
+	//! Destructor
+	~Class();
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
new file mode 100644
index 0000000..81cc839
--- /dev/null
+++ b/src/Configuration.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Configuration.h"
+#include "Type.h"
+#include "Class.h"
+
+
+namespace osm
+{
+
+Configuration::Configuration()
+{
+}
+
+Configuration::~Configuration()
+{
+	ez_mapdelete( m_Types );
+}
+void Configuration::AddType( Type* t )
+{
+	m_Types[t->name] = t;
+}
+
+Type* Configuration::FindType( std::string name ) 
+{
+	return m_Types[name];
+}
+
+Class* Configuration::FindClass( std::string typeName, std::string className ) 
+{
+	return m_Types[typeName]->m_Classes[className];
+}
+
+} // end namespace osm
diff --git a/src/Configuration.h b/src/Configuration.h
new file mode 100644
index 0000000..5bbe21b
--- /dev/null
+++ b/src/Configuration.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt                                    *
+ *   gentoo.murray at gmail.com                                               *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+ 
+#ifndef CONFIGURATION_H
+#define CONFIGURATION_H
+
+#include "Type.h"
+#include "Class.h"
+
+namespace osm
+{
+
+template< class Map >
+inline void ez_mapdelete( Map& c )
+{
+	typename Map::iterator it( c.begin() );
+	typename Map::iterator last( c.end() );
+	while( it!=last )
+	{
+		delete (*it++).second;
+	}
+}
+
+template< class Vector >
+inline void ez_vectordelete( Vector& c )
+{
+	typename Vector::iterator it( c.begin() );
+	typename Vector::iterator last( c.end() );
+	while( it!=last )
+	{
+		delete (*it++);
+	}
+}
+          
+
+/**
+A configuration document.
+*/
+class Configuration
+{
+public:
+	//! Map, which saves the parsed types
+	std::map<std::string, Type*> m_Types;
+	//std::map<long long, Type*> m_Types;
+public:
+
+	//! Constructor
+	Configuration();
+	//! Destructor
+	virtual ~Configuration();
+	//! add node to the map
+	void AddType( Type* t );
+	Type* FindType( std::string typeName );
+	Class* FindClass( std::string typeName, std::string className );
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/ConfigurationParserCallback.cpp b/src/ConfigurationParserCallback.cpp
new file mode 100644
index 0000000..3383375
--- /dev/null
+++ b/src/ConfigurationParserCallback.cpp
@@ -0,0 +1,116 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "ConfigurationParserCallback.h"
+#include "OSMDocument.h"
+#include "Configuration.h"
+#include "Type.h"
+#include "Class.h"
+
+namespace osm
+{
+	
+	
+/**
+	Parser callback for configuration files
+*/
+void ConfigurationParserCallback::StartElement( const char *name, const char** atts )
+{
+	//std::cout << "SE for <" << name << ">" << std::endl;
+	if( strcmp(name,"class") == 0 )
+	{
+		if (atts != NULL)
+		{
+			long long id=-1;
+			std::string name;
+			double priority = 1;
+			int maxspeed=50;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* key = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( key, "id" ) == 0 )
+				{
+					id = atoll( value );
+					//std::cout << "class id = " << id << std::endl;
+
+				}
+				else if( strcmp( key, "name" ) == 0 )
+				{
+					name = value;
+					//std::cout << "class name = " << name << std::endl;
+				}else if(strcmp(key, "priority") == 0){
+					priority = boost::lexical_cast<double>(value);
+				}else if(strcmp(key, "maxspeed") == 0){
+					maxspeed = boost::lexical_cast<int>(value);
+				}
+			}
+			if( id>0 && !name.empty() )
+			{
+				m_pActType->AddClass( new Class( id, name, priority, maxspeed ) );
+				//std::cout << "class id = "<<id<<" name = " << name << " added to type name=" << m_pActType->name << std::endl;
+			}
+		}
+	}
+	else if( strcmp(name,"type") == 0 )
+	{
+		if (atts != NULL)
+		{
+			long long id;
+			std::string name;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* key = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( key, "id" ) == 0 )
+				{
+					id = atoll( value );
+
+				}
+				else if( strcmp( key, "name" ) == 0 )
+				{
+					name = value;
+				}
+			}
+			if( !name.empty() )
+			{
+			    m_pActType = new Type( id, name );
+			}
+		}
+	}
+	else if( strcmp(name,"configuration") == 0 )
+	{
+	}
+}
+
+
+void ConfigurationParserCallback::EndElement( const char* name )
+{
+	if( strcmp(name,"type") == 0 )
+	{
+	    m_rDocument.AddType( m_pActType );
+	    m_pActType = 0;
+	}
+}
+
+}; // end namespace osm
diff --git a/src/ConfigurationParserCallback.h b/src/ConfigurationParserCallback.h
new file mode 100644
index 0000000..856e5f6
--- /dev/null
+++ b/src/ConfigurationParserCallback.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef CONFIGURATIONPARSERCALLBACK_H
+#define CONFIGURATIONPARSERCALLBACK_H
+
+#include <string.h>
+#include "XMLParser.h"
+
+
+namespace osm
+{
+
+class Configuration;
+class Type;
+
+/**
+	Parser callback for configuration files
+*/
+class ConfigurationParserCallback : public xml::XMLParserCallback
+{	
+	//! reference to a Configuration object
+	Configuration& m_rDocument;
+	//! current type, which will be parsed
+	Type* m_pActType;
+
+	virtual void StartElement( const char *name, const char** atts );
+
+	virtual void EndElement( const char* name );
+
+	virtual void SetContent( const char* ch, int len)
+	{
+	}
+
+	virtual void ProcessingInstruction( const char* target, const char* data )
+	{
+	}
+
+	virtual void CDataBlockInternal(const char *value, int len)
+	{
+	}
+
+
+public:
+	/**
+	 *	Constructor
+	 */
+	ConfigurationParserCallback( Configuration& doc )
+	:
+		m_rDocument( doc ),
+		m_pActType( 0 )
+	{
+	}
+
+}; // class
+
+}; // end namespace osm
+
+#endif
diff --git a/src/Export2DB.cpp b/src/Export2DB.cpp
new file mode 100644
index 0000000..477b10b
--- /dev/null
+++ b/src/Export2DB.cpp
@@ -0,0 +1,486 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Export2DB.h"
+#include "boost/algorithm/string/replace.hpp"
+
+#define TO_STR(x)	boost::lexical_cast<std::string>(x)
+
+using namespace std;
+
+Export2DB::Export2DB(std::string host, std::string user, std::string dbname, std::string port, std::string passwd, std::string tables_prefix)
+:mycon(0)
+{
+    this->conninf="host="+host+" user="+user+" dbname="+ dbname +" port="+port;
+    this->tables_prefix = tables_prefix;
+    if(!passwd.empty())
+        this->conninf+=" password="+passwd;
+}
+
+Export2DB::~Export2DB()
+{
+	PQfinish(mycon);
+}
+
+int Export2DB::connect()
+{
+	cout << conninf<< endl;
+	//mycon =PQconnectdb("user=postgres dbname=template1 hostaddr=127.0.0.1 port=5432");
+	mycon =PQconnectdb(conninf.c_str());
+
+	ConnStatusType type =PQstatus(mycon);
+		if(type==CONNECTION_BAD)
+		{
+			cout << "connection failed"<< endl;
+			return 1;
+		}
+		else
+		{
+			cout << "connection success"<< endl;
+			return 0;
+		}
+/***
+      CONNECTION_STARTED: Waiting for connection to be made.
+      CONNECTION_MADE: Connection OK; waiting to send.
+      CONNECTION_AWAITING_RESPONSE: Waiting for a response from the postmaster.
+      CONNECTION_AUTH_OK: Received authentication; waiting for backend start-up.
+	  CONNECTION_SETENV: Negotiating environment.
+***/
+}
+
+void Export2DB::createTables()
+{
+    std::string create_nodes("CREATE TABLE " + tables_prefix + "nodes (id bigint PRIMARY KEY, lon decimal(11,8), lat decimal(11,8), numOfUse int);");
+	PGresult *result = PQexec(mycon, create_nodes.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create Nodes failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+    } else {
+        std::cout << "Nodes table created" << std::endl;
+    }
+
+	// gid cannot be "bigint" right now because pgRouting doesn't support "bigint"
+    std::string create_ways("CREATE TABLE " + tables_prefix + "ways (gid integer, class_id integer not null, length double precision, name text, x1 double precision, y1 double precision, x2 double precision, y2 double precision, reverse_cost double precision, rule text, to_cost double precision, maxspeed_forward integer, maxspeed_backward integer, osm_id bigint, priority double precision DEFAULT 1);"
+            + " SELECT AddGeometryColumn('" + tables_prefix + "ways','the_geom',4326,'LINESTRING',2);");
+	result = PQexec(mycon, create_ways.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << PQresultStatus(result);
+        std::cerr << "create ways failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+    } else {
+        std::cout << "Ways table created" << std::endl;
+    }
+
+    std::string create_types("CREATE TABLE " + tables_prefix + "types (id integer PRIMARY KEY, name text);");
+	result = PQexec(mycon, create_types.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create types failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+	} else {
+        std::cout << "Types table created" << std::endl;
+    }
+
+    std::string create_way_tag("CREATE TABLE " + tables_prefix + "way_tag (type_id integer, class_id integer, way_id bigint);");
+	result = PQexec(mycon, create_way_tag.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create way_tag failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+	} else {
+        std::cout << "Way_tag table created" << std::endl;
+    }
+
+    std::string create_relations("CREATE TABLE " + tables_prefix + "relations (relation_id bigint, type_id integer, class_id integer, name text);");
+	result = PQexec(mycon, create_relations.c_str());
+    if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create relations failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+    } else {
+        std::cout << "Relations table created" << std::endl;
+    }
+
+    std::string create_relations_ways("CREATE TABLE " + tables_prefix + "relation_ways (relation_id bigint, way_id bigint, type character varying(200));");
+    result = PQexec(mycon, create_relations_ways.c_str());
+    if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create relation_ways failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+    } else {
+        std::cout << "Relation_ways table created" << std::endl;
+    }
+
+    std::string create_classes("CREATE TABLE " + tables_prefix + "classes (id integer PRIMARY KEY, type_id integer, name text, cost double precision, priority double precision, default_maxspeed integer);");
+	result = PQexec(mycon, create_classes.c_str());
+    if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "create classes failed: "
+        << PQerrorMessage(mycon)
+        << std::endl;
+        PQclear(result);
+    } else {
+		std::cout << "Classes table created" << std::endl;
+	}
+}
+
+void Export2DB::dropTables()
+{
+    std::string drop_tables( "DROP TABLE " + tables_prefix + "ways;"
+                            + " DROP TABLE " + tables_prefix + "nodes;"
+                            + " DROP TABLE " + tables_prefix + "types;"
+                            + " DROP TABLE " + tables_prefix + "classes;"
+                            + " DROP TABLE " + tables_prefix + "way_tag;"
+                            + " DROP TABLE " + tables_prefix + "relations;"
+                            + " DROP TABLE " + tables_prefix + "relation_ways;");
+	PGresult *result = PQexec(mycon, drop_tables.c_str());
+}
+
+void Export2DB::exportNodes(std::map<long long, Node*>& nodes)
+{
+	std::map<long long, Node*>::iterator it(nodes.begin());
+	std::map<long long, Node*>::iterator last(nodes.end());
+    std::string copy_nodes( "COPY " + tables_prefix + "nodes(id, lon, lat, numofuse) FROM STDIN");
+	//PGresult* res = PQexec(mycon, tables_prefix.c_str());
+	PGresult* res = PQexec(mycon, copy_nodes.c_str());
+	PQclear(res);
+	while(it!=last)
+	{
+		Node* node = (*it++).second;
+		std::string row_data = TO_STR(node->id);
+		row_data += "\t";
+		row_data += TO_STR(node->lon);
+		row_data += "\t";
+		row_data += TO_STR(node->lat);
+		row_data += "\t";
+		row_data += TO_STR(node->numsOfUse);
+		row_data += "\n";
+		PQputline(mycon, row_data.c_str());
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+}
+
+void Export2DB::exportRelations(std::vector<Relation*>& relations, Configuration* config)
+{
+	std::vector<Relation*>::iterator it_relation( relations.begin() );
+	std::vector<Relation*>::iterator last_relation( relations.end() );
+    std::string copy_relations( "COPY " + tables_prefix + "relations(relation_id, type_id, class_id, name) FROM STDIN");
+	PGresult* res = PQexec(mycon, copy_relations.c_str());
+	PQclear(res);
+	while( it_relation!=last_relation )
+	{
+		Relation* relation = *it_relation++;
+		std::map<std::string, std::string>::iterator it_tag( relation->m_Tags.begin() );
+		std::map<std::string, std::string>::iterator last_tag( relation->m_Tags.end() );
+		while( it_tag!=last_tag )
+		{
+			std::pair<std::string, std::string> pair = *it_tag++;
+			std::string row_data = TO_STR(relation->id);
+			row_data += "\t";
+			row_data += TO_STR(config->FindType(pair.first)->id);
+			row_data += "\t";
+			row_data += TO_STR(config->FindClass(pair.first, pair.second)->id);
+			row_data += "\t";
+			if(!relation->name.empty())
+  		{
+  			std::string escaped_name = relation->name;
+  			boost::replace_all(escaped_name, "\t", "\\\t");
+				row_data += escaped_name;
+			}
+			row_data += "\n";
+			PQputline(mycon, row_data.c_str());
+		}
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+
+	// Second round of iteration is needed to copy relation_ways
+	it_relation = relations.begin();
+    std::string copy_relation_ways( "COPY " + tables_prefix + "relation_ways(relation_id, way_id) FROM STDIN");
+	res = PQexec(mycon, copy_relation_ways.c_str());
+	PQclear(res);
+	while( it_relation!=last_relation )
+	{
+		Relation* relation = *it_relation++;
+		std::vector<long long>::iterator it_way( relation->m_WayRefs.begin() );
+		std::vector<long long>::iterator last_way( relation->m_WayRefs.end() );
+
+		while( it_way!=last_way )
+		{
+			long long way_id = *it_way++;
+			std::string row_data = TO_STR(relation->id);
+			row_data += "\t";
+			row_data += TO_STR(way_id);
+			row_data += "\n";
+			PQputline(mycon, row_data.c_str());
+		}
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+}
+
+/*
+<relation id="147411" version="5" timestamp="2010-01-22T17:02:14Z" uid="24299" user="james_hiebert" changeset="3684904">
+    <member type="way" ref="25584788" role=""/>
+    <member type="way" ref="35064036" role=""/>
+    <member type="way" ref="35064035" role=""/>
+    <member type="way" ref="35064037" role=""/>
+    <member type="way" ref="35064038" role=""/>
+    <member type="way" ref="35065746" role=""/>
+    <member type="way" ref="48690404" role=""/>
+    <member type="way" ref="24221632" role=""/>
+    <tag k="name" v="Mt. Douglas Park Local Connector"/>
+    <tag k="network" v="rcn"/>
+    <tag k="route" v="bicycle"/>
+    <tag k="type" v="route"/>
+  </relation>
+ */
+void Export2DB::exportWays(std::vector<Way*>& ways, Configuration* config)
+{
+	std::vector<Way*>::iterator it_way( ways.begin() );
+	std::vector<Way*>::iterator last_way( ways.end() );
+    std::string copy_way_tag( "COPY " + tables_prefix + "way_tag(type_id, class_id, way_id) FROM STDIN");
+	PGresult* res = PQexec(mycon, copy_way_tag.c_str());
+	PQclear(res);
+	while( it_way!=last_way )
+	{
+		Way* way = *it_way++;
+		std::map<std::string, std::string>::iterator it_tag( way->m_Tags.begin() );
+		std::map<std::string, std::string>::iterator last_tag( way->m_Tags.end() );
+		while( it_tag!=last_tag )
+		{
+			std::pair<std::string, std::string> pair = *it_tag++;
+			std::string row_data = TO_STR(config->FindType(pair.first)->id);
+			row_data += "\t";
+			row_data += TO_STR(config->FindClass(pair.first, pair.second)->id);
+			row_data += "\t";
+			row_data += TO_STR(way->id);
+			row_data += "\n";
+
+			PQputline(mycon, row_data.c_str());
+		}
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+
+	it_way = ways.begin();
+    std::string copy_ways( "COPY " + tables_prefix + "ways(gid, class_id, length, x1, y1, x2, y2, osm_id, the_geom, reverse_cost, maxspeed_forward, maxspeed_backward, priority, name) FROM STDIN");
+	res = PQexec(mycon, copy_ways.c_str());
+	while( it_way!=last_way )
+	{
+		Way* way = *it_way++;
+		std::string row_data = TO_STR(way->id);
+		row_data += "\t";
+		row_data += TO_STR(config->FindClass(way->type, way->clss)->id);
+		row_data += "\t";
+		//row_data += TO_STR(way->length);
+		//length based on oneway
+		if(way->oneWayType==REVERSED)
+			row_data += TO_STR(way->length*1000000);
+		else
+			row_data += TO_STR(way->length);
+
+		row_data += "\t";
+		row_data += TO_STR(way->m_NodeRefs.front()->lon);
+		row_data += "\t";
+		row_data += TO_STR(way->m_NodeRefs.front()->lat);
+		row_data += "\t";
+		row_data += TO_STR(way->m_NodeRefs.back()->lon);
+		row_data += "\t";
+		row_data += TO_STR(way->m_NodeRefs.back()->lat);
+		row_data += "\t";
+		row_data += TO_STR(way->osm_id);
+		row_data += "\t";
+		row_data += "srid=4326;" + way->geom;
+		row_data += "\t";
+
+		//reverse_cost
+		if(way->oneWayType==YES)
+	    	row_data += TO_STR(way->length*1000000);
+		else
+			row_data += TO_STR(way->length);
+
+		row_data += "\t";
+
+		//maxspeed
+		row_data += TO_STR(way->maxspeed_forward);
+		row_data += "\t";
+		row_data += TO_STR(way->maxspeed_backward);
+		row_data += "\t";
+
+		//priority
+		row_data += TO_STR(config->FindClass(way->type,way->clss)->priority);
+		row_data += "\t";
+
+		//name
+	  	if(!way->name.empty())
+	  	{
+	        std::string escaped_name = way->name;
+	        boost::replace_all(escaped_name, "\\", "");
+	        boost::replace_all(escaped_name, "\t", "\\\t");
+	        boost::replace_all(escaped_name, "\n", "");
+	        boost::replace_all(escaped_name, "\r", "");
+	        row_data += escaped_name.substr(0,199);
+	  	}
+		row_data += "\n";
+		//cout<<row_data<<endl;
+		PQputline(mycon, row_data.c_str());
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+}
+
+void Export2DB::exportTypesWithClasses(std::map<std::string, Type*>& types)
+{
+	std::map<std::string, Type*>::iterator tIt(types.begin());
+	std::map<std::string, Type*>::iterator tLast(types.end());
+    std::string copy_types( "COPY " + tables_prefix + "types(id, name) FROM STDIN");
+	PGresult* res = PQexec(mycon, copy_types.c_str());
+	PQclear(res);
+	while(tIt!=tLast)
+	{
+		Type* type = (*tIt++).second;
+		std::string row_data = TO_STR(type->id);
+		row_data += "\t";
+		row_data += type->name;
+		row_data += "\n";
+		PQputline(mycon, row_data.c_str());
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+
+	tIt = types.begin();
+    std::string copy_classes( "COPY " + tables_prefix + "classes(id, type_id, name, priority, default_maxspeed) FROM STDIN");
+	res = PQexec(mycon, copy_classes.c_str());
+	PQclear(res);
+	while(tIt!=tLast)
+	{
+		Type* type = (*tIt++).second;
+		std::map<std::string, Class*>& classes= type->m_Classes;
+		std::map<std::string, Class*>::iterator cIt(classes.begin());
+		std::map<std::string, Class*>::iterator cLast(classes.end());
+
+		while(cIt!=cLast)
+		{
+			Class* clss = (*cIt++).second;
+			std::string row_data = TO_STR(clss->id);
+			row_data += "\t";
+			row_data += TO_STR(type->id);
+			row_data += "\t";
+			row_data += clss->name;
+			row_data += "\t";
+			row_data += TO_STR(clss->priority);
+			row_data += "\t";
+			row_data += TO_STR(clss->default_maxspeed);
+			row_data += "\n";
+			PQputline(mycon, row_data.c_str());
+		}
+	}
+	PQputline(mycon, "\\.\n");
+	PQendcopy(mycon);
+}
+
+void Export2DB::createTopology()
+{
+    bool everything_fine = true;
+
+    std::string alter_ways_source( "ALTER TABLE " + tables_prefix + "ways ADD COLUMN source integer;");
+	PGresult *result = PQexec(mycon, alter_ways_source.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Alter table add source failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string alter_ways_target( "ALTER TABLE " + tables_prefix + "ways ADD COLUMN target integer;");
+	result = PQexec(mycon, alter_ways_target.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Alter table add target failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string source_idx("CREATE INDEX " + tables_prefix + "source_idx ON " + tables_prefix + "ways(source);");
+	result = PQexec(mycon, source_idx.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Create index add on source failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string target_idx("CREATE INDEX " + tables_prefix + "target_idx ON " + tables_prefix + "ways(target);");
+	result = PQexec(mycon, target_idx.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Create index add on target failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string geom_idx("CREATE INDEX " + tables_prefix + "geom_idx ON " + tables_prefix + "ways USING GIST (the_geom);");
+    result = PQexec(mycon, geom_idx.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Create geom index on ways failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string ways_gid_idx("CREATE UNIQUE INDEX "+ tables_prefix + "ways_gid_idx ON "+ tables_prefix + "ways(gid);");
+	result = PQexec(mycon, ways_gid_idx.c_str());
+	if (PQresultStatus(result) != PGRES_COMMAND_OK)
+    {
+        std::cerr << "Create unique index on ways failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    std::string create_topology("SELECT pgr_createTopology('"+ tables_prefix + "ways', 0.00001, 'the_geom', 'gid');");
+	result = PQexec(mycon, create_topology.c_str());
+	if (PQresultStatus(result) != PGRES_TUPLES_OK)
+    {
+        std::cerr << "Create Topology failed: " << PQerrorMessage(mycon) << std::endl;
+        PQclear(result);
+        everything_fine = false;
+	}
+
+    if (everything_fine) {
+        std::cout << "Create Topology success" << std::endl;
+    }
+}
diff --git a/src/Export2DB.h b/src/Export2DB.h
new file mode 100644
index 0000000..2d4af7b
--- /dev/null
+++ b/src/Export2DB.h
@@ -0,0 +1,90 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef EXPORT2DB_H
+#define EXPORT2DB_H
+
+//#include "postgresql/libpq-fe.h"
+#include "libpq-fe.h"
+#include "Node.h"
+#include "Way.h"
+#include "Relation.h"
+#include "Type.h"
+#include "Class.h"
+#include "Configuration.h"
+
+using namespace osm;
+
+/**
+ * This class connects to a postgresql database. For using this class,
+ * you also need to install postgis and pgrouting
+ */
+
+class Export2DB
+{
+public:
+	/**
+	 * Construktor
+	 * @param host Host address of the database
+	 * @param user a user, who has write access to the database
+	 * @param dbname name of the database
+	 *
+	 */
+ 	Export2DB(std::string host, std::string user, std::string dbname, std::string port, std::string password, std::string tables_prefix);
+ 	
+ 	/**
+ 	 * Destructor
+ 	 * closes the connection to the database
+ 	 */
+ 	~Export2DB();
+
+ 	//! connects to database
+ 	int connect();
+ 	//! creates needed tables
+ 	void createTables();
+ 	//! exports nodes to the database
+ 	void exportNodes(std::map<long long, Node*>& nodes);
+ 	//! exports ways to the database
+ 	void exportWays(std::vector<Way*>& ways, Configuration* config);
+ 	void exportRelations(std::vector<Relation*>& relations, Configuration* config);
+
+ 	void exportTypesWithClasses(std::map<std::string, Type*>& types);
+
+ 	/**
+ 	 * creates the topology
+ 	 * Be careful, it takes some time.
+ 	 *
+ 	 * for example:
+ 	 * complete germany: OSM file with a size of 1,1 GiB.
+ 	 * Export and create topology:
+ 	 * time took circa 30 hours on an Intel Xeon 2,4 GHz with 2 GiB Ram.
+ 	 * But only for the streettypes "motorway", "primary" and "secondary"
+ 	 */
+ 	void createTopology();
+ 	//! Be careful! It deletes the created tables!
+ 	void dropTables();
+
+private:
+	PGconn *mycon;
+	std::string conninf;
+	std::string tables_prefix;
+};
+
+#endif
diff --git a/src/Node.cpp b/src/Node.cpp
new file mode 100644
index 0000000..ff633c1
--- /dev/null
+++ b/src/Node.cpp
@@ -0,0 +1,40 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Node.h"
+
+namespace osm
+{
+
+Node::Node( long long id, double lat, double lon )
+:
+	id(id),
+	lat(lat),
+	lon(lon)
+{
+	this->numsOfUse=0;
+}
+
+Node::~Node()
+{
+}
+
+} // end namespace osm
diff --git a/src/Node.h b/src/Node.h
new file mode 100644
index 0000000..bfd05d1
--- /dev/null
+++ b/src/Node.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef NODE_H
+#define NODE_H
+
+namespace osm
+{
+
+/**
+\code
+  <node id="122603925" 
+		lat="53.0780875" 
+		lon="8.1351704" 
+		user="artus70" visible="true" timestamp="2007-11-18T22:18:59+00:00"/>
+\endcode
+*/
+class Node
+{
+public:
+	//! ID of the node
+	long long id;
+	//! latitude coordinate
+	double lat;
+	//! longitude coordinate
+	double lon;
+	/**
+	 *	counts the rate, how much this node is used in different ways
+	 */
+	unsigned short numsOfUse;
+public:
+	/**
+	 *	Construktor
+	 * 	@param id ID of the node
+	 *	@param lat latitude
+	 *	@param lon longitude
+	 */
+	Node( long long id=-1, double lat=0, double lon=0 );
+	//! Destructor
+	virtual ~Node();
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/OSMDocument.cpp b/src/OSMDocument.cpp
new file mode 100644
index 0000000..d630d5e
--- /dev/null
+++ b/src/OSMDocument.cpp
@@ -0,0 +1,172 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "OSMDocument.h"
+#include "Configuration.h"
+#include "Node.h"
+#include "Relation.h"
+#include "Way.h"
+#include "math_functions.h"
+
+
+namespace osm
+{
+
+OSMDocument::OSMDocument( Configuration& config ) : m_rConfig( config )
+{
+}
+
+OSMDocument::~OSMDocument()
+{
+	ez_mapdelete( m_Nodes );
+	ez_vectordelete( m_Ways );		
+	ez_vectordelete( m_Relations );		
+	ez_vectordelete( m_SplittedWays );
+}
+void OSMDocument::AddNode( Node* n )
+{
+	m_Nodes[n->id] = n;
+}
+
+void OSMDocument::AddWay( Way* w )
+{
+	m_Ways.push_back( w );
+}
+
+void OSMDocument::AddRelation( Relation* r )
+{
+	m_Relations.push_back( r );
+}
+
+Node* OSMDocument::FindNode( long long nodeRefId ) 
+const
+{
+	std::map<long long, Node*>::const_iterator  it = m_Nodes.find( nodeRefId );
+	return (it!=m_Nodes.end() ) ? it->second : 0;
+}
+
+void OSMDocument::SplitWays()
+{
+	
+	std::vector<Way*>::const_iterator it(m_Ways.begin());
+	std::vector<Way*>::const_iterator last(m_Ways.end());
+
+	//splitted ways get a new ID
+	long long id=0;
+
+	while(it!=last)
+	{
+		Way* currentWay = *it++;
+		
+		// ITERATE THROUGH THE NODES
+		std::vector<Node*>::const_iterator it_node( currentWay->m_NodeRefs.begin());	
+		std::vector<Node*>::const_iterator last_node( currentWay->m_NodeRefs.end());
+		
+		Node* backNode = currentWay->m_NodeRefs.back();
+
+		while(it_node!=last_node)
+		{
+			
+			Node* node = *it_node++;
+			Node* secondNode=0;
+			Node* lastNode=0;
+			
+			Way* splitted_way = new Way( ++id, currentWay->visible, currentWay->osm_id, currentWay->maxspeed_forward, currentWay->maxspeed_backward );
+			splitted_way->name=currentWay->name;
+			splitted_way->type=currentWay->type;
+			splitted_way->clss=currentWay->clss;
+			splitted_way->oneWayType=currentWay->oneWayType;
+			
+			std::map<std::string, std::string>::iterator it_tag( currentWay->m_Tags.begin() );
+			std::map<std::string, std::string>::iterator last_tag( currentWay->m_Tags.end() );
+//			std::cout << "Number of tags: " << currentWay->m_Tags.size() << std::endl;
+//			std::cout << "First tag: " << currentWay->m_Tags.front()->key << ":" << currentWay->m_Tags.front()->value << std::endl;
+		
+			// ITERATE THROUGH THE TAGS
+		
+			while(it_tag!=last_tag)
+			{
+				std::pair<std::string, std::string> pair = *it_tag++;
+
+				splitted_way->AddTag(pair.first, pair.second);
+				
+			}
+			
+			
+
+	//GeometryFromText('LINESTRING('||x1||' '||y1||','||x2||' '||y2||')',4326);
+			
+			splitted_way->geom="LINESTRING("+ boost::lexical_cast<std::string>(node->lon) + " " + boost::lexical_cast<std::string>(node->lat) +",";
+			
+			splitted_way->AddNodeRef(node);
+			
+			bool found=false;
+			
+			if(it_node!=last_node)
+			{
+				while(it_node!=last_node && !found)
+				{
+					splitted_way->AddNodeRef(*it_node);
+					if((*it_node)->numsOfUse>1)
+					{
+						found=true;
+						secondNode = *it_node;
+						splitted_way->AddNodeRef(secondNode);
+						double length = getLength(node,secondNode);
+						if(length<0)
+							length*=-1;
+						splitted_way->length+=length;
+						splitted_way->geom+= boost::lexical_cast<std::string>(secondNode->lon) + " " + boost::lexical_cast<std::string>(secondNode->lat) + ")";
+						
+					}
+					else if(backNode==(*it_node))
+					{
+						lastNode=*it_node++;
+						splitted_way->AddNodeRef(lastNode);
+						double length = getLength(node,lastNode);
+						if(length<0)
+							length*=-1;
+						splitted_way->length+=length;
+						splitted_way->geom+= boost::lexical_cast<std::string>(lastNode->lon) + " " + boost::lexical_cast<std::string>(lastNode->lat) + ")";
+					}
+					else
+					{
+						splitted_way->geom+= boost::lexical_cast<std::string>((*it_node)->lon) + " " + boost::lexical_cast<std::string>((*it_node)->lat) + ",";
+						*it_node++;
+					}
+				}
+			}
+				
+			if(splitted_way->m_NodeRefs.front()!=splitted_way->m_NodeRefs.back())
+				m_SplittedWays.push_back(splitted_way);
+			else
+			{
+				delete splitted_way;
+				splitted_way=0;
+			}
+				
+		}
+
+	}
+
+} // end SplitWays
+
+} // end namespace osm
diff --git a/src/OSMDocument.h b/src/OSMDocument.h
new file mode 100644
index 0000000..0bb1f3a
--- /dev/null
+++ b/src/OSMDocument.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef OSMDOCUMENT_H
+#define OSMDOCUMENT_H
+
+#include "Configuration.h"
+
+namespace osm
+{
+
+
+class Node;
+class Way;
+class Relation;
+
+/**
+	An osm-document.
+*/
+class OSMDocument
+{
+public:
+	//! Map, which saves the parsed nodes
+	std::map<long long, Node*> m_Nodes;
+	//! parsed ways
+	std::vector<Way*> m_Ways;
+	//! splitted ways
+	std::vector<Way*> m_SplittedWays;
+
+	std::vector<Relation*> m_Relations;
+
+
+	Configuration& m_rConfig;
+public:
+
+	//! Constructor
+	OSMDocument( Configuration& config);
+	//! Destructor
+	virtual ~OSMDocument();
+	//! add node to the map
+	void AddNode( Node* n );
+	//! add way to the map
+	void AddWay( Way* w );
+	//! find node by using an ID
+	Node* FindNode( long long nodeRefId ) const;
+	//! split the ways
+	void SplitWays();
+	//Node* getNode( long long nodeRefId );
+
+	void AddRelation( Relation* r );
+
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/OSMDocumentParserCallback.cpp b/src/OSMDocumentParserCallback.cpp
new file mode 100644
index 0000000..2c8fbc6
--- /dev/null
+++ b/src/OSMDocumentParserCallback.cpp
@@ -0,0 +1,362 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "OSMDocumentParserCallback.h"
+#include "OSMDocument.h"
+#include "Relation.h"
+#include "Way.h"
+#include "Node.h"
+#include "utils.h"
+
+// define here, which streetstype you want to parse
+// for applying this filter, compile with "DISTRICT" as flag (g++ -DRESTRICT)
+//#define _FILTER if(m_pActWay->highway == "motorway" || m_pActWay->highway == "primary" || m_pActWay->highway == "secondary")
+
+namespace osm
+{
+	
+	
+/*
+<relation id="147411" version="5" timestamp="2010-01-22T17:02:14Z" uid="24299" user="james_hiebert" changeset="3684904">
+    <member type="way" ref="25584788" role=""/>
+    <member type="way" ref="35064036" role=""/>
+    <member type="way" ref="35064035" role=""/>
+    <member type="way" ref="35064037" role=""/>
+    <member type="way" ref="35064038" role=""/>
+    <member type="way" ref="35065746" role=""/>
+    <member type="way" ref="48690404" role=""/>
+    <member type="way" ref="24221632" role=""/>
+    <tag k="name" v="Mt. Douglas Park Local Connector"/>
+    <tag k="network" v="rcn"/>
+    <tag k="route" v="bicycle"/>
+    <tag k="type" v="route"/>
+  </relation>
+ */
+
+	
+/**
+	Parser callback for OSMDocument files
+*/
+void OSMDocumentParserCallback::StartElement( const char *name, const char** atts )
+{
+	// START RELATIONS CODE
+	if( strcmp(name,"member") == 0 )
+	{
+		// std::cout << "In member..." << std::endl;
+		
+		if( m_pActRelation && atts != NULL )
+		{
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* name = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( name, "ref" ) == 0 )
+				{
+					long long wayRefId = atoll( value );
+                	m_pActRelation->AddWayRef( wayRefId );
+				}
+			}
+		}
+	} 
+	// END RELATIONS CODE
+
+
+	if( strcmp(name,"nd") == 0 )
+	{
+		if( m_pActWay && atts != NULL )
+		{
+			const char* name = *atts++;
+			const char* value = *atts++;
+			if( strcmp(name,"ref")==0 )
+			{
+				long long nodeRefId = atoll( value );
+                                m_pActWay->AddNodeRef( m_rDocument.FindNode( nodeRefId ) );
+                                  Node * node = m_rDocument.FindNode( nodeRefId );
+                                  if(node != 0 ){
+                                    node->numsOfUse+=1;
+                                  }else {
+                                    std::cout << "Reference nd=" << nodeRefId << " has no corresponding Node Entry (Maybe Node entry after Reference?)" << std::endl;
+                                  }
+			}
+		}
+	} 
+	else if( strcmp(name,"node") == 0 )
+	{
+		if (atts != NULL)
+		{
+			long long id=-1;
+			double lat=-1;
+			double lon=-1;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* name = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( name, "id" ) == 0 )
+				{
+					id = atoll( value);
+				}
+				else if( strcmp( name, "lat" ) == 0 )
+				{
+					lat = atof( value );
+				}
+				else if( strcmp( name, "lon" ) == 0 )
+				{
+					lon = atof( value );
+				}
+			}
+			if( id>0 ) m_rDocument.AddNode( new Node( id, lat, lon ) );
+		}
+	}
+	// THIS IS THE RELATION CODE...
+	else if( strcmp(name,"relation") == 0 )
+	{
+		if (atts != NULL)
+		{
+			long long id=-1;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* name = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( name, "id" ) == 0 )
+				{
+					id = atoll( value);
+				}
+			}
+			if( id>0 ) m_pActRelation = new Relation( id );
+			// std::cout<<"Starting relation: "<<id<<std::endl;
+
+		}
+	}
+	// END OF THE RELATIONS CODE
+	else if( strcmp(name,"tag") == 0 )
+	{
+		// <tag k="name" v="Pf�nderweg"/>
+		if (atts != NULL)
+		{
+			std::string k;
+			std::string v;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* name = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( name, "k" ) == 0 )
+				{
+					k = value;
+				}
+				else if( strcmp( name, "v" ) == 0 )
+				{
+					v = value;
+				}
+			}
+			if( !k.empty() )
+			{
+				//  CHECKING OUT SOME DATA...
+				// std::cout<<"k: "<<k<<", v: "<<v<<std::endl;
+				// std::cout<<"m_pActWay: "<<m_rDocument.m_rConfig.m_Types.count(k)<<std::endl;
+				// std::cout<<"thecount: "<<m_rDocument.m_rConfig.m_Types.count(k)<<std::endl;
+				if( m_pActWay && k.compare("name")==0 )
+				{
+					m_pActWay->name = v;
+				}
+				//checks ONEWAY tag
+				else if( m_pActWay && k.compare("oneway")==0 ){
+					if ((v.compare("yes")==0) || (v.compare("true")==0) || (v.compare("1")==0)){
+						m_pActWay->oneWayType = YES;
+					}else
+					//check false conditions: 0, no, false
+					if ((v.compare("no")==0) || (v.compare("false")==0) || (v.compare("0")==0)){
+						m_pActWay->oneWayType = NO;
+					}else
+					//check revers conditions: -1
+					if ((v.compare("-1")==0)){
+						m_pActWay->oneWayType = REVERSED;
+					}
+				//in case roundabout, if there is not additional oneway tag, set default oneway to YES
+				}else if(m_pActWay && k.compare("junction")==0 && v.compare("roundabout")==0){
+					if (m_pActWay->oneWayType == NO) m_pActWay->oneWayType= YES;
+				}
+				//handle maxspeed:forward tag
+				else if(m_pActWay && k.compare("maxspeed:forward")==0){
+					int mspeed_fwd = 50;
+
+					if(my_utils::is_number(v)){
+						mspeed_fwd = atoi(v.c_str());
+					}else{
+						//TODO: handle non-numeric values, ex.: RO:urban
+						std::cout<<"unknown maxspeed value: "<<v<<std::endl;
+					}
+					m_pActWay->maxspeed_forward = mspeed_fwd;
+				}
+				//handler maxspeed:backward
+				else if(m_pActWay && k.compare("maxspeed:backward")==0){
+					int mspeed_backwd = 50;
+
+					if(my_utils::is_number(v)){
+						mspeed_backwd = atoi(v.c_str());
+					}else{
+						//TODO: handle non-numeric values, ex.: RO:urban
+						std::cout<<"unknown maxspeed value: "<<v<<std::endl;
+					}
+					m_pActWay->maxspeed_backward= mspeed_backwd;
+				}
+				else if(m_pActWay && k.compare("maxspeed")==0){
+					int mspeed_fwd = 50;
+					int mspeed_backwd = 50;
+
+					if(my_utils::is_number(v)){
+						mspeed_fwd = atoi(v.c_str());
+						mspeed_backwd = atoi(v.c_str());
+					}else{
+						//TODO: handle non-numeric values, ex.: RO:urban
+						std::cout<<"unknown maxspeed value: "<<v<<std::endl;
+					}
+					m_pActWay->maxspeed_backward= mspeed_backwd;
+					m_pActWay->maxspeed_forward=mspeed_fwd;
+				}
+				//else if( m_pActWay && k.compare("highway")==0 )
+				else if( m_pActWay && m_rDocument.m_rConfig.m_Types.count(k) )				
+				{
+					m_pActWay->type = k;
+					m_pActWay->clss = v;
+					
+					
+					if( m_rDocument.m_rConfig.m_Types.count(m_pActWay->type) && m_rDocument.m_rConfig.m_Types[m_pActWay->type]->m_Classes.count(m_pActWay->clss) ) {
+						
+						m_pActWay->AddTag( k, v );
+
+						// std::cout<<"Added tag: "<<k<<" "<<v<<std::endl;
+
+						//set default maxspeed values from classes, if not set previously (default: -1)
+						if(m_pActWay->maxspeed_forward<=0){
+							int newValue = m_rDocument.m_rConfig.m_Types[m_pActWay->type]->m_Classes[m_pActWay->clss]->default_maxspeed;
+							m_pActWay->maxspeed_forward = newValue;
+						}
+						if(m_pActWay->maxspeed_backward<=0){
+							int newValue = m_rDocument.m_rConfig.m_Types[m_pActWay->type]->m_Classes[m_pActWay->clss]->default_maxspeed;
+							m_pActWay->maxspeed_backward = newValue;
+						}
+
+					}
+				}
+				// START TAG FOR RELATION
+				else if( m_pActRelation && m_rDocument.m_rConfig.m_Types.count(k)) 
+				{
+					if( m_rDocument.m_rConfig.m_Types.count(k) && m_rDocument.m_rConfig.m_Types[k]->m_Classes.count(v) ) {
+						
+						m_pActRelation->AddTag( k, v );
+						// std::cout<<"Added Relation tag: "<<k<<" "<<v<<std::endl;
+					}	
+					// std::cout<<"Relations tag: "<<k<<" "<<v<<std::endl;
+				}
+								
+				if (m_pActRelation && k.compare("name")==0 )
+				{
+					m_pActRelation->name = v;
+				}
+				
+				
+				// END TAG FOR RELATION
+			}
+		}
+	}
+	else if( strcmp(name,"way") == 0 )
+	{
+		if (atts != NULL)
+		{
+			long long id=-1;
+			bool visibility = false;
+			const char** attribut = (const char**)atts;
+			while( *attribut != NULL )
+			{
+				const char* name = *attribut++;
+				const char* value = *attribut++;
+				if( strcmp( name, "id" ) == 0 )
+				{
+					id = atoll( value);
+				}
+				else if( strcmp( name, "visible" ) == 0 )
+				{
+					visibility = strcmp(value,"true")==0;
+				}
+
+			}
+			if( id>0 )
+			{
+				m_pActWay = new Way( id, visibility, id ,-1, -1);
+				
+			}
+		}
+	}
+	else if( strcmp(name,"osm") == 0 )
+	{
+	}
+}
+
+
+
+void OSMDocumentParserCallback::EndElement( const char* name )
+{
+	if( strcmp(name,"way") == 0 )
+	{
+		//#ifdef RESTRICT
+		//_FILTER
+		
+		if( m_rDocument.m_rConfig.m_Types.count(m_pActWay->type) && m_rDocument.m_rConfig.m_Types[m_pActWay->type]->m_Classes.count(m_pActWay->clss) )
+		{
+		//#endif
+		
+		// Comment out the following to get more log output
+		//std::cout<<"We need a way of type "<<m_pActWay->type<<" and class "<< m_pActWay->clss<<std::endl;
+		
+			m_rDocument.AddWay( m_pActWay );
+			// std::cout << "First tag: " << m_pActWay->m_Tags.back()->key << ":" << m_pActWay->m_Tags.back()->value << std::endl;
+
+
+		//#ifdef RESTRICT
+		}
+		else
+		{
+		// std::cout<<"We DON'T need a way of type "<<m_pActWay->type<<" and class "<< m_pActWay->clss<<std::endl;
+			// delete m_pActWay;
+		}
+		//#endif
+
+		m_pActWay = 0;
+	}
+	// THIS IS THE RELATION CODE...
+	else if( strcmp(name,"relation") == 0 )
+	{
+		m_rDocument.AddRelation( m_pActRelation );
+		m_pActRelation = 0;		
+
+		// std::cout<<"Adding relation: "<<m_pActRelation->id<<std::endl;
+	}
+	// END OF THE RELATIONS CODE
+	
+	
+	
+}
+
+}; // end namespace osm
diff --git a/src/OSMDocumentParserCallback.h b/src/OSMDocumentParserCallback.h
new file mode 100644
index 0000000..3b7b8b7
--- /dev/null
+++ b/src/OSMDocumentParserCallback.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef OSMDOCUMENTPARSERCALLBACK_H
+#define OSMDOCUMENTPARSERCALLBACK_H
+
+#include <string.h>
+#include "XMLParser.h"
+
+namespace osm
+{
+
+class OSMDocument;
+class Way;
+class Relation;
+
+/**
+	Parser callback for OSMDocument files
+*/
+class OSMDocumentParserCallback : public xml::XMLParserCallback
+{	
+	//! reference to a OSMDocument object
+	OSMDocument& m_rDocument;
+	//! current way, which will be parsed
+	Way* m_pActWay;
+	Relation* m_pActRelation;
+
+	virtual void StartElement( const char *name, const char** atts );
+
+	virtual void EndElement( const char* name );
+
+	virtual void SetContent( const char* ch, int len)
+	{
+	}
+
+	virtual void ProcessingInstruction( const char* target, const char* data )
+	{
+	}
+
+	virtual void CDataBlockInternal(const char *value, int len)
+	{
+	}
+
+
+public:
+	/**
+	 *	Constructor
+	 */
+	OSMDocumentParserCallback( OSMDocument& doc )
+	:
+		m_rDocument( doc ),
+		m_pActWay( 0 ),
+		m_pActRelation( 0 )
+
+	{
+	}
+
+}; // class OSMDocumentParserCallback
+
+}; // end namespace osm
+
+#endif
diff --git a/src/Relation.cpp b/src/Relation.cpp
new file mode 100644
index 0000000..22431b5
--- /dev/null
+++ b/src/Relation.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Relation.h"
+#include "Way.h"
+
+
+namespace osm
+{
+
+Relation::Relation( long long id )
+:
+	id(id)
+{
+}
+
+Relation::~Relation()
+{
+}
+
+void Relation::AddWayRef( long long pID )
+{
+	if( pID ) m_WayRefs.push_back(pID);
+}
+
+void Relation::AddTag( std::string key, std::string value)
+{
+	m_Tags[key] = value;
+}
+
+} // end namespace osm
+
diff --git a/src/Relation.h b/src/Relation.h
new file mode 100644
index 0000000..3ac02c2
--- /dev/null
+++ b/src/Relation.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#ifndef RELATION_H
+#define RELATION_H
+
+namespace osm
+{
+	class Way;
+
+/**
+\code
+ <way id="20215432" visible="true" timestamp="2008-01-09T22:35:16+00:00" user="Pferdo">
+    <nd ref="213794929"/>
+    <nd ref="213795470"/>
+    <nd ref="213795483"/>
+    <nd ref="213795493"/>
+    <nd ref="213795506"/>
+    <nd ref="213795517"/>
+    <nd ref="213795527"/>
+    <nd ref="213795541"/>
+    <nd ref="213795552"/>
+    <nd ref="213795561"/>
+    <nd ref="213795571"/>
+    <tag k="name" v="Pf�nderweg"/>
+    <tag k="created_by" v="JOSM"/>
+    <tag k="highway" v="residential"/>
+  </way>
+\endcode
+*/
+class Relation
+{
+public:
+	long long id;
+    std::string name;
+	std::vector<long long> m_WayRefs;
+	std::map<std::string, std::string> m_Tags;
+
+public:
+	/** 
+	 *	Constructor
+	 *	@param id ID of the way
+	 */
+	Relation( long long id );
+	//! Destructor
+	~Relation();
+	/**
+	 *	saves the nodes of the way  
+	 *	@param pNode node
+	 */
+	void AddWayRef( long long pID );
+	void AddTag(std::string key, std::string value);
+
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/Type.cpp b/src/Type.cpp
new file mode 100644
index 0000000..dfeb03d
--- /dev/null
+++ b/src/Type.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+*   Copyright (C) 2008 by Daniel Wendt                                    *
+*   gentoo.murray at gmail.com                                               *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+                  
+#include "stdafx.h"
+#include "Type.h"
+
+namespace osm
+{
+
+Type::Type( long long id, std::string name)
+:
+  id(id),
+  name(name)
+{
+}
+                        
+Type::~Type()
+{
+}
+                        
+void Type::AddClass( Class* pClass )
+{
+  if( pClass ) m_Classes[pClass->name] = pClass;
+}
+                                
+
+} // end namespace osm
diff --git a/src/Type.h b/src/Type.h
new file mode 100644
index 0000000..b5dcfc0
--- /dev/null
+++ b/src/Type.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+*   Copyright (C) 2008 by Daniel Wendt                                    *
+*   gentoo.murray at gmail.com                                               *
+*                                                                         *
+*   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.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+                  
+#ifndef TYPE_H
+#define TYPE_H
+
+#include "Class.h"
+
+namespace osm
+{
+
+class Type
+{
+public:
+	//std::vector<Class*> m_ClassRefs;
+	std::map<std::string, Class*> m_Classes;
+	//std::map<long long, Class*> m_Classes;
+	long long id;
+	std::string name;
+public:
+	/** 
+	 *	Constructor
+	 *	@param name name of the type
+	 */
+	Type( long long id, std::string );
+	//! Destructor
+	~Type();
+	/**
+	 *	saves the classes of the type
+	 *	@param pClass class
+	 */
+	void AddClass( Class* pClass );
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/Way.cpp b/src/Way.cpp
new file mode 100644
index 0000000..28767de
--- /dev/null
+++ b/src/Way.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Way.h"
+
+
+namespace osm
+{
+
+Way::Way( long long id, bool visible, long long osm_id, int maxspeed_forward, int maxspeed_backward)
+:
+	id(id),
+	visible(visible),
+	length(0),
+	oneWayType(NO),
+	osm_id(osm_id),
+	maxspeed_forward(maxspeed_forward),
+	maxspeed_backward(maxspeed_backward)
+{
+}
+
+Way::~Way()
+{
+}
+
+void Way::AddNodeRef( Node* pNode )
+{
+	if( pNode ) m_NodeRefs.push_back(pNode);
+}
+
+void Way::AddTag( std::string key , std::string value)
+{
+	m_Tags[key] = value;
+}
+
+bool Way::HasTag(std::string key)
+{
+	return (m_Tags.count(key)>0);
+}
+
+
+
+} // end namespace osm
+
diff --git a/src/Way.h b/src/Way.h
new file mode 100644
index 0000000..66fc498
--- /dev/null
+++ b/src/Way.h
@@ -0,0 +1,101 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#ifndef WAY_H
+#define WAY_H
+
+namespace osm
+{
+	class Node;
+
+	enum OneWayType{ YES, NO, REVERSED};
+
+/**
+\code
+ <way id="20215432" visible="true" timestamp="2008-01-09T22:35:16+00:00" user="Pferdo">
+    <nd ref="213794929"/>
+    <nd ref="213795470"/>
+    <nd ref="213795483"/>
+    <nd ref="213795493"/>
+    <nd ref="213795506"/>
+    <nd ref="213795517"/>
+    <nd ref="213795527"/>
+    <nd ref="213795541"/>
+    <nd ref="213795552"/>
+    <nd ref="213795561"/>
+    <nd ref="213795571"/>
+    <tag k="name" v="Pf�nderweg"/>
+    <tag k="created_by" v="JOSM"/>
+    <tag k="highway" v="residential"/>
+  </way>
+\endcode
+*/
+class Way
+{
+public:
+	//! Do not delete nodes in this container!
+	std::vector<Node*> m_NodeRefs;
+	std::map<std::string, std::string> m_Tags;
+	//! ID of the way
+	long long id;
+	bool visible;
+	//! name of the street
+	std::string name;
+	//! type of the street, for example "motorway"
+	//std::string highway;
+	
+	std::string type;
+	std::string clss;
+
+	//long long type;
+	//long long clss;
+	
+	//! geometry of the street
+	std::string geom;
+	//! length of the street
+	double length;
+
+	int maxspeed_forward;
+	int maxspeed_backward;
+
+	OneWayType oneWayType;
+	
+	long long osm_id;
+
+
+public:
+	/** 
+	 *	Constructor
+	 *	@param id ID of the way
+	 */
+	Way( long long id, bool visible, long long osm_id,  int maxspeed_forward, int maxspeed_backward);
+	//! Destructor
+	~Way();
+	/**
+	 *	saves the nodes of the way  
+	 *	@param pNode node
+	 */
+	void AddNodeRef( Node* pNode );
+	void AddTag( std::string key, std::string value);
+	bool HasTag(std::string key);
+};
+
+
+} // end namespace osm
+#endif
diff --git a/src/XMLParser.cpp b/src/XMLParser.cpp
new file mode 100644
index 0000000..0603990
--- /dev/null
+++ b/src/XMLParser.cpp
@@ -0,0 +1,93 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <cstdio> 
+#include <errno.h>
+#include <string.h>
+#include "stdafx.h"
+#include "XMLParser.h"
+
+
+namespace xml
+{
+
+//------------------------------------- global Expat Callbacks:
+
+static void startElement(void *userData, const char *name, const char **atts)
+{
+	XMLParserCallback* pCallback = (XMLParserCallback*) userData;
+	if( pCallback ) pCallback->StartElement( name, atts );
+}
+
+static void endElement(void *userData, const char *name)
+{
+	XMLParserCallback* pCallback = (XMLParserCallback*) userData;
+	if( pCallback ) pCallback->EndElement( name );
+}
+
+
+
+
+int XMLParser::Parse( XMLParserCallback& rCallback, const char* chFileName )
+{
+  int ret = 1; // File not found
+
+  FILE* fp = fopen(chFileName,"rb");
+  if( fp )
+  {
+    XML_Parser parser = XML_ParserCreate(NULL);
+
+    XML_SetUserData( parser, (void*)&rCallback );
+
+    // register Callbacks for start- and end-element events of the parser:
+    XML_SetElementHandler(parser, startElement, endElement);
+
+    int done;
+    do // loop over whole file content
+    {
+      char buf[BUFSIZ];
+      size_t len = fread(buf, 1, sizeof(buf), fp);	// read chunk of data
+      done = len < sizeof(buf);	// end of file reached if buffer not completely filled
+      if (!XML_Parse(parser, buf, (int)len, done))
+  	{
+  	  // a parse error occured:
+        fprintf(stderr,
+  	      "%s at line %d\n",
+  	      XML_ErrorString(XML_GetErrorCode(parser)),(int)
+  	      XML_GetCurrentLineNumber(parser));
+  	       fclose(fp);
+        ret = 2;	// quit, return = 2 indicating parsing error
+        done = 1;
+      }
+    } while (!done);
+
+    XML_ParserFree(parser);
+    fclose(fp);
+    ret = 0;
+  }else{
+    fprintf(stderr, "Error opening %s: %s\n", chFileName, strerror(errno));
+  }
+  return ret; // return = 0 indicating success
+}
+
+
+
+} // end namespace xml
+//! \endcond
diff --git a/src/XMLParser.h b/src/XMLParser.h
new file mode 100644
index 0000000..db66d09
--- /dev/null
+++ b/src/XMLParser.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef XMLPARSERT_H
+#define XMLPARSERT_H
+
+#include <expat.h>
+
+
+namespace xml
+{
+
+/**
+    Callback to be used with XMLParser 
+ */
+class XMLParserCallback
+{
+public:
+
+  //! Constructor_
+  XMLParserCallback(){}
+  //! Destructor
+  virtual ~XMLParserCallback(){}
+
+  /**
+    Implement to construct an element with the given name,
+    call back for parser event "start element"
+    
+    \param name  [IN]  element name
+    \param atts  [IN]  the attributes
+   */  
+	virtual void StartElement( const char *name, const char** atts )=0;
+
+  /**
+    Implement to process parser event "end element"
+    */
+	virtual void EndElement( const char *elementName )=0;
+
+
+};
+
+/**
+  XML-Parser based on expat library by 
+  James Clark http://www.jclark.com/xml/expat.html.
+  
+  Fast, event driven, non-validating parser
+  
+  Dependencies:
+  - link with xmlparse.lib
+  - uses xmlparse.dll
+*/
+class XMLParser
+{
+
+public:
+  //! Constructor
+	XMLParser(){}
+	//! Destructor
+	virtual ~XMLParser(){}
+
+  /**
+    Parse a file from the file system-
+    
+    \param rCallback [IN] the parser callback
+    \param chFileName [IN] name of the file to be parsed  
+    
+    \return 0: everything ok, 1: file not found, 2: parsing error
+   */  
+	int Parse( XMLParserCallback& rCallback, const char* chFileName );
+
+private:
+	//! the expat parser object / imported from „expat.h“
+	XML_Parser			m_ParserCtxt;
+
+};
+
+} // end namespace xml
+#endif
diff --git a/src/math_functions.cpp b/src/math_functions.cpp
new file mode 100644
index 0000000..4dda6b0
--- /dev/null
+++ b/src/math_functions.cpp
@@ -0,0 +1,41 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "math_functions.h"
+#include <math.h>
+
+// calculation of the lenght is correct???
+double getLength(Node* a, Node* b)
+{
+	int R = 6371; //km
+	double PI =3.141592653589793238462643;
+
+	double dLat=(b->lat -a->lat)*PI/180;
+	double dLon=(b->lon -a->lon)*PI/180;
+
+	double c = sin(dLat/2) * sin(dLat/2) + cos(a->lat*PI/180) * cos(b->lat*PI/180) * sin(dLon/2) * sin(dLon/2);
+
+	double d = 2 * atan2(sqrt(c), sqrt(1-c)); 
+
+	return R*d;
+
+}
+
diff --git a/src/math_functions.h b/src/math_functions.h
new file mode 100644
index 0000000..397429d
--- /dev/null
+++ b/src/math_functions.h
@@ -0,0 +1,31 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef MATH_FUNCTIONS_H
+#define MATH_FUNCTIONS_H
+
+#include "Node.h"
+
+using namespace osm;
+
+double getLength(Node* a, Node* b);
+
+
+#endif
diff --git a/src/osm2pgrouting.cpp b/src/osm2pgrouting.cpp
new file mode 100644
index 0000000..ea9686e
--- /dev/null
+++ b/src/osm2pgrouting.cpp
@@ -0,0 +1,258 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "stdafx.h"
+#include "Configuration.h"
+#include "ConfigurationParserCallback.h"
+#include "OSMDocument.h"
+#include "OSMDocumentParserCallback.h"
+#include "Way.h"
+#include "Node.h"
+#include "Relation.h"
+#include "Export2DB.h"
+
+using namespace osm;
+using namespace xml;
+using namespace std;
+
+void _error()
+{
+				cout << "following params are required: " << endl;
+				cout << "-file <file>  -- name of your osm xml file" << endl;
+				cout << "-conf <conf>  -- name of your configuration xml file" << endl;
+				cout << "-dbname <dbname> -- name of your database" << endl;
+				cout << "-user <user> -- name of the user, which have write access to the database" << endl;
+				cout << "optional:" << endl;
+				cout << "-host <host>  -- host of your postgresql database (default: 127.0.0.1)" << endl;
+				cout << "-port <port> -- port of your database (default: 5432)" << endl;
+				cout << "-passwd <passwd> --  password for database access" << endl;
+				cout << "-prefixtables <prefix> --  add at the beginning of table names" << endl;
+				cout << "-clean -- drop previously created tables" << endl;
+                cout << "-skipnodes -- don't import the nodes table" << endl;
+
+
+}
+
+int main(int argc, char* argv[])
+{
+	std::string file;
+	std::string cFile;
+	std::string host="127.0.0.1";
+	std::string user;
+	std::string port="5432";
+	std::string dbname;
+	std::string passwd;
+	std::string prefixtables="";
+	bool skipnodes = false;
+	bool clean = false;
+	if(argc >=7 && argc <=19)
+	{
+		int i=1;
+		while( i<argc)
+		{
+			if(strcmp(argv[i],"-file")==0)
+			{
+				i++;
+				file = argv[i];
+			}
+
+			else if(strcmp(argv[i],"-conf")==0)
+			{
+				i++;
+				cFile = argv[i];
+			}
+
+			else if(strcmp(argv[i],"-host")==0)
+			{
+				i++;
+				host = argv[i];
+			}
+			else if(strcmp(argv[i],"-dbname")==0)
+			{
+				i++;
+				dbname = argv[i];
+			}
+			else if(strcmp(argv[i],"-user")==0)
+			{
+				i++;
+				user = argv[i];
+			}
+			else if(strcmp(argv[i],"-port")==0)
+			{
+				i++;
+				port = argv[i];
+			}
+			else if(strcmp(argv[i],"-passwd")==0)
+			{
+				i++;
+				passwd = argv[i];
+			}
+			else if(strcmp(argv[i],"-prefixtables")==0)
+			{
+				i++;
+				prefixtables = argv[i];
+			}
+			else if(strcmp(argv[i],"-clean")==0)
+			{
+				clean = true;
+			}
+			else if(strcmp(argv[i],"-skipnodes")==0)
+            {
+                skipnodes = true;
+            }
+			else
+			{
+				cout << "unknown parameter: " << argv[i] << endl;
+				_error();
+				return 1;
+			}
+
+			i++;
+		}
+
+	}
+	else
+	{
+		_error();
+		return 1;
+	}
+
+	if(file.empty() || cFile.empty() || dbname.empty() || user.empty())
+	{
+		_error();
+		return 1;
+	}
+
+	Export2DB test(host, user, dbname, port, passwd, prefixtables);
+	if(test.connect()==1)
+		return 1;
+
+	XMLParser parser;
+
+	cout << "Trying to load config file " << cFile.c_str() << endl;
+
+	Configuration* config = new Configuration();
+    ConfigurationParserCallback cCallback( *config );
+
+	cout << "Trying to parse config" << endl;
+
+	int ret = parser.Parse(cCallback, cFile.c_str());
+	if (ret!=0) {
+		cerr << "Failed to parse config file " << cFile.c_str() << endl;
+		return 1;
+	}
+
+	cout << "Trying to load data" << endl;
+
+	OSMDocument* document = new OSMDocument(*config);
+    OSMDocumentParserCallback callback(*document);
+
+	cout << "Trying to parse data" << endl;
+
+	ret = parser.Parse( callback, file.c_str() );
+	if( ret!=0 ) {
+		if( ret == 1 )
+			cerr << "Failed to open data file" << endl;
+		cerr << "Failed to parse data file " << file.c_str() << endl;
+		return 1;
+	}
+
+	cout << "Split ways" << endl;
+
+	document->SplitWays();
+	//############# Export2DB
+	{
+
+		if( clean )
+    {
+        cout << "Dropping tables..." << endl;
+
+        test.dropTables();
+    }
+
+    cout << "Creating tables..." << endl;
+    test.createTables();
+
+    cout << "Adding tag types and classes to database..." << endl;
+    test.exportTypesWithClasses(config->m_Types);
+
+		cout << "Adding relations to database..." << endl;
+		test.exportRelations(document->m_Relations, config);
+
+		// Optional user argument skipnodes will not add nodes to the database (saving a lot of time if not necessary)
+		if ( !skipnodes) {
+			cout << "Adding nodes to database..." << endl;
+			test.exportNodes(document->m_Nodes);
+		}
+
+		cout << "Adding ways to database..." << endl;
+		test.exportWays(document->m_SplittedWays, config);
+		
+		//TODO: make some free memory, document will be not used anymore, so there will be more memory available to future DB operations.
+
+		cout << "Creating topology..." << endl;
+		test.createTopology();
+	}
+
+	//#############
+
+	/*
+	std::vector<Way*>& ways= document.m_Ways;
+	std::vector<Way*>::iterator it( ways.begin() );
+	std::vector<Way*>::iterator last( ways.end() );
+	while( it!=last )
+	{
+		Way* pWay = *it;
+
+		if( !pWay->name.empty() )
+		{
+			if( pWay->m_NodeRefs.empty() )
+			{
+				std::cout << pWay->name.c_str() << endl;
+			}
+			else
+			{
+				Node* n0 = pWay->m_NodeRefs.front();
+				Node* n1 = pWay->m_NodeRefs.back();
+				//if(n1->numsOfUse==1)
+				//cout << "way-id: " << pWay->id << " name: " << pWay->name <<endl;
+				//std::cout << n0->lon << " "  << n0->lat << " " << n1->lon << " " << n1->lat << " " << pWay->name.c_str() << " highway: " << pWay->highway.c_str() << " Start numberOfUse: " << n0->numsOfUse << " End numberOfUse: " << n1->numsOfUse  << " ID: " << n1->id <<  endl;
+			}
+		}
+		if( pWay->id == 20215432 ) // Pfaenderweg
+		{
+			cout << pWay->name << endl;
+			int a=4;
+		}
+		++it;
+	}
+	*/
+
+	cout << "#########################" << endl;
+
+	cout << "size of streets: " << document->m_Ways.size() <<	endl;
+	cout << "size of splitted ways : " << document->m_SplittedWays.size() <<	endl;
+
+	cout << "finished" << endl;
+
+	//string n;
+	//getline( cin, n );
+	return 0;
+}
diff --git a/src/stdafx.h b/src/stdafx.h
new file mode 100644
index 0000000..e6808ab
--- /dev/null
+++ b/src/stdafx.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Daniel Wendt   								   *
+ *   gentoo.murray at gmail.com   											   *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <map>
+#include <vector>
+#include <string>
+#include <iostream>
+#include <boost/lexical_cast.hpp>
diff --git a/src/utils.cpp b/src/utils.cpp
new file mode 100644
index 0000000..5318c0e
--- /dev/null
+++ b/src/utils.cpp
@@ -0,0 +1,12 @@
+#include "utils.h"
+
+namespace my_utils{
+
+bool is_number(const std::string& s)
+{
+	std::string::const_iterator it = s.begin();
+	while (it != s.end() && std::isdigit(*it)) ++it;
+	return !s.empty() && it == s.end();
+}
+
+}
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..d27ca6e
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,7 @@
+#include <string>
+
+namespace my_utils{
+
+bool is_number(const std::string& s);
+
+}
diff --git a/tools/vagrant/bootstrap.sh b/tools/vagrant/bootstrap.sh
new file mode 100755
index 0000000..55f965c
--- /dev/null
+++ b/tools/vagrant/bootstrap.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Vagrant - Virtualized Development 
+# Copyright(c) pgRouting Contributors
+#
+# Virtual environment bootstrap script
+# ------------------------------------------------------------------------------
+
+set -e # Exit script immediately on first error.
+#set -x # Print commands and their arguments as they are executed.
+
+# Abort provisioning if pgRouting development environment already setup.
+# ------------------------------------------------------------------------------
+which vim >/dev/null &&
+{ echo "osm2pgrouting development environment already setup."; exit 0; }
+
+# Run provisioning
+# ------------------------------------------------------------------------------
+echo "Installing packages ... this may take some time."
+apt-get update -qq
+apt-get install -y -qq vim packaging-dev checkinstall libboost-graph-dev libpq-dev libexpat1-dev
+
diff --git a/tools/vagrant/packaging.sh b/tools/vagrant/packaging.sh
new file mode 100755
index 0000000..419de7c
--- /dev/null
+++ b/tools/vagrant/packaging.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Vagrant - Virtualized Development 
+# Copyright(c) pgRouting Contributors
+#
+# Prepare packaging (sample)
+# ------------------------------------------------------------------------------
+
+echo "DEBEMAIL=daniel at georepublic.de" > ~/.bash_aliases
+echo "DEBFULLNAME='Daniel Kastl (Georepublic)'" >> ~/.bash_aliases
+
+git config --global user.name "Daniel Kastl"
+git config --global user.email "daniel at georepublic.de"
+git config --global core.editor vim
+git config --global color.ui true
diff --git a/tools/vagrant/packaging.sh.sample b/tools/vagrant/packaging.sh.sample
new file mode 100755
index 0000000..0ebdf38
--- /dev/null
+++ b/tools/vagrant/packaging.sh.sample
@@ -0,0 +1,15 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Vagrant - Virtualized Development 
+# Copyright(c) pgRouting Contributors
+#
+# Prepare packaging (sample)
+# ------------------------------------------------------------------------------
+
+echo "DEBEMAIL=mail at example.com" > ~/.bash_aliases
+echo "DEBFULLNAME='First Last'" >> ~/.bash_aliases
+
+git config --global user.name "First Last"
+git config --global user.email "mail at example.com"
+git config --global core.editor vim
+git config --global color.ui true

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



More information about the Pkg-grass-devel mailing list