[pgrouting] 01/04: Imported Upstream version 2.3.1

Bas Couwenberg sebastic at debian.org
Sun Nov 20 21:28:55 UTC 2016


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

sebastic pushed a commit to branch master
in repository pgrouting.

commit 7ca1f7187be74484979f1e04bd80da3ff5807f88
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sun Nov 20 22:07:25 2016 +0100

    Imported Upstream version 2.3.1
---
 .travis.yml                                        |  105 +-
 CMakeLists.txt                                     |    8 +-
 NEWS                                               |    9 +
 README.md                                          |    9 +-
 VERSION                                            |    2 +-
 appveyor.yml                                       |    5 -
 ci/appveyor/install.bat                            |    2 +-
 doc/index.rst                                      |    1 +
 doc/src/changelog/release_notes.rst                |   16 +
 doc/src/installation/installation.rst              |   25 +-
 doc/test/utilities-any.result                      |    2 +-
 src/allpairs/src/floydWarshall.c                   |    4 +-
 src/allpairs/src/johnson.c                         |    4 +-
 src/alpha_shape/src/alpha.c                        |    8 +-
 src/astar/src/astarManyToMany.c                    |    4 +-
 src/astar/src/astarManyToOne.c                     |    4 +-
 src/astar/src/astarOneToMany.c                     |    4 +-
 src/astar/src/astarOneToOne.c                      |    4 +-
 src/bd_astar/src/bdastar.c                         |    4 +-
 src/bd_dijkstra/doc/doc-bdDijkstra.queries         |   10 +-
 src/bd_dijkstra/src/bdsp.c                         |   20 +-
 src/contraction/src/contractGraph_driver.cpp       |    1 -
 src/dijkstra/src/dijkstraVia.c                     |    4 +-
 src/dijkstra/src/many_to_many_dijkstra.c           |    4 +-
 src/dijkstra/src/many_to_one_dijkstra.c            |    4 +-
 src/dijkstra/src/one_to_many_dijkstra.c            |    4 +-
 src/dijkstra/src/one_to_one_dijkstra.c             |    4 +-
 src/driving_distance/src/drivedist.c               |    4 +-
 .../src/many_to_dist_driving_distance.c            |    4 +-
 .../src/many_to_dist_withPointsDD.c                |    4 +-
 src/driving_distance/src/withPoints_dd.c           |    4 +-
 src/ksp/src/ksp.c                                  |    4 +-
 src/ksp/src/withPoints_ksp.c                       |    4 +-
 .../src/edge_disjoint_paths_many_to_many.c         |    7 +-
 src/max_flow/src/edge_disjoint_paths_many_to_one.c |    6 +-
 src/max_flow/src/edge_disjoint_paths_one_to_many.c |    6 +-
 src/max_flow/src/edge_disjoint_paths_one_to_one.c  |    4 +-
 src/max_flow/src/max_flow_many_to_many.c           |    7 +-
 src/max_flow/src/max_flow_many_to_one.c            |    5 +-
 src/max_flow/src/max_flow_one_to_many.c            |    5 +-
 src/max_flow/src/max_flow_one_to_one.c             |    4 +-
 src/max_flow/src/maximum_cardinality_matching.c    |    4 +-
 src/pickDeliver/src/pickDeliver.c                  |    4 +-
 src/topology/sql/create_vertices_table.sql         |    2 +-
 src/trsp/doc/doc-trsp.queries                      |   20 +-
 src/trsp/sql/CMakeLists.txt                        |    2 +-
 src/trsp/sql/routing_trsp.sql                      |   26 +-
 src/trsp/sql/routing_trsp_vias.sql                 |   26 +-
 src/trsp/sql/trsp_V2.2.sql                         |   88 +-
 src/trsp/sql/vias_trsp_V2.2.sql                    |   24 +-
 src/trsp/src/CMakeLists.txt                        |    6 +-
 src/trsp/src/GraphDefinition.cpp                   |  681 ++++++++-----
 src/trsp/src/GraphDefinition.h                     |  247 +++--
 src/trsp/src/trsp.c                                | 1070 +++++++++++++-------
 src/trsp/src/trsp.h                                |   91 ++
 src/trsp/src/trsp_core.cpp                         |  137 +++
 src/trsp/src/utils.h                               |  106 ++
 src/trsp/test/doc-trsp.test.sql                    |   20 +-
 src/trsp/test/issue693.result                      |    5 +
 src/trsp/test/issue693.test.sql                    |   16 +
 src/trsp/test/pgtap/from1to3.test.sql              |    3 +
 ...restrictions-compare-dijkstra-directed.test.sql |    4 +-
 ...strictions-compare-dijkstra-undirected.test.sql |    4 +-
 src/trsp/test/test.conf                            |    1 +
 src/trsp/test/trsp-any-02.test.sql                 |    2 +-
 src/trsp/test/trsp_vias-any-04.test.sql            |    8 +-
 src/tsp/src/eucledianTSP.c                         |    4 +-
 src/tsp/src/newTSP.c                               |    4 +-
 src/tsp/src/tsp2.c                                 |    4 +-
 src/tsp/src/tsplib.c                               |    4 +-
 src/vrp_basic/src/VRP.c                            |    4 +-
 src/withPoints/src/many_to_many_withPoints.c       |    4 +-
 src/withPoints/src/many_to_one_withPoints.c        |    4 +-
 src/withPoints/src/one_to_many_withPoints.c        |    4 +-
 src/withPoints/src/one_to_one_withPoints.c         |    4 +-
 tools/curr-sig/pgrouting--2.3.1.sig                |  141 +++
 tools/sigs/pgrouting--2.3.0.sig                    |  140 +++
 tools/testers/pg_prove_tests.sh                    |    2 +-
 tools/testers/update-tester.sh                     |   41 +-
 tools/travis/install-doxygen.sh                    |   28 +
 tools/travis/install-postgres.sh                   |   63 ++
 tools/travis/test-documentation.sh                 |   22 +
 82 files changed, 2386 insertions(+), 1023 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4f629fc..bdedba9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,97 +10,98 @@
 #group: edge
 #dist: trusty    
 
-dist: precise
+#dist: precise
 
-sudo: required
 
-language: c
+language: cpp
 
 compiler:
     - gcc
 
-notifications:
-  email:
-    on_failure: project at pgrouting.org
+#notifications:
+#  email:
+#    on_failure: project at pgrouting.org
 
-branches:
-  only:
-    - master
-    - develop
-    - release/2.3.0
+env: POSTGRESQL_VERSION=9.6   PG_USER=postgres
+      
+matrix:
+  include:
+    - os: linux
+      sudo: required
+      dist: precise
+      env: POSTGRESQL_VERSION=9.5   PG_USER=postgres
+
+
+    - os: linux
+      sudo: required
+      dist: precise
+      env: POSTGRESQL_VERSION=9.4   PG_USER=postgres
+
+
+    - os: linux
+      sudo: required
+      dist: trusty
+      group: edge
+      env: POSTGRESQL_VERSION=9.6   PG_USER=postgres
+
+
+    - os: linux
+      sudo: required
+      dist: trusty
+      group: edge
+      env: POSTGRESQL_VERSION=9.5   PG_USER=postgres
+
+
+    - os: linux
+      sudo: required
+      dist: trusty
+      group: edge
+      env: POSTGRESQL_VERSION=9.4   PG_USER=postgres
 
-env:
-  - POSTGRESQL_VERSION=9.1
-  - POSTGRESQL_VERSION=9.2
-  - POSTGRESQL_VERSION=9.3
-  - POSTGRESQL_VERSION=9.4
-  - POSTGRESQL_VERSION=9.5
-  #- POSTGRESQL_VERSION=9.6
 
 
 # executed. So things have to be tested oe by one.
 addons:
   apt:
     sources:
-      # For gcc >= 4.8
-      - ubuntu-toolchain-r-test
-      # For cmake >= 2.8.8 (for CMakePackageConfigHelpers)
+      - - ubuntu-toolchain-r-test
+      # For cmake
       - kubuntu-backports
       - boost-latest
     packages:
-      - g++-4.8
       - cmake
       - libboost-thread-dev
       - libboost-graph-dev
       - libcgal-dev
-      - postgresql-server-dev-all
-      - postgresql-common
       - python-sphinx
 
 
-install:
-  - sudo /etc/init.d/postgresql stop
-  - sudo /etc/init.d/postgresql stop
 
-  - sudo ./tools/travis/install-postgres9.5.sh $POSTGRESQL_VERSION postgres
-  #- sudo ./tools/travis/install-postgres9.6.sh $POSTGRESQL_VERSION postgres
+
+
+install:
+  - sudo ./tools/travis/install-postgres.sh $POSTGRESQL_VERSION $PG_USER
+  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ./tools/travis/install-doxygen.sh ; fi
 
 before_script:
-  ## Install doxygen
-  #- sudo add-apt-repository ppa:libreoffice/libreoffice-4-4 -y && sudo apt-get -qq update &&
-  #  sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen  &&
-  #  doxygen --version ;
 
   # Add our chosen PG version to the path
   - export PATH=/usr/lib/postgresql/$POSTGRESQL_VERSION/bin:$PATH
 
-  # Stop whichever version of PG that travis started
-  - sudo /etc/init.d/postgresql stop
-
-  # Start the version of PG that we want to test
-  - sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION
-
-  # Install pgtap and pg_prove
-  # pgtap has to be installed after postgres has started
-  - ./tools/travis/install_pgtap.sh $POSTGRESQL_VERSION
-  - sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
-
   # initialize databases
-  - createdb  -U postgres ___pgr___test___
-  - createdb  -U postgres pgr_test__db__test
+  - createdb  -U $PG_USER ___pgr___test___
+  - createdb  -U $PG_USER pgr_test__db__test
   - ./tools/travis/check-extensions.sh $POSTGRESQL_VERSION ___pgr___test___
 
+
 script: 
   - ./tools/travis/pgrouting_build.sh $POSTGRESQL_VERSION $POSTGIS_VERSION
   # tests as part of script so if a test fails the build fails
-  - ./tools/travis/pgrouting_test.sh $POSTGRESQL_VERSION postgres
-  - ./tools/testers/pg_prove_tests.sh postgres
+  - ./tools/travis/pgrouting_test.sh $POSTGRESQL_VERSION $PG_USER
+  - ./tools/testers/pg_prove_tests.sh $PG_USER DEBUG
 
 after_script: 
   # blank
 
 #after_success:
-  - make doc
-  # - doxygen -v
-  - make doxy
-
+  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ./tools/travis/test-documentation.sh ; fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c10af4c..b58e5b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT CMAKE_BUILD_TYPE)
             "Choose the type of build, options are: None Debug Release RelWithDebInfo
             MinSizeRel."
             FORCE)
-        message("Running as: Debug")
+        message("Running as: Release")
     else()
         set(CMAKE_BUILD_TYPE Release CACHE STRING
             "Choose the type of build, options are: None Debug Release RelWithDebInfo
@@ -177,7 +177,7 @@ endif()
 # PGROUTING version number.
 set(PGROUTING_VERSION_MAJOR "2")
 set(PGROUTING_VERSION_MINOR "3")
-set(PGROUTING_VERSION_PATCH "0")
+set(PGROUTING_VERSION_PATCH "1")
 
 set(PGROUTING_VERSION_STRING "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}.${PGROUTING_VERSION_PATCH}")
 set(PGROUTING_VERSION "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}")
@@ -187,7 +187,7 @@ set(POSTGIS_MINIMUM_VERSION "2.0.0")
 
 file(STRINGS "${PGROUTING_SOURCE_DIR}/VERSION" PGROUTING_BUILD_STRING)
 
-set(PGROUTING_GIT_TAG "pgrouting-2.3.0")
+set(PGROUTING_GIT_TAG "v2.3.1")
 
 #string(REGEX REPLACE "^(.+)-([0-9]+)-g([0-9a-f]+) (.*)$" "\\1" PGROUTING_GIT_TAG ${PGROUTING_BUILD_STRING})
 string(REGEX REPLACE "^(.+)-([^-]+)-[0-9]+-([0-9a-f]+) (.*)$" "\\2" PGROUTING_GIT_BUILD ${PGROUTING_BUILD_STRING})
@@ -400,7 +400,7 @@ endif()
 
 set(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}  -Wall -Wconversion -pedantic -fmax-errors=10  -Wmissing-prototypes")
 #TODO remove the optimizer flag when pgr_bdijkstra gets fixed
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O1 -fno-implicit-inline-templates -Wconversion -pedantic -fmax-errors=10 -Wunused -Wuninitialized -Wextra")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O1 -fno-implicit-inline-templates -Wconversion -pedantic -fmax-errors=10 -Wunused -Wuninitialized -Wextra -Wdouble-promotion -Werror")
 
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
diff --git a/NEWS b/NEWS
index daad8dd..bb3dbba 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,13 @@
 
+Changes for 2.3.1
+-------------------------------------------------------------------------------
+
+* Bug fixes
+  * Leaks on proposed max_flow functions
+  * Regression error on pgr_trsp
+  * Types discrepancy on pgr_createVerticesTable
+
+
 Changes for 2.3.0
 -------------------------------------------------------------------------------
 
diff --git a/README.md b/README.md
index c5f94ec..2ed5ac7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
 
 ### Branches
 
-* The *master* branch has the latest minor release. (2.3.0)
+* The *master* branch has the latest minor release. (2.3.1)
 * The *develop* branch has the next minor release. (2.4.0)
 
 For the complete list of releases go to:
@@ -51,10 +51,11 @@ https://github.com/pgRouting/pgrouting/releases
 	</tr>
 </table>
 
-* travis: Postgis 2.2 for  Postgres 9.1, 9.2, 9.3, 9.4, 9.5
+* travis: Postgis 2.3.0 for  Postgres 9.4, 9.5, 9.6
   * precise
-* jenkins: g++ 4.8 on 32 & 64 bits for Postgis 2.3.0dev and Postgres 9.4, 9.5, 9.6
-* appveyor: vs1013 Postgis 2.2 Postgres 9.4
+  * trusty
+* jenkins: g++ 4.8 on 32 & 64 bits for Postgis 2.3.0 and Postgres 9.4, 9.5, 9.6
+* appveyor: vs1013 Postgis 2.3.0 Postgres 9.4
 
 
 
diff --git a/VERSION b/VERSION
index 38edf79..c66ff5e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-pgrouting-2.3.0-3977-8c86efd master
+pgrouting-2.3.1-4034-963f95d master
diff --git a/appveyor.yml b/appveyor.yml
index c0c4f6d..ce9ef39 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,11 +7,6 @@
 
 version: 2.3.{build}
 
-branches:
-  only:
-    - master
-    - develop
-
 image: Visual Studio 2013
 configuration: Release
 platform: x64
diff --git a/ci/appveyor/install.bat b/ci/appveyor/install.bat
index aa83bdd..d6f939e 100644
--- a/ci/appveyor/install.bat
+++ b/ci/appveyor/install.bat
@@ -20,7 +20,7 @@ if not defined COMMON_INSTALL_DIR set COMMON_INSTALL_DIR=%BUILD_ROOT_DIR%\local\
 
 :: for cmake its the min version
 if not defined CMAKE_VERSION set CMAKE_VERSION=3.5.2
-if not defined PG_VERSION set PG_VERSION=2.2.2
+if not defined PG_VERSION set PG_VERSION=2.3.0
 if not defined BOOST_VERSION set BOOST_VERSION=1.58.0
 if not defined CGAL_VERSION set CGAL_VERSION=4.8.1
 
diff --git a/doc/index.rst b/doc/index.rst
index 857aede..0d1991d 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -178,6 +178,7 @@ Change Log
 
 :ref:`change_log`
 
+   - :ref:`changelog_2_3_1`
    - :ref:`changelog_2_3_0`
    - :ref:`changelog_2_2_4`
    - :ref:`changelog_2_2_3`
diff --git a/doc/src/changelog/release_notes.rst b/doc/src/changelog/release_notes.rst
index 0f6afa3..42b4a60 100644
--- a/doc/src/changelog/release_notes.rst
+++ b/doc/src/changelog/release_notes.rst
@@ -17,6 +17,7 @@ To see the full list of changes check the list of `Git commits <https://github.c
 Table of contents
 --------------------------
 
+   - :ref:`changelog_2_3_1`
    - :ref:`changelog_2_3_0`
    - :ref:`changelog_2_2_4`
    - :ref:`changelog_2_2_3`
@@ -28,6 +29,21 @@ Table of contents
    - :ref:`changelog_2_0_0`
    - :ref:`changelog_1_x`
 
+
+.. _changelog_2_3_1:
+
+pgRouting 2.3.1 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.3.1 <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.3.1%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: Bug Fixes
+
+* Leaks on proposed max_flow functions
+* Regression error on pgr_trsp
+* Types discrepancy on pgr_createVerticesTable
+
+
 .. _changelog_2_3_0:
 
 pgRouting 2.3.0 Release Notes
diff --git a/doc/src/installation/installation.rst b/doc/src/installation/installation.rst
index 84d8ef8..9f86092 100644
--- a/doc/src/installation/installation.rst
+++ b/doc/src/installation/installation.rst
@@ -51,34 +51,25 @@ pgRouting on Ubuntu can be installed using packages from a PostgreSQL repository
 
 Using a terminal window:
 
-* Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg.
-
 .. code-block:: bash
 
-   sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
-
-* Import the repository key, update the package lists
-
-.. code-block:: bash
+    # Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg.
+    sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
 
-    sudo apt install wget ca-certificates
+    # Import the repository key, update the package lists
+    sudo apt-get install wget ca-certificates
     wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-    sudo apt update
+    sudo apt-get update
 
-* Install pgrouting based on your postgres Installation: for this example is 9.3
+    # Install pgrouting based on your postgres Installation: for this example is 9.3
+    sudo apt-get install postgresql-9.3-pgrouting
 
-.. code-block:: bash
-
-sudo apt install postgresql-9.3-pgrouting
-
-This will also install all required packages such as PostgreSQL and PostGIS if not installed yet.
 
 * To be up-to-date with changes and improvements
 
-
 .. code-block:: bash
 
-sudo apt-get update & sudo apt-get upgrade
+    sudo apt-get update & sudo apt-get upgrade
 
 
 RHEL/CentOS
diff --git a/doc/test/utilities-any.result b/doc/test/utilities-any.result
index 276cbf9..2bf1c1c 100644
--- a/doc/test/utilities-any.result
+++ b/doc/test/utilities-any.result
@@ -1 +1 @@
-2.3.0
+2.3.1
diff --git a/src/allpairs/src/floydWarshall.c b/src/allpairs/src/floydWarshall.c
index 7ce4c40..4575d03 100644
--- a/src/allpairs/src/floydWarshall.c
+++ b/src/allpairs/src/floydWarshall.c
@@ -155,8 +155,8 @@ floydWarshall(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (Matrix_cell_t*) funcctx->user_fctx;
 
diff --git a/src/allpairs/src/johnson.c b/src/allpairs/src/johnson.c
index 4afbe28..1e0658a 100644
--- a/src/allpairs/src/johnson.c
+++ b/src/allpairs/src/johnson.c
@@ -143,8 +143,8 @@ johnson(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (Matrix_cell_t*) funcctx->user_fctx;
 
diff --git a/src/alpha_shape/src/alpha.c b/src/alpha_shape/src/alpha.c
index 4bebd1a..aa344ca 100644
--- a/src/alpha_shape/src/alpha.c
+++ b/src/alpha_shape/src/alpha.c
@@ -127,9 +127,9 @@ static int compute_alpha_shape(char* sql, float8 alpha, vertex_t **res, size_t *
   void *SPIplan;
   Portal SPIportal;
   bool moredata = TRUE;
-  uint32_t ntuples;
+  size_t ntuples;
   vertex_t *vertices = NULL;
-  uint32_t total_tuples = 0;
+  size_t total_tuples = 0;
 #ifndef _MSC_VER
   vertex_columns_t vertex_columns = {.id = -1, .x = -1, .y = -1};
 #else   // _MSC_VER
@@ -272,8 +272,8 @@ Datum alphashape(PG_FUNCTION_ARGS) {
   PGR_DBG("Strange stuff doing\n");
   funcctx = SRF_PERCALL_SETUP();
 
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
   tuple_desc = funcctx->tuple_desc;
   res = (vertex_t*) funcctx->user_fctx;
 
diff --git a/src/astar/src/astarManyToMany.c b/src/astar/src/astarManyToMany.c
index 2354c37..c73bc08 100644
--- a/src/astar/src/astarManyToMany.c
+++ b/src/astar/src/astarManyToMany.c
@@ -202,8 +202,8 @@ astarManyToMany(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/astar/src/astarManyToOne.c b/src/astar/src/astarManyToOne.c
index aeebf3e..913a4b2 100644
--- a/src/astar/src/astarManyToOne.c
+++ b/src/astar/src/astarManyToOne.c
@@ -194,8 +194,8 @@ astarManyToOne(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/astar/src/astarOneToMany.c b/src/astar/src/astarOneToMany.c
index ba0e222..88f0c8c 100644
--- a/src/astar/src/astarOneToMany.c
+++ b/src/astar/src/astarOneToMany.c
@@ -193,8 +193,8 @@ astarOneToMany(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/astar/src/astarOneToOne.c b/src/astar/src/astarOneToOne.c
index 330a2b3..a3c66ed 100644
--- a/src/astar/src/astarOneToOne.c
+++ b/src/astar/src/astarOneToOne.c
@@ -184,8 +184,8 @@ astarOneToOne(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/bd_astar/src/bdastar.c b/src/bd_astar/src/bdastar.c
index 47d64dc..205e4be 100644
--- a/src/bd_astar/src/bdastar.c
+++ b/src/bd_astar/src/bdastar.c
@@ -398,8 +398,8 @@ bidir_astar_shortest_path(PG_FUNCTION_ARGS) {
 
   funcctx = SRF_PERCALL_SETUP();
 
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
   tuple_desc = funcctx->tuple_desc;
   path = (path_element_t*) funcctx->user_fctx;
 
diff --git a/src/bd_dijkstra/doc/doc-bdDijkstra.queries b/src/bd_dijkstra/doc/doc-bdDijkstra.queries
index 3566f29..47cd559 100644
--- a/src/bd_dijkstra/doc/doc-bdDijkstra.queries
+++ b/src/bd_dijkstra/doc/doc-bdDijkstra.queries
@@ -6,11 +6,11 @@ SELECT * FROM pgr_bdDijkstra(
     4, 10, false, false);
  seq | id1 | id2 | cost 
 -----+-----+-----+------
-   0 |   4 |     |    0
-   1 |   3 |     |    0
-   2 |   2 |     |    1
-   3 |   5 |     |    1
-   4 |  10 |     |    0
+   0 |   4 |   3 |    0
+   1 |   3 |   2 |    0
+   2 |   2 |   4 |    1
+   3 |   5 |  10 |    1
+   4 |  10 |  -1 |    0
 (5 rows)
 
 --q2
diff --git a/src/bd_dijkstra/src/bdsp.c b/src/bd_dijkstra/src/bdsp.c
index 67f1e77..f09e6f6 100644
--- a/src/bd_dijkstra/src/bdsp.c
+++ b/src/bd_dijkstra/src/bdsp.c
@@ -157,9 +157,9 @@ static int compute_bidirsp(char* sql, int64_t start_vertex,
   void *SPIplan;
   Portal SPIportal;
   bool moredata = TRUE;
-  uint32_t ntuples;
+  size_t ntuples;
   edge_t *edges = NULL;
-  uint32_t total_tuples = 0;
+  size_t total_tuples = 0;
 #ifndef _MSC_VER
   edge_columns_t edge_columns = {.id = -1, .source = -1, .target = -1,
                                  .cost = -1, .reverse_cost = -1};
@@ -224,9 +224,9 @@ static int compute_bidirsp(char* sql, int64_t start_vertex,
 
   // defining min and max vertex id
 
-  PGR_DBG("Total %i tuples", total_tuples);
+  PGR_DBG("Total %ld tuples", total_tuples);
 
-  for (z = 0; z < total_tuples; z++) {
+  for (z = 0; z < (int64_t)total_tuples; z++) {
     if (edges[z].source < v_min_id) v_min_id = edges[z].source;
     if (edges[z].source > v_max_id) v_max_id = edges[z].source;
     if (edges[z].target < v_min_id) v_min_id = edges[z].target;
@@ -237,7 +237,7 @@ static int compute_bidirsp(char* sql, int64_t start_vertex,
   //::::::::::::::::::::::::::::::::::::
   //:: reducing vertex id (renumbering)
   //::::::::::::::::::::::::::::::::::::
-  for (z = 0; z < total_tuples; z++) {
+  for (z = 0; z < (int64_t)total_tuples; z++) {
     // check if edges[] contains source and target
     if (edges[z].source == start_vertex ||  edges[z].target == start_vertex)
       ++s_count;
@@ -249,7 +249,7 @@ static int compute_bidirsp(char* sql, int64_t start_vertex,
     // PGR_DBG("%i - %i", edges[z].source, edges[z].target);
   }
 
-  PGR_DBG("Total %i tuples", total_tuples);
+  PGR_DBG("Total %ld tuples", total_tuples);
 
   if (s_count == 0) {
     elog(ERROR, "Start vertex was not found.");
@@ -266,11 +266,11 @@ static int compute_bidirsp(char* sql, int64_t start_vertex,
 
   // v_max_id -= v_min_id;
 
-  PGR_DBG("Calling bidirsp_wrapper(edges, %u, %ld, %ld, %ld, %d, %d, ...)\n",
+  PGR_DBG("Calling bidirsp_wrapper(edges, %ld, %ld, %ld, %ld, %d, %d, ...)\n",
         total_tuples, v_max_id + 2, start_vertex, end_vertex,
         directed, has_reverse_cost);
 
-  ret = bidirsp_wrapper(edges, total_tuples, (int)v_max_id + 2, (int)start_vertex, (int)end_vertex,
+  ret = bidirsp_wrapper(edges, (unsigned int)total_tuples, (int)v_max_id + 2, (int)start_vertex, (int)end_vertex,
                        directed, has_reverse_cost,
                        path, path_count, &err_msg);
 
@@ -367,8 +367,8 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS) {
   // stuff done on every call of the function
   funcctx = SRF_PERCALL_SETUP();
 
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
   tuple_desc = funcctx->tuple_desc;
   path = (path_element_t*) funcctx->user_fctx;
 
diff --git a/src/contraction/src/contractGraph_driver.cpp b/src/contraction/src/contractGraph_driver.cpp
index a920fe9..74525f8 100644
--- a/src/contraction/src/contractGraph_driver.cpp
+++ b/src/contraction/src/contractGraph_driver.cpp
@@ -52,7 +52,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./structs.h"
 
 #include "./../../common/src/pgr_alloc.hpp"
-#include "./../../common/src/debug_macro.h"
 #include "./../../common/src/identifiers.hpp"
 
 
diff --git a/src/dijkstra/src/dijkstraVia.c b/src/dijkstra/src/dijkstraVia.c
index df048d9..5192822 100644
--- a/src/dijkstra/src/dijkstraVia.c
+++ b/src/dijkstra/src/dijkstraVia.c
@@ -175,8 +175,8 @@ dijkstraVia(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (Routes_t*) funcctx->user_fctx;
 
diff --git a/src/dijkstra/src/many_to_many_dijkstra.c b/src/dijkstra/src/many_to_many_dijkstra.c
index 229434d..f9e282c 100644
--- a/src/dijkstra/src/many_to_many_dijkstra.c
+++ b/src/dijkstra/src/many_to_many_dijkstra.c
@@ -184,8 +184,8 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/dijkstra/src/many_to_one_dijkstra.c b/src/dijkstra/src/many_to_one_dijkstra.c
index 7ee3dd7..6fe7845 100644
--- a/src/dijkstra/src/many_to_one_dijkstra.c
+++ b/src/dijkstra/src/many_to_one_dijkstra.c
@@ -177,8 +177,8 @@ many_to_one_dijkstra(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/dijkstra/src/one_to_many_dijkstra.c b/src/dijkstra/src/one_to_many_dijkstra.c
index 083c856..5244dae 100644
--- a/src/dijkstra/src/one_to_many_dijkstra.c
+++ b/src/dijkstra/src/one_to_many_dijkstra.c
@@ -176,8 +176,8 @@ one_to_many_dijkstra(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/dijkstra/src/one_to_one_dijkstra.c
index 6667571..da20582 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/dijkstra/src/one_to_one_dijkstra.c
@@ -167,8 +167,8 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/driving_distance/src/drivedist.c b/src/driving_distance/src/drivedist.c
index 239924f..ec20422 100644
--- a/src/driving_distance/src/drivedist.c
+++ b/src/driving_distance/src/drivedist.c
@@ -137,8 +137,8 @@ driving_distance(PG_FUNCTION_ARGS) {
   /* stuff done on every call of the function */
   funcctx = SRF_PERCALL_SETUP();
 
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
   tuple_desc = funcctx->tuple_desc;
   ret_path = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/driving_distance/src/many_to_dist_driving_distance.c b/src/driving_distance/src/many_to_dist_driving_distance.c
index 07f63ad..e1b09f6 100644
--- a/src/driving_distance/src/many_to_dist_driving_distance.c
+++ b/src/driving_distance/src/many_to_dist_driving_distance.c
@@ -148,8 +148,8 @@ driving_many_to_dist(PG_FUNCTION_ARGS) {
     /* stuff done on every call of the function */
     funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     ret_path = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/driving_distance/src/many_to_dist_withPointsDD.c b/src/driving_distance/src/many_to_dist_withPointsDD.c
index e45a947..c54b334 100644
--- a/src/driving_distance/src/many_to_dist_withPointsDD.c
+++ b/src/driving_distance/src/many_to_dist_withPointsDD.c
@@ -214,8 +214,8 @@ many_withPointsDD(PG_FUNCTION_ARGS) {
     /* stuff done on every call of the function */
     funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/driving_distance/src/withPoints_dd.c b/src/driving_distance/src/withPoints_dd.c
index 828f0d9..f351922 100644
--- a/src/driving_distance/src/withPoints_dd.c
+++ b/src/driving_distance/src/withPoints_dd.c
@@ -212,8 +212,8 @@ withPoints_dd(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/ksp/src/ksp.c b/src/ksp/src/ksp.c
index e3e5710..403dbe9 100644
--- a/src/ksp/src/ksp.c
+++ b/src/ksp/src/ksp.c
@@ -147,8 +147,8 @@ kshortest_path(PG_FUNCTION_ARGS) {
     /* stuff done on every call of the function */
     funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     path = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/ksp/src/withPoints_ksp.c b/src/ksp/src/withPoints_ksp.c
index 7ad2ea6..540c62c 100644
--- a/src/ksp/src/withPoints_ksp.c
+++ b/src/ksp/src/withPoints_ksp.c
@@ -222,8 +222,8 @@ withPoints_ksp(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/edge_disjoint_paths_many_to_many.c b/src/max_flow/src/edge_disjoint_paths_many_to_many.c
index 075c1b3..84c60bc 100644
--- a/src/max_flow/src/edge_disjoint_paths_many_to_many.c
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_many.c
@@ -157,6 +157,9 @@ edge_disjoint_paths_many_to_many(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(source_vertices);
+        free(sink_vertices);
+
         /*                                                                    */
         /**********************************************************************/
 
@@ -175,8 +178,8 @@ edge_disjoint_paths_many_to_many(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/edge_disjoint_paths_many_to_one.c b/src/max_flow/src/edge_disjoint_paths_many_to_one.c
index 953e4d6..a7919ff 100644
--- a/src/max_flow/src/edge_disjoint_paths_many_to_one.c
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_one.c
@@ -150,6 +150,8 @@ edge_disjoint_paths_many_to_one(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(source_vertices);
+
         /*                                                                    */
         /**********************************************************************/
 
@@ -168,8 +170,8 @@ edge_disjoint_paths_many_to_one(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/edge_disjoint_paths_one_to_many.c b/src/max_flow/src/edge_disjoint_paths_one_to_many.c
index c628c7f..f7f89c1 100644
--- a/src/max_flow/src/edge_disjoint_paths_one_to_many.c
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_many.c
@@ -149,6 +149,8 @@ edge_disjoint_paths_one_to_many(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(sink_vertices);
+
         /*                                                                    */
         /**********************************************************************/
 
@@ -167,8 +169,8 @@ edge_disjoint_paths_one_to_many(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/edge_disjoint_paths_one_to_one.c b/src/max_flow/src/edge_disjoint_paths_one_to_one.c
index bec6512..9d6687c 100644
--- a/src/max_flow/src/edge_disjoint_paths_one_to_one.c
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_one.c
@@ -164,8 +164,8 @@ edge_disjoint_paths_one_to_one(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/max_flow_many_to_many.c b/src/max_flow/src/max_flow_many_to_many.c
index 621c29a..ec73b73 100644
--- a/src/max_flow/src/max_flow_many_to_many.c
+++ b/src/max_flow/src/max_flow_many_to_many.c
@@ -164,6 +164,9 @@ max_flow_many_to_many(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(source_vertices);
+        free(sink_vertices);
+
         /*                                                                    */
         /**********************************************************************/
 
@@ -182,8 +185,8 @@ max_flow_many_to_many(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/max_flow_many_to_one.c b/src/max_flow/src/max_flow_many_to_one.c
index c94ec3e..7f02628 100644
--- a/src/max_flow/src/max_flow_many_to_one.c
+++ b/src/max_flow/src/max_flow_many_to_one.c
@@ -158,6 +158,7 @@ max_flow_many_to_one(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(source_vertices);
         /*                                                                    */
         /**********************************************************************/
 
@@ -176,8 +177,8 @@ max_flow_many_to_one(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/max_flow_one_to_many.c b/src/max_flow/src/max_flow_one_to_many.c
index 048f528..1e8cadf 100644
--- a/src/max_flow/src/max_flow_one_to_many.c
+++ b/src/max_flow/src/max_flow_one_to_many.c
@@ -158,6 +158,7 @@ max_flow_one_to_many(PG_FUNCTION_ARGS) {
             &result_tuples,
             &result_count);
 
+        free(sink_vertices);
         /*                                                                    */
         /**********************************************************************/
 
@@ -176,8 +177,8 @@ max_flow_one_to_many(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/max_flow_one_to_one.c b/src/max_flow/src/max_flow_one_to_one.c
index 760bd29..6356331 100644
--- a/src/max_flow/src/max_flow_one_to_one.c
+++ b/src/max_flow/src/max_flow_one_to_one.c
@@ -173,8 +173,8 @@ max_flow_one_to_one(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
diff --git a/src/max_flow/src/maximum_cardinality_matching.c b/src/max_flow/src/maximum_cardinality_matching.c
index 24a2d74..5290ff3 100644
--- a/src/max_flow/src/maximum_cardinality_matching.c
+++ b/src/max_flow/src/maximum_cardinality_matching.c
@@ -151,8 +151,8 @@ maximum_cardinality_matching(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (pgr_basic_edge_t *) funcctx->user_fctx;
 
diff --git a/src/pickDeliver/src/pickDeliver.c b/src/pickDeliver/src/pickDeliver.c
index cd2cb88..31be79d 100644
--- a/src/pickDeliver/src/pickDeliver.c
+++ b/src/pickDeliver/src/pickDeliver.c
@@ -193,8 +193,8 @@ pickDeliver(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_vehicle_orders_t*) funcctx->user_fctx;
 
diff --git a/src/topology/sql/create_vertices_table.sql b/src/topology/sql/create_vertices_table.sql
index e6b0acf..f46dcc1 100644
--- a/src/topology/sql/create_vertices_table.sql
+++ b/src/topology/sql/create_vertices_table.sql
@@ -70,7 +70,7 @@ DECLARE
     sourcename text;
     targetname text;
     query text;
-    ecnt integer; 
+    ecnt bigint; 
     srid integer;
     sourcetype text;
     targettype text;
diff --git a/src/trsp/doc/doc-trsp.queries b/src/trsp/doc/doc-trsp.queries
index 33a91c1..78aaa01 100644
--- a/src/trsp/doc/doc-trsp.queries
+++ b/src/trsp/doc/doc-trsp.queries
@@ -20,7 +20,7 @@ SELECT * FROM pgr_trsp(
 SELECT * FROM pgr_trsp(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
         2, 7, false, false,
-        'SELECT to_cost, target_id,
+        'SELECT to_cost, target_id::int4,
         from_edge || coalesce('','' || via_path, '''') AS via_path
         FROM restrictions'
     );
@@ -39,7 +39,7 @@ SELECT * FROM pgr_trsp(
 SELECT * FROM pgr_trsp(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
         7, 11, false, false,
-        'SELECT to_cost, target_id,
+        'SELECT to_cost, target_id::int4,
         from_edge || coalesce('','' || via_path, '''') AS via_path
         FROM restrictions'
     );
@@ -57,9 +57,9 @@ SELECT * FROM pgr_trsp(
 --q4
 SELECT * FROM pgr_trspViaVertices(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
-        ARRAY[2,7,11]::INTEGER[],     
-        false,  false,  
-        'SELECT to_cost, target_id, from_edge ||
+        ARRAY[2,7,11]::INTEGER[],
+        false,  false,
+        'SELECT to_cost, target_id::int4, from_edge ||
         coalesce('',''||via_path,'''') AS via_path FROM restrictions');
  seq | id1 | id2 | id3 | cost 
 -----+-----+-----+-----+------
@@ -83,11 +83,11 @@ SELECT * FROM pgr_trspViaVertices(
 SELECT * FROM pgr_trspViaEdges(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost,
         reverse_cost FROM edge_table',
-        ARRAY[2,7,11]::INTEGER[],           
-        ARRAY[0.5, 0.5, 0.5]::FLOAT[],     
-        true,  
-        true,  
-        'SELECT to_cost, target_id, FROM_edge ||
+        ARRAY[2,7,11]::INTEGER[],
+        ARRAY[0.5, 0.5, 0.5]::FLOAT[],
+        true,
+        true,
+        'SELECT to_cost, target_id::int4, FROM_edge ||
         coalesce('',''||via_path,'''') AS via_path FROM restrictions');
  seq | id1 | id2 | id3 | cost 
 -----+-----+-----+-----+------
diff --git a/src/trsp/sql/CMakeLists.txt b/src/trsp/sql/CMakeLists.txt
index 195bd9e..8316d20 100644
--- a/src/trsp/sql/CMakeLists.txt
+++ b/src/trsp/sql/CMakeLists.txt
@@ -2,8 +2,8 @@
 list(APPEND PACKAGE_SQL_FILES
     #${CMAKE_CURRENT_SOURCE_DIR}/routing_trsp.sql
     #${CMAKE_CURRENT_SOURCE_DIR}/routing_trsp_vias.sql
-    ${CMAKE_CURRENT_SOURCE_DIR}/vias_trsp_V2.2.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/trsp_V2.2.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/vias_trsp_V2.2.sql
     )
 
 # set in parent scope
diff --git a/src/trsp/sql/routing_trsp.sql b/src/trsp/sql/routing_trsp.sql
index 7a06c1c..62e0088 100644
--- a/src/trsp/sql/routing_trsp.sql
+++ b/src/trsp/sql/routing_trsp.sql
@@ -1,25 +1,3 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 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.
-
-********************************************************************PGR-GNU*/
 -----------------------------------------------------------------------
 -- Core function for time_dependent_shortest_path computation
 -- See README for description
@@ -35,7 +13,7 @@ CREATE OR REPLACE FUNCTION pgr_trsp(
         has_reverse_cost boolean, 
         turn_restrict_sql text DEFAULT null)
         RETURNS SETOF pgr_costResult
-        AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'turn_restrict_shortest_path_vertex'
+        AS '$libdir/librouting-2.1', 'turn_restrict_shortest_path_vertex'
         LANGUAGE 'c' IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION pgr_trsp(
@@ -48,6 +26,6 @@ CREATE OR REPLACE FUNCTION pgr_trsp(
         has_reverse_cost boolean, 
         turn_restrict_sql text DEFAULT null)
         RETURNS SETOF pgr_costResult
-        AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'turn_restrict_shortest_path_edge'
+        AS '$libdir/librouting-2.1', 'turn_restrict_shortest_path_edge'
         LANGUAGE 'c' IMMUTABLE;
 
diff --git a/src/trsp/sql/routing_trsp_vias.sql b/src/trsp/sql/routing_trsp_vias.sql
index 3b48df0..76473c7 100644
--- a/src/trsp/sql/routing_trsp_vias.sql
+++ b/src/trsp/sql/routing_trsp_vias.sql
@@ -1,25 +1,3 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 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.
-
-********************************************************************PGR-GNU*/
 create or replace function pgr_trspViaVertices(sql text, vids integer[], directed boolean, has_reverse_cost boolean, turn_restrict_sql text DEFAULT NULL::text)
     RETURNS SETOF pgr_costresult3 AS
 $body$
@@ -169,7 +147,7 @@ create or replace function pgr_trsp(sql text, vids integer[], directed boolean,
     RETURNS SETOF pgr_costresult AS
 $body$
 begin
-    return query select seq, id2 as id1, id3 as id2, cost from pgr_trspViaVertices( sql, vids, directed, has_reverse_cost, turn_restrict_sql);
+    return query select seq, id2 as id1, id3 as id2, cost from pgr_trspVia( sql, vids, directed, has_reverse_cost, turn_restrict_sql);
 end;
 $body$
     language plpgsql stable
@@ -182,7 +160,7 @@ create or replace function pgr_trsp(sql text, eids integer[], pcts float8[], dir
     RETURNS SETOF pgr_costresult AS
 $body$
 begin
-    return query select seq, id2 as id1, id3 as id2, cost from pgr_trspViaEdges(sql, eids, pcts, directed, has_reverse_cost, turn_restrict_sql);
+    return query select seq, id2 as id1, id3 as id2, cost from pgr_trspVia(sql, eids, pcts, directed, has_reverse_cost, turn_restrict_sql);
 end;
 $body$
     language plpgsql stable
diff --git a/src/trsp/sql/trsp_V2.2.sql b/src/trsp/sql/trsp_V2.2.sql
index 0ff2500..444bfea 100644
--- a/src/trsp/sql/trsp_V2.2.sql
+++ b/src/trsp/sql/trsp_V2.2.sql
@@ -28,24 +28,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 --     - For now just checking with static data, so the query is similar to shortest_paths.
 
 CREATE OR REPLACE FUNCTION _pgr_trsp(
-    sql text, 
-    source_vid integer, 
-    target_vid integer, 
-    directed boolean, 
-    has_reverse_cost boolean, 
+    sql text,
+    source_vid integer,
+    target_vid integer,
+    directed boolean,
+    has_reverse_cost boolean,
     turn_restrict_sql text DEFAULT null)
 RETURNS SETOF pgr_costResult
 AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'turn_restrict_shortest_path_vertex'
 LANGUAGE 'c' IMMUTABLE;
 
-CREATE OR REPLACE FUNCTION pgr_trsp(
-    sql text, 
-    source_eid integer, 
+CREATE OR REPLACE FUNCTION _pgr_trsp(
+    sql text,
+    source_eid integer,
     source_pos float8,
     target_eid integer,
     target_pos float8,
-    directed boolean, 
-    has_reverse_cost boolean, 
+    directed boolean,
+    has_reverse_cost boolean,
     turn_restrict_sql text DEFAULT null)
 RETURNS SETOF pgr_costResult
 AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'turn_restrict_shortest_path_edge'
@@ -70,7 +70,7 @@ CREATE OR REPLACE FUNCTION pgr_trsp(
     directed BOOLEAN,
     has_rcost BOOLEAN,
     restrictions_sql TEXT DEFAULT NULL)
-RETURNS SETOF pgr_costResult AS 
+RETURNS SETOF pgr_costResult AS
 $BODY$
 DECLARE
 has_reverse BOOLEAN;
@@ -83,7 +83,7 @@ BEGIN
     IF (has_reverse != has_rcost) THEN  -- user contradiction
         IF (has_reverse) THEN  -- it has reverse_cost but user don't want it.
             -- to be on the safe side because it reads the data wrong, sending only postitive values
-            new_sql := 
+            new_sql :=
             'WITH old_sql AS (' || edges_sql || ')' ||
             '   SELECT id, source, target, cost FROM old_sql';
         ELSE -- it does not have reverse_cost but user wants it
@@ -101,8 +101,6 @@ BEGIN
 
     RETURN query SELECT * FROM _pgr_trsp(new_sql, start_vid, end_vid, directed, has_rcost, restrictions_sql);
     RETURN;
-
-
 END
 $BODY$
 LANGUAGE plpgsql VOLATILE
@@ -124,7 +122,7 @@ CREATE OR REPLACE FUNCTION pgr_trspViaVertices(
     directed BOOLEAN,
     has_rcost BOOLEAN,
     restrictions_sql TEXT DEFAULT NULL)
-RETURNS SETOF pgr_costResult3 AS 
+RETURNS SETOF pgr_costResult3 AS
 $BODY$
 DECLARE
 has_reverse BOOLEAN;
@@ -136,7 +134,7 @@ BEGIN
     new_sql := edges_sql;
     IF (has_reverse != has_rcost) THEN  -- user contradiction
         IF (has_reverse) THEN  -- it has reverse_cost but user don't want it.
-            new_sql := 
+            new_sql :=
                'WITH old_sql AS (' || edges_sql || ')' ||
                 '   SELECT id, source, target, cost FROM old_sql';
         ELSE -- it does not have reverse_cost but user wants it
@@ -151,10 +149,64 @@ BEGIN
             FROM pgr_dijkstraVia(new_sql, via_vids, directed, strict:=true) WHERE edge != -1;
         RETURN;
     END IF;
-   
+
 
     -- make the call without contradiction from part of the user
-    RETURN query SELECT * FROM _pgr_trspViaVertices(new_sql, via_vids, directed, has_rcost, restrictions_sql);
+    RETURN query SELECT * FROM _pgr_trspViaVertices(new_sql, via_vids::INTEGER[], directed, has_rcost, restrictions_sql);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+
+CREATE OR REPLACE FUNCTION pgr_trsp(
+    sql text,
+    source_eid integer,
+    source_pos float8,
+    target_eid integer,
+    target_pos float8,
+    directed boolean,
+    has_reverse_cost boolean,
+    turn_restrict_sql text DEFAULT null)
+RETURNS SETOF pgr_costResult AS
+$BODY$
+DECLARE
+has_reverse BOOLEAN;
+new_sql TEXT;
+trsp_sql TEXT;
+BEGIN
+    has_reverse =_pgr_parameter_check('dijkstra', sql, false);
+
+    new_sql := sql;
+    IF (has_reverse != has_reverse_cost) THEN  -- user contradiction
+        IF (has_reverse) THEN
+            -- it has reverse_cost but user don't want it.
+            -- to be on the safe side because it reads the data wrong, sending only postitive values
+            new_sql :=
+            'WITH old_sql AS (' || sql || ')' ||
+            '   SELECT id, source, target, cost FROM old_sql';
+        ELSE -- it does not have reverse_cost but user wants it
+            RAISE EXCEPTION 'Error, reverse_cost is used, but query did''t return ''reverse_cost'' column'
+            USING ERRCODE := 'XX000';
+        END IF;
+    END IF;
+
+    IF (turn_restrict_sql IS NULL OR length(turn_restrict_sql) = 0) THEN
+        -- no restrictions then its a with points
+        RETURN query SELECT seq-1 AS seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
+        FROM pgr_withpoints(new_sql,
+            '(SELECT 1 as pid, ' || source_eid || 'as edge_id, ' || source_pos || '::float8 as fraction)'
+            || ' UNION '
+            || '(SELECT 2, ' || target_eid || ', ' || target_pos || ')' ::TEXT,
+            -1, -2, directed)
+        WHERE node != -2;
+        RETURN;
+    END IF;
+
+    RETURN query SELECT * FROM _pgr_trsp(new_sql, source_eid, source_pos, target_eid, target_pos, directed, has_reverse_cost, turn_restrict_sql);
+    RETURN;
+
 END
 $BODY$
 LANGUAGE plpgsql VOLATILE
diff --git a/src/trsp/sql/vias_trsp_V2.2.sql b/src/trsp/sql/vias_trsp_V2.2.sql
index db9d0d9..e42edb8 100644
--- a/src/trsp/sql/vias_trsp_V2.2.sql
+++ b/src/trsp/sql/vias_trsp_V2.2.sql
@@ -38,27 +38,14 @@ declare
     lrra boolean := false;
     seq integer := 0;
     seq2 integer := 0;
-    has_reverse BOOLEAN;
-    edges_sql TEXT;
 
 begin
-    has_reverse =_pgr_parameter_check('dijkstra', sql, false);
-    edges_sql = sql;
-    IF (has_reverse != has_rcost) THEN
-        IF (has_reverse) THEN
-            edges_sql = 'SELECT id, source, target, cost FROM (' || sql || ') a';
-        ELSE
-            raise EXCEPTION 'has_rcost set to true but reverse_cost not found';
-        END IF;
-    END IF;
-
-
 
     -- loop through each pair of vids and compute the path
     for i in 1 .. array_length(vids, 1)-1 loop
         seq2 := seq2 + 1;
         for rr in select a.seq, seq2 as id1, a.id1 as id2, a.id2 as id3, a.cost
-                    from pgr_trsp(edges_sql, vids[i], vids[i+1], directed, has_rcost, turn_restrict_sql) as a loop
+                    from _pgr_trsp(sql, vids[i], vids[i+1], directed, has_rcost, turn_restrict_sql) as a loop
             -- filter out the individual path ends except the last one
             -- we might not want to do this so we can know where the via points are in the path result
             -- but this needs more thought
@@ -115,7 +102,7 @@ declare
 
 begin
     has_reverse =_pgr_parameter_check('dijkstra', sql, false);
-    edges_sql = sql;
+    edges_sql := sql;
     IF (has_reverse != has_rcost) THEN
         IF (has_reverse) THEN
             edges_sql = 'SELECT id, source, target, cost FROM (' || sql || ') a';
@@ -124,6 +111,13 @@ begin
         END IF;
     END IF;
 
+    IF (turn_restrict_sql IS NULL OR length(turn_restrict_sql) = 0) THEN
+        -- no restrictions then its a _pgr_withPointsVia
+        RETURN query SELECT seq-1 AS seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost
+        FROM _pgr_withPointsVia(edges_sql, eids, pcts, directed)
+        RETURN;
+    END IF;
+
     if array_length(eids, 1) != array_length(pcts, 1) then
         raise exception 'The length of arrays eids and pcts must be the same!';
     end if;
diff --git a/src/trsp/src/CMakeLists.txt b/src/trsp/src/CMakeLists.txt
index bbb9409..bd61d64 100644
--- a/src/trsp/src/CMakeLists.txt
+++ b/src/trsp/src/CMakeLists.txt
@@ -1,5 +1 @@
-add_library(trsp OBJECT 
-    trsp.c
-    trsp_driver.cpp
-    GraphDefinition.cpp)
-
+add_library(trsp OBJECT trsp.h trsp.c utils.h GraphDefinition.h trsp_core.cpp GraphDefinition.cpp)
diff --git a/src/trsp/src/GraphDefinition.cpp b/src/trsp/src/GraphDefinition.cpp
index 2d58e0c..8e0c2b4 100644
--- a/src/trsp/src/GraphDefinition.cpp
+++ b/src/trsp/src/GraphDefinition.cpp
@@ -1,63 +1,36 @@
-/*PGR-GNU*****************************************************************
 
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 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.
-
-********************************************************************PGR-GNU*/
-
-#if defined(__MINGW32__) || defined(_MSC_VER)
+#ifdef __MINGW32__
 #include <winsock2.h>
 #include <windows.h>
-#undef min
-#undef max
 #endif
 
 
-#include <sstream>
 #include "GraphDefinition.h"
+#include <functional>
 
 // -------------------------------------------------------------------------
-GraphDefinition::GraphDefinition(
-        edge_t *edges,
-        unsigned int edge_count,
-        bool directed,
-        bool has_rcost) :
-    m_lStartEdgeId(-1),
-    m_lEndEdgeId(0),
-    m_dStartpart(0.0),
-    m_dEndPart(0.0),
-    m_edge_count(edge_count),
-    m_bIsturnRestrictOn(false),
-    m_bIsGraphConstructed(false) {
-        m_dCost.clear();
-        parent.clear();
-        init();
-        construct_graph(edges, has_rcost, directed);
-        m_bIsGraphConstructed = true;
-    }
+GraphDefinition::GraphDefinition(void)
+{
+    m_lStartEdgeId = -1;
+    m_lEndEdgeId = 0;
+    m_dStartpart = 0.0;
+    m_dEndPart = 0.0;
+    m_dCost = NULL;
+    m_bIsturnRestrictOn = false;
+    m_bIsGraphConstructed = false;
+    parent = NULL;
+    init();
+}
 
 // -------------------------------------------------------------------------
-GraphDefinition::~GraphDefinition(void) { }
+GraphDefinition::~GraphDefinition(void)
+{
+}
 
 
 // -------------------------------------------------------------------------
-void GraphDefinition::init() {
+void GraphDefinition::init()
+{
     max_edge_id = 0;
     max_node_id = 0;
     isStartVirtual = false;
@@ -66,26 +39,33 @@ void GraphDefinition::init() {
 
 
 // -------------------------------------------------------------------------
-
-void GraphDefinition::deleteall() {
+void GraphDefinition::deleteall()
+{
+    std::vector<GraphEdgeInfo*>::iterator it;
+    for(it  = m_vecEdgeVector.begin(); it != m_vecEdgeVector.end(); it++){
+        delete *it;
+    }
     m_vecEdgeVector.clear();
 
-    parent.clear();
-    m_dCost.clear();
+    delete [] parent;
+    delete [] m_dCost;
 }
 
 
-
-
 // -------------------------------------------------------------------------
-double GraphDefinition::construct_path(int64_t ed_id, int64_t v_pos) {
-    if(parent[ed_id].ed_ind[v_pos] == -1) {
+double GraphDefinition::construct_path(long ed_id, int v_pos)
+{
+    if(parent[ed_id].ed_ind[v_pos] == -1)
+    {
         path_element_t pelement;
-        GraphEdgeInfo* cur_edge = &m_vecEdgeVector[ed_id];
-        if(v_pos == 0) {
+        GraphEdgeInfo* cur_edge = m_vecEdgeVector[ed_id];
+        if(v_pos == 0)
+        {
             pelement.vertex_id = cur_edge->m_lStartNode;
             pelement.cost = cur_edge->m_dCost;
-        } else {
+        }
+        else
+        {
             pelement.vertex_id = cur_edge->m_lEndNode;
             pelement.cost = cur_edge->m_dReverseCost;
         }
@@ -96,12 +76,15 @@ double GraphDefinition::construct_path(int64_t ed_id, int64_t v_pos) {
     }
     double ret = construct_path(parent[ed_id].ed_ind[v_pos], parent[ed_id].v_pos[v_pos]);
     path_element_t pelement;
-    GraphEdgeInfo* cur_edge = &m_vecEdgeVector[ed_id];
-    if(v_pos == 0) {
+    GraphEdgeInfo* cur_edge = m_vecEdgeVector[ed_id];
+    if(v_pos == 0)
+    {
         pelement.vertex_id = cur_edge->m_lStartNode;
         pelement.cost = m_dCost[ed_id].endCost - ret;// cur_edge.m_dCost;
         ret = m_dCost[ed_id].endCost;
-    } else {
+    }
+    else
+    {
         pelement.vertex_id = cur_edge->m_lEndNode;
         pelement.cost = m_dCost[ed_id].startCost - ret;
         ret = m_dCost[ed_id].startCost;
@@ -116,28 +99,36 @@ double GraphDefinition::construct_path(int64_t ed_id, int64_t v_pos) {
 
 // -------------------------------------------------------------------------
 double GraphDefinition::getRestrictionCost(
-        int64_t edge_ind,
-        GraphEdgeInfo& new_edge,
-        bool isStart) {
+    long edge_ind,
+    GraphEdgeInfo& new_edge,
+    bool isStart)
+{
     double cost = 0.0;
     auto edge_id = new_edge.m_lEdgeID;
-    if(m_ruleTable.find(edge_id) == m_ruleTable.end()) {    
+    if(m_ruleTable.find(edge_id) == m_ruleTable.end())
+    {    
         return(0.0);
     }
     std::vector<Rule> vecRules = m_ruleTable[edge_id];
+    // int ruleIndex;
     auto totalRule = vecRules.size();
     auto st_edge_ind = edge_ind;
-    for(size_t ruleIndex = 0; ruleIndex < totalRule; ruleIndex++) {
+    for(size_t ruleIndex = 0; ruleIndex < totalRule; ruleIndex++)
+    {
         bool flag = true;
         auto total_edge = vecRules[ruleIndex].precedencelist.size();
-        int64_t v_pos = (isStart?0:1);
+        // int i;
+        int v_pos = (isStart?0:1);
         edge_ind = st_edge_ind;
-        for(size_t i = 0; i < total_edge; i++) {
-            if(edge_ind == -1) {
+        for(size_t i = 0; i < total_edge; i++)
+        {
+            if(edge_ind == -1)
+            {
                 flag = false;
                 break;
             }
-            if(vecRules[ruleIndex].precedencelist[i] != m_vecEdgeVector[edge_ind].m_lEdgeID) {
+            if(vecRules[ruleIndex].precedencelist[i] != m_vecEdgeVector[edge_ind]->m_lEdgeID)
+            {
                 flag = false;
                 break;
             }
@@ -145,7 +136,7 @@ double GraphDefinition::getRestrictionCost(
             v_pos = parent[edge_ind].v_pos[v_pos];
             edge_ind = parent_ind;
         }
-        if(flag) 
+        if(flag)
             cost += vecRules[ruleIndex].cost;
     }
     return cost;
@@ -154,52 +145,60 @@ double GraphDefinition::getRestrictionCost(
 
 // -------------------------------------------------------------------------
 void GraphDefinition::explore(
-        int64_t cur_node,
-        GraphEdgeInfo &cur_edge,
-        bool isStart,
-        LongVector &vecIndex,
-        std::priority_queue<PDP, std::vector<PDP>,
-        std::greater<PDP> > &que) {
+    long cur_node,
+    GraphEdgeInfo& cur_edge,
+    bool isStart,
+    LongVector &vecIndex,
+    std::priority_queue<PDP, std::vector<PDP>,
+    std::greater<PDP> > &que)
+{
     unsigned int i;
     double extCost = 0.0;
-    GraphEdgeInfo new_edge;
+    GraphEdgeInfo* new_edge;
     // int new_node;
     double totalCost;
-    for(i = 0; i < vecIndex.size(); i++) {
+    for(i = 0; i < vecIndex.size(); i++)
+    {
         new_edge = m_vecEdgeVector[vecIndex[i]];
         extCost = 0.0;
-        if(m_bIsturnRestrictOn) {
-            extCost = getRestrictionCost(cur_edge.m_lEdgeIndex, new_edge, isStart);
+        if(m_bIsturnRestrictOn)
+        {
+            extCost = getRestrictionCost(cur_edge.m_lEdgeIndex, *new_edge, isStart);
         }
-        if(new_edge.m_lStartNode == cur_node) {
-            if(new_edge.m_dCost >= 0.0) {
+        if(new_edge->m_lStartNode == cur_node)
+        {
+            if(new_edge->m_dCost >= 0.0)
+            {
                 //new_node = new_edge->m_lEndNode;
-
+                
                 if(isStart)
-                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].endCost + new_edge.m_dCost + extCost;
+                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].endCost + new_edge->m_dCost + extCost;
                 else
-                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].startCost + new_edge.m_dCost + extCost;
-                if(totalCost < m_dCost[vecIndex[i]].endCost) {
+                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].startCost + new_edge->m_dCost + extCost;
+                if(totalCost < m_dCost[vecIndex[i]].endCost)
+                {
                     m_dCost[vecIndex[i]].endCost = totalCost;
-                    parent[new_edge.m_lEdgeIndex].v_pos[0] = (isStart?0:1);
-                    parent[new_edge.m_lEdgeIndex].ed_ind[0] = cur_edge.m_lEdgeIndex;
-                    que.push(std::make_pair(totalCost, std::make_pair(new_edge.m_lEdgeIndex, true)));
+                    parent[new_edge->m_lEdgeIndex].v_pos[0] = (isStart?0:1);
+                    parent[new_edge->m_lEdgeIndex].ed_ind[0] = cur_edge.m_lEdgeIndex;
+                    que.push(PDP((double)totalCost, PIB((int)new_edge->m_lEdgeIndex, (bool)true)));
                 }
             }
-        } else {
-            if(new_edge.m_dReverseCost >= 0.0)
+        }
+        else
+        {
+            if(new_edge->m_dReverseCost >= 0.0)
             {
                 // new_node = new_edge->m_lStartNode;
                 if(isStart)
-                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].endCost + new_edge.m_dReverseCost + extCost;
+                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].endCost + new_edge->m_dReverseCost + extCost;
                 else
-                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].startCost + new_edge.m_dReverseCost + extCost;
+                    totalCost = m_dCost[cur_edge.m_lEdgeIndex].startCost + new_edge->m_dReverseCost + extCost;
                 if(totalCost < m_dCost[vecIndex[i]].startCost)
                 {
                     m_dCost[vecIndex[i]].startCost = totalCost;
-                    parent[new_edge.m_lEdgeIndex].v_pos[1] = (isStart?0:1);
-                    parent[new_edge.m_lEdgeIndex].ed_ind[1] = cur_edge.m_lEdgeIndex;
-                    que.push(std::make_pair(totalCost, std::make_pair(new_edge.m_lEdgeIndex, false)));
+                    parent[new_edge->m_lEdgeIndex].v_pos[1] = (isStart?0:1);
+                    parent[new_edge->m_lEdgeIndex].ed_ind[1] = cur_edge.m_lEdgeIndex;
+                    que.push(PDP((double)totalCost, PIB((int)new_edge->m_lEdgeIndex, (bool)false)));
                 }
             }
         }
@@ -207,15 +206,213 @@ void GraphDefinition::explore(
 }
 
 
+// -------------------------------------------------------------------------
+int GraphDefinition::multi_dijkstra(
+    edge_t *edges,
+    unsigned int edge_count,
+    std::vector<int> vertices,
+    bool directed,
+    bool has_reverse_cost, 
+    path_element_t **path,
+    size_t *path_count,
+    char **err_msg,
+    std::vector<PDVI> &ruleList)
+{
+    construct_graph(edges, edge_count, has_reverse_cost, directed);
+    if(ruleList.size() > 0)
+    {
+    m_ruleTable.clear();
+    auto total_rule = ruleList.size();
+    // int i;
+    LongVector vecsource;
+    // int kk;
+    for(size_t i = 0; i < total_rule; i++)
+    {
+        Rule rule;
+        rule.cost = ruleList[i].first;
+        // int j;
+        auto seq_cnt = ruleList[i].second.size();
+        for(size_t j = 1; j < seq_cnt; j++)
+        {
+            rule.precedencelist.push_back(ruleList[i].second[j]);
+        }
+        auto dest_edge_id = ruleList[i].second[0];
+        if(m_ruleTable.find(dest_edge_id) != m_ruleTable.end())
+        {
+            m_ruleTable[dest_edge_id].push_back(rule);
+        }
+        else
+        {
+            std::vector<Rule> temprules;
+            temprules.clear();
+            temprules.push_back(rule);
+            m_ruleTable[dest_edge_id] = temprules;
+        }
+    }
+    
+    m_bIsturnRestrictOn = true;
+    }
+    parent = new PARENT_PATH[edge_count + 1];
+    m_dCost = new CostHolder[edge_count + 1];
+    m_vecPath.clear();
+    // int i;
+    auto total_vertices = vertices.size();
+    for(size_t i = 0; i < total_vertices - 1; i++)
+    {
+    int ret = my_dijkstra1(vertices[i], vertices[i + 1], edge_count, err_msg);
+    if(ret < 0)
+    {
+        deleteall();
+        return -1;
+    }
+    }
+
+    *path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
+    *path_count = m_vecPath.size();
+
+    for(size_t i = 0; i < *path_count; i++)
+    {
+    (*path)[i].vertex_id = m_vecPath[i].vertex_id;
+    (*path)[i].edge_id = m_vecPath[i].edge_id;
+    (*path)[i].cost = m_vecPath[i].cost;
+    }
+    deleteall();
+    return 0;
+}
+
 
 // -------------------------------------------------------------------------
-    void
-GraphDefinition::add_virtual_vertices(int start_edge_id, double start_part, int end_edge_id, double end_part,
-        int64_t &start_vertex, int64_t &end_vertex)
+int GraphDefinition::my_dijkstra1(long start_vertex, long end_vertex, size_t edge_count, char **err_msg)
 {
-    GraphEdgeInfo *start_edge_info = &m_vecEdgeVector[m_mapEdgeId2Index[start_edge_id]];
+    if(!m_bIsGraphConstructed)
+    {
+    *err_msg = (char *)"Graph not Ready!";
+    return -1;
+    }
+    unsigned int i;
+    for(i = 0; i <= edge_count; i++)
+    {
+    m_dCost[i].startCost = 1e15;
+    m_dCost[i].endCost = 1e15;
+    }
+
+    if(m_mapNodeId2Edge.find(start_vertex) == m_mapNodeId2Edge.end())
+    {
+    *err_msg = (char *)"Source Not Found";
+    deleteall();
+    return -1;
+    }
+
+    if(m_mapNodeId2Edge.find(end_vertex) == m_mapNodeId2Edge.end())
+    {
+    *err_msg = (char *)"Destination Not Found";
+    deleteall();
+    return -1;
+    }
+
+    std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > que;
+    LongVector vecsource = m_mapNodeId2Edge[start_vertex];
+    GraphEdgeInfo* cur_edge = NULL;
+
+    for(i = 0; i < vecsource.size(); i++)
+    {
+    cur_edge = m_vecEdgeVector[vecsource[i]];
+    if(cur_edge->m_lStartNode == start_vertex)
+    {
+        if(cur_edge->m_dCost >= 0.0)
+        {
+        m_dCost[cur_edge->m_lEdgeIndex].endCost= cur_edge->m_dCost;
+        parent[cur_edge->m_lEdgeIndex].v_pos[0] = -1;
+        parent[cur_edge->m_lEdgeIndex].ed_ind[0] = -1;
+        //que.push(std::make_pair(cur_edge->m_dCost, std::make_pair(cur_edge->m_lEdgeIndex, true)));
+        que.push(PDP(cur_edge->m_dCost, PIB((int)cur_edge->m_lEdgeIndex, true)));
+        }
+    }
+    else
+    {
+        if(cur_edge->m_dReverseCost >= 0.0)
+        {
+        m_dCost[cur_edge->m_lEdgeIndex].startCost = cur_edge->m_dReverseCost;
+        parent[cur_edge->m_lEdgeIndex].v_pos[1] = -1;
+        parent[cur_edge->m_lEdgeIndex].ed_ind[1] = -1;
+        //que.push(std::make_pair(cur_edge->m_dReverseCost, std::make_pair(cur_edge->m_lEdgeIndex, false)));
+        que.push(PDP(cur_edge->m_dReverseCost, PIB((int)cur_edge->m_lEdgeIndex, false)));
+        }
+    }
+    }
+    
+    // int new_node;
+    long cur_node = -1;
+
+    while(!que.empty())
+    {
+    PDP cur_pos = que.top();
+    que.pop();
+    int cured_index = cur_pos.second.first;
+    cur_edge = m_vecEdgeVector[cured_index];
+    //GraphEdgeInfo* new_edge;
+
+    if(cur_pos.second.second)      // explore edges connected to end node
+    {
+        cur_node = cur_edge->m_lEndNode;
+        if(cur_edge->m_dCost < 0.0)
+        continue;
+        if(cur_node == end_vertex)
+        break;
+        explore(cur_node, *cur_edge, true, cur_edge->m_vecEndConnedtedEdge, que);
+    }
+    else        // explore edges connected to start node
+    {
+        cur_node = cur_edge->m_lStartNode;
+        if(cur_edge->m_dReverseCost < 0.0)
+        continue;
+        if(cur_node == end_vertex)
+        break;
+        explore(cur_node, *cur_edge, false, cur_edge->m_vecStartConnectedEdge, que);
+    }
+    }
+    if(cur_node != end_vertex)
+    {
+    *err_msg = (char *)"Path Not Found";
+    deleteall();
+    return -1;
+    }
+    else
+    {
+    // double total_cost;  //set but not used
+    if(cur_node == cur_edge->m_lStartNode)
+    {
+        // total_cost = m_dCost[cur_edge->m_lEdgeIndex].startCost;
+        construct_path(cur_edge->m_lEdgeIndex, 1);
+    }
+    else
+    {
+        // total_cost = m_dCost[cur_edge->m_lEdgeIndex].endCost;
+        construct_path(cur_edge->m_lEdgeIndex, 0);
+    }
+    path_element_t pelement;
+    pelement.vertex_id = end_vertex;
+    pelement.edge_id = -1;
+    pelement.cost = 0.0;
+    m_vecPath.push_back(pelement);
+    }
+    return 0;
+}
+
+
+// -------------------------------------------------------------------------
+int GraphDefinition::my_dijkstra4(edge_t *edges, unsigned int edge_count, long start_edge_id, double start_part, long end_edge_id, double end_part, bool directed, bool has_reverse_cost,
+                path_element_t **path, size_t *path_count, char **err_msg, std::vector<PDVI> &ruleList)
+{
+    if(!m_bIsGraphConstructed)
+    {
+        init();
+        construct_graph(edges, edge_count, has_reverse_cost, directed);
+        m_bIsGraphConstructed = true;
+    }
+    GraphEdgeInfo* start_edge_info = m_vecEdgeVector[m_mapEdgeId2Index[start_edge_id]];
     edge_t start_edge;
-    //int start_vertex, end_vertex;
+    long start_vertex, end_vertex;
     m_dStartpart = start_part;
     m_dEndPart = end_part;
     m_lStartEdgeId = start_edge_id;
@@ -244,7 +441,7 @@ GraphDefinition::add_virtual_vertices(int start_edge_id, double start_part, int
             start_edge.target = start_edge_info->m_lEndNode;
             start_edge.cost = (1.0 - start_part) * start_edge_info->m_dCost;
             addEdge(start_edge);
-            m_edge_count++;
+            edge_count++;
         }
         if(start_edge_info->m_dReverseCost >= 0.0)
         {
@@ -253,13 +450,13 @@ GraphDefinition::add_virtual_vertices(int start_edge_id, double start_part, int
             start_edge.target = start_edge_info->m_lStartNode;
             start_edge.cost = start_part * start_edge_info->m_dReverseCost;
             addEdge(start_edge);
-            m_edge_count++;
+            edge_count++;
         }
     }
 
-    GraphEdgeInfo *end_edge_info = &m_vecEdgeVector[m_mapEdgeId2Index[end_edge_id]];
+    GraphEdgeInfo* end_edge_info = m_vecEdgeVector[m_mapEdgeId2Index[end_edge_id]];
     edge_t end_edge;
-
+    
     if(end_part == 0.0)
     {
         end_vertex = end_edge_info->m_lStartNode;
@@ -283,7 +480,7 @@ GraphDefinition::add_virtual_vertices(int start_edge_id, double start_part, int
             end_edge.source = end_edge_info->m_lStartNode;
             end_edge.cost = end_part * end_edge_info->m_dCost;
             addEdge(end_edge);
-            m_edge_count++;
+            edge_count++;
         }
         if(end_edge_info->m_dReverseCost >= 0.0)
         {
@@ -291,98 +488,122 @@ GraphDefinition::add_virtual_vertices(int start_edge_id, double start_part, int
             end_edge.id = max_edge_id + 1;
             end_edge.cost = (1.0 - end_part) * end_edge_info->m_dReverseCost;
             addEdge(end_edge);
-            m_edge_count++;
+            edge_count++;
         }
     }
-    //edge_count = m_edge_count;
+
+    return(my_dijkstra3(edges, edge_count, start_vertex, end_vertex, directed, has_reverse_cost, path, path_count, err_msg, ruleList));
 }
 
 
 // -------------------------------------------------------------------------
-    void
-GraphDefinition::set_restrictions(
-        int64_t start_vertex,
-        int64_t end_vertex,
-        std::vector<PDVI> &ruleList) {
+int GraphDefinition:: my_dijkstra3(edge_t *edges, unsigned int edge_count, long start_vertex, long end_vertex, bool directed, bool has_reverse_cost,
+                                  path_element_t **path, size_t *path_count, char **err_msg, std::vector<PDVI> &ruleList)
+{
     m_ruleTable.clear();
     auto total_rule = ruleList.size();
+    // int i;
     LongVector vecsource;
     unsigned int kk;
     for(size_t i = 0; i < total_rule; i++)
     {
         Rule rule;
         rule.cost = ruleList[i].first;
+        // int j;
         auto seq_cnt = ruleList[i].second.size();
-        for(size_t j = 1; j < seq_cnt; j++) {
+        for(size_t j = 1; j < seq_cnt; j++)
+        {
             rule.precedencelist.push_back(ruleList[i].second[j]);
         }
-        auto dest_edge_id = ruleList[i].second[0];
-        if(m_ruleTable.find(dest_edge_id) != m_ruleTable.end()) {
+        int dest_edge_id = ruleList[i].second[0];
+        if(m_ruleTable.find(dest_edge_id) != m_ruleTable.end())
+        {
             m_ruleTable[dest_edge_id].push_back(rule);
-        } else {
+        }
+        else
+        {
             std::vector<Rule> temprules;
             temprules.clear();
             temprules.push_back(rule);
-            m_ruleTable.insert(std::make_pair(dest_edge_id, temprules));
+            //m_ruleTable.insert(std::make_pair(dest_edge_id, temprules));
+            m_ruleTable[dest_edge_id] =  temprules;
         }
-
-        if(isStartVirtual) {
-            if(seq_cnt == 2 && ruleList[i].second[1] == m_lStartEdgeId) {
+    
+        if(isStartVirtual)
+        {
+            if(seq_cnt == 2 && ruleList[i].second[1] == m_lStartEdgeId)
+            {
                 vecsource = m_mapNodeId2Edge[start_vertex];
-                for(kk = 0; kk < vecsource.size(); kk++) {
+                for(kk = 0; kk < vecsource.size(); kk++)
+                {
                     rule.precedencelist.clear();
-                    rule.precedencelist.push_back(m_vecEdgeVector[vecsource[kk]].m_lEdgeID);
-                    m_ruleTable[dest_edge_id].push_back(rule);
+                    rule.precedencelist.push_back(m_vecEdgeVector[vecsource[kk]]->m_lEdgeID);
+                    m_ruleTable.at(dest_edge_id).push_back(rule);
                 }
             }
         }
     }
-    if(isEndVirtual) {
-        if(m_ruleTable.find(m_lEndEdgeId) != m_ruleTable.end()) {
+    if(isEndVirtual)
+    {
+        if(m_ruleTable.find(m_lEndEdgeId) != m_ruleTable.end())
+        {
             std::vector<Rule> tmpRules = m_ruleTable[m_lEndEdgeId];
             vecsource = m_mapNodeId2Edge[end_vertex];
-            for(kk = 0; kk < vecsource.size(); kk++) {
-                m_ruleTable.insert(std::make_pair(m_vecEdgeVector[vecsource[kk]].m_lEdgeID, tmpRules));
+            for(kk = 0; kk < vecsource.size(); kk++)
+            {
+                //m_ruleTable.insert(std::make_pair(m_vecEdgeVector[vecsource[kk]]->m_lEdgeID, tmpRules));
+                m_ruleTable[m_vecEdgeVector[vecsource[kk]]->m_lEdgeID] = tmpRules;
             }
         }
     }
     m_bIsturnRestrictOn = true;
+    return(my_dijkstra2(edges, edge_count, start_vertex, end_vertex, directed, has_reverse_cost, path, path_count, err_msg));
 }
 
-// THIS ONE IS THE DIJKSTRA
-// -------------------------------------------------------------------------
-int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
-        path_element_t **path, size_t *path_count,
-        std::ostringstream &log) {
 
+// -------------------------------------------------------------------------
+int GraphDefinition:: my_dijkstra2(edge_t *edges, unsigned int edge_count, long start_vertex, long end_vertex, bool directed, bool has_reverse_cost,
+                path_element_t **path, size_t *path_count, char **err_msg)
+{
+    if(!m_bIsGraphConstructed)
+    {
+        init();
+        construct_graph(edges, edge_count, has_reverse_cost, directed);
+        m_bIsGraphConstructed = true;
+    }
+    
     std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > que;
-    parent.resize(m_edge_count + 1);
-    m_dCost.resize(m_edge_count + 1);
+    parent = new PARENT_PATH[edge_count + 1];
+    m_dCost = new CostHolder[edge_count + 1];
     m_vecPath.clear();
 
-    for (auto &dcost : m_dCost) {
-        dcost.startCost = 1e15;
-        dcost.endCost = 1e15;
+    unsigned int i;
+    for(i = 0; i <= edge_count; i++)
+    {
+        m_dCost[i].startCost = 1e15;
+        m_dCost[i].endCost = 1e15;
     }
-
+    
     if(m_mapNodeId2Edge.find(start_vertex) == m_mapNodeId2Edge.end())
     {
-        log << "Source Not Found";
+        *err_msg = (char *)"Source Not Found";
+        deleteall();
         return -1;
     }
 
     if(m_mapNodeId2Edge.find(end_vertex) == m_mapNodeId2Edge.end())
     {
-        log << "Destination Not Found";
+        *err_msg = (char *)"Destination Not Found";
+        deleteall();
         return -1;
     }
 
     LongVector vecsource = m_mapNodeId2Edge[start_vertex];
-    GraphEdgeInfo *cur_edge = NULL;
+    GraphEdgeInfo* cur_edge = NULL;
 
-    for (auto &s : vecsource)
+    for(i = 0; i < vecsource.size(); i++)
     {
-        GraphEdgeInfo *cur_edge = &m_vecEdgeVector[s];
+        cur_edge = m_vecEdgeVector[vecsource[i]];
         if(cur_edge->m_lStartNode == start_vertex)
         {
             if(cur_edge->m_dCost >= 0.0)
@@ -390,37 +611,48 @@ int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
                 m_dCost[cur_edge->m_lEdgeIndex].endCost= cur_edge->m_dCost;
                 parent[cur_edge->m_lEdgeIndex].v_pos[0] = -1;
                 parent[cur_edge->m_lEdgeIndex].ed_ind[0] = -1;
-                que.push(std::make_pair(cur_edge->m_dCost, std::make_pair(cur_edge->m_lEdgeIndex, true)));
+                //que.push(std::make_pair(cur_edge->m_dCost, std::make_pair(cur_edge->m_lEdgeIndex, true)));
+                que.push(PDP(cur_edge->m_dCost, PIB((int)cur_edge->m_lEdgeIndex, true)));
             }
-        } else {
+        }
+        else
+        {
             if(cur_edge->m_dReverseCost >= 0.0)
             {
                 m_dCost[cur_edge->m_lEdgeIndex].startCost = cur_edge->m_dReverseCost;
                 parent[cur_edge->m_lEdgeIndex].v_pos[1] = -1;
                 parent[cur_edge->m_lEdgeIndex].ed_ind[1] = -1;
-                que.push(std::make_pair(cur_edge->m_dReverseCost, std::make_pair(cur_edge->m_lEdgeIndex, false)));
+                //que.push(std::make_pair(cur_edge->m_dReverseCost, std::make_pair(cur_edge->m_lEdgeIndex, false)));
+                que.push(PDP(cur_edge->m_dReverseCost, PIB((int)cur_edge->m_lEdgeIndex, false)));
             }
         }
     }
+    //parent[start_vertex].v_id = -1;
+    //parent[start_vertex].ed_id = -1;
+    //m_dCost[start_vertex] = 0.0;
 
-    int64_t cur_node = -1;
+    // int new_node;
+    long cur_node = -1;
 
-    while(!que.empty()) {
+    while(!que.empty())
+    {
         PDP cur_pos = que.top();
         que.pop();
         int cured_index = cur_pos.second.first;
-        cur_edge = &m_vecEdgeVector[cured_index];
+        cur_edge = m_vecEdgeVector[cured_index];
+        //GraphEdgeInfo* new_edge;
 
-        if(cur_pos.second.second) {
-            // explore edges connected to end node
+        if(cur_pos.second.second)      // explore edges connected to end node
+        {
             cur_node = cur_edge->m_lEndNode;
             if(cur_edge->m_dCost < 0.0)
                 continue;
             if(cur_node == end_vertex)
                 break;
             explore(cur_node, *cur_edge, true, cur_edge->m_vecEndConnedtedEdge, que);
-        } else {
-            // explore edges connected to start node
+        }
+        else        // explore edges connected to start node
+        {
             cur_node = cur_edge->m_lStartNode;
             if(cur_edge->m_dReverseCost < 0.0)
                 continue;
@@ -429,22 +661,29 @@ int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
             explore(cur_node, *cur_edge, false, cur_edge->m_vecStartConnectedEdge, que);
         }
     }
-    if(cur_node != end_vertex) {
-        if(m_lStartEdgeId == m_lEndEdgeId) {
-            if(get_single_cost(1000.0, path, path_count)) {
+    if(cur_node != end_vertex)
+    {
+        if(m_lStartEdgeId == m_lEndEdgeId)
+        {
+            if(get_single_cost(1000.0, path, path_count))
+            {
                 return 0;
             }
         }
-        log << "Path Not Found";
-        *path=NULL;
-        path_count=0;
-        return 0;
-    } else {
+        *err_msg = (char *)"Path Not Found";
+        deleteall();
+        return -1;
+    }
+    else
+    {
         double total_cost;
-        if(cur_node == cur_edge->m_lStartNode) {
+        if(cur_node == cur_edge->m_lStartNode)
+        {
             total_cost = m_dCost[cur_edge->m_lEdgeIndex].startCost;
             construct_path(cur_edge->m_lEdgeIndex, 1);
-        } else {
+        }
+        else
+        {
             total_cost = m_dCost[cur_edge->m_lEdgeIndex].endCost;
             construct_path(cur_edge->m_lEdgeIndex, 0);
         }
@@ -461,7 +700,7 @@ int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
                 return 0;
             }
         }
-
+        
         *path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
         *path_count = m_vecPath.size();
 
@@ -482,6 +721,7 @@ int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
             (*path)[*path_count - 1].edge_id = m_lEndEdgeId;
         }
     }
+    deleteall();
     return 0;
 }
 
@@ -489,7 +729,7 @@ int GraphDefinition:: my_dijkstra(int64_t start_vertex, int64_t end_vertex,
 // -------------------------------------------------------------------------
 bool GraphDefinition::get_single_cost(double total_cost, path_element_t **path, size_t *path_count)
 {
-    GraphEdgeInfo *start_edge_info = &m_vecEdgeVector[m_mapEdgeId2Index[m_lStartEdgeId]];
+    GraphEdgeInfo* start_edge_info = m_vecEdgeVector[m_mapEdgeId2Index[m_lStartEdgeId]];
     if(m_dEndPart >= m_dStartpart)
     {
         if(start_edge_info->m_dCost >= 0.0 && start_edge_info->m_dCost * (m_dEndPart - m_dStartpart) <= total_cost)
@@ -517,51 +757,27 @@ bool GraphDefinition::get_single_cost(double total_cost, path_element_t **path,
         }
     }
     return false;
-
+    
 }
 
 
 // -------------------------------------------------------------------------
-bool GraphDefinition::construct_graph(edge_t* edges, bool has_reverse_cost, bool directed) {
-    unsigned int i;
-    for(i = 0; i < m_edge_count; i++) {
-
-        /*
-         *  has_reverse_cost but cost is negative
-         *    - flip the record
-         *    - After this: cost is positive unless reverse_cost was also negative
-         */
-        if (has_reverse_cost) {
-            if (edges[i].cost < 0) {
-                auto tmp_v = edges[i].source;
-                edges[i].source = edges[i].target;
-                edges[i].target = tmp_v;
-                edges[i].cost = edges[i].reverse_cost;
-                edges[i].reverse_cost = -1.0;
-            }
-        }
-
-        /*
-         * all data in the reverse_cost column must be ignored
-         */
-        if (!has_reverse_cost) {
+bool GraphDefinition::construct_graph(edge_t* edges, int edge_count, bool has_reverse_cost, bool directed)
+{
+    int i;
+    for(i = 0; i < edge_count; i++)
+    {
+        if(!has_reverse_cost)
+        {
+        if(directed)
+        {
             edges[i].reverse_cost = -1.0;
         }
-
-        /* 
-         * when the graph is undirected:
-         * both colummns must have the same smallest positive value
-         */
-        if (!directed && !has_reverse_cost) {
+        else
+        {
             edges[i].reverse_cost = edges[i].cost;
-        } else if (!directed && has_reverse_cost) {
-            if (edges[i].reverse_cost < 0) {
-                edges[i].reverse_cost = edges[i].cost;
-            } else {
-                edges[i].reverse_cost = std::min(edges[i].reverse_cost, edges[i].cost);
-            }
         }
-
+        }
         addEdge(edges[i]);
     }
     m_bIsGraphConstructed = true;
@@ -615,26 +831,30 @@ bool GraphDefinition::addEdge(edge_t edgeIn)
     if(itMap != m_mapEdgeId2Index.end())    
         return false;
 
-
-    GraphEdgeInfo newEdge(edgeIn.id, m_vecEdgeVector.size(),
-            edgeIn.source, edgeIn.target,edgeIn.cost, edgeIn.reverse_cost);
-    newEdge.m_vecStartConnectedEdge.clear();
-    newEdge.m_vecEndConnedtedEdge.clear();
-    newEdge.m_vecRestrictedEdge.clear();
-    newEdge.m_lEdgeID = edgeIn.id;
-    newEdge.m_lEdgeIndex = m_vecEdgeVector.size();    
-    newEdge.m_lStartNode = edgeIn.source;
-    newEdge.m_lEndNode = edgeIn.target;
-    newEdge.m_dCost = edgeIn.cost;
-    newEdge.m_dReverseCost = edgeIn.reverse_cost;
-    if(edgeIn.id > max_edge_id) {
+    
+    GraphEdgeInfo* newEdge = new GraphEdgeInfo();
+    newEdge->m_vecStartConnectedEdge.clear();
+    newEdge->m_vecEndConnedtedEdge.clear();
+    newEdge->m_vecRestrictedEdge.clear();
+    newEdge->m_lEdgeID = edgeIn.id;
+    newEdge->m_lEdgeIndex = (long)m_vecEdgeVector.size();    
+    newEdge->m_lStartNode = edgeIn.source;
+    newEdge->m_lEndNode = edgeIn.target;
+    newEdge->m_dCost = edgeIn.cost;
+    newEdge->m_dReverseCost = edgeIn.reverse_cost;
+
+    if(edgeIn.id > max_edge_id)
+    {
         max_edge_id = edgeIn.id;
     }
 
-    if(newEdge.m_lStartNode > max_node_id) { max_node_id = newEdge.m_lStartNode;
+    if(newEdge->m_lStartNode > max_node_id)
+    {
+        max_node_id = newEdge->m_lStartNode;
     }
-
-    if(newEdge.m_lEndNode > max_node_id) { max_node_id = newEdge.m_lEndNode;
+    if(newEdge->m_lEndNode > max_node_id)
+    {
+        max_node_id = newEdge->m_lEndNode;
     }
 
     //Searching the start node for connectivity
@@ -643,12 +863,12 @@ bool GraphDefinition::addEdge(edge_t edgeIn)
     {
         //Connect current edge with existing edge with start node
         //connectEdge(
-        int64_t lEdgeCount = itNodeMap->second.size();
-        int64_t lEdgeIndex;
+        long lEdgeCount = (long)itNodeMap->second.size();
+        long lEdgeIndex;
         for(lEdgeIndex = 0; lEdgeIndex < lEdgeCount; lEdgeIndex++)
         {
-            int64_t lEdge = itNodeMap->second.at(lEdgeIndex);    
-            connectEdge(newEdge, m_vecEdgeVector[lEdge], true);
+            long lEdge = itNodeMap->second.at(lEdgeIndex);    
+            connectEdge(*newEdge, *m_vecEdgeVector[lEdge], true);
         }
     }
 
@@ -659,24 +879,25 @@ bool GraphDefinition::addEdge(edge_t edgeIn)
     {
         //Connect current edge with existing edge with end node
         //connectEdge(
-        int64_t lEdgeCount = itNodeMap->second.size();
-        int64_t lEdgeIndex;
+        long lEdgeCount = (long)itNodeMap->second.size();
+        long lEdgeIndex;
         for(lEdgeIndex = 0; lEdgeIndex < lEdgeCount; lEdgeIndex++)
         {
-            int64_t lEdge = itNodeMap->second.at(lEdgeIndex);    
-            connectEdge(newEdge, m_vecEdgeVector[lEdge], false);
+            long lEdge = itNodeMap->second.at(lEdgeIndex);    
+            connectEdge(*newEdge, *m_vecEdgeVector[lEdge], false);
         }
     }
 
 
 
     //Add this node and edge into the data structure
-    m_mapNodeId2Edge[edgeIn.source].push_back(newEdge.m_lEdgeIndex);
-    m_mapNodeId2Edge[edgeIn.target].push_back(newEdge.m_lEdgeIndex);
+    m_mapNodeId2Edge[edgeIn.source].push_back(newEdge->m_lEdgeIndex);
+    m_mapNodeId2Edge[edgeIn.target].push_back(newEdge->m_lEdgeIndex);
 
 
     //Adding edge to the list
-    m_mapEdgeId2Index.insert(std::make_pair(newEdge.m_lEdgeID, m_vecEdgeVector.size()));
+    //m_mapEdgeId2Index.insert(std::make_pair(newEdge->m_lEdgeID, m_vecEdgeVector.size()));
+    m_mapEdgeId2Index[newEdge->m_lEdgeID] = (long)m_vecEdgeVector.size();
     m_vecEdgeVector.push_back(newEdge);
 
     //
diff --git a/src/trsp/src/GraphDefinition.h b/src/trsp/src/GraphDefinition.h
index 85c4733..2ea1944 100644
--- a/src/trsp/src/GraphDefinition.h
+++ b/src/trsp/src/GraphDefinition.h
@@ -1,159 +1,156 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 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.
-
-********************************************************************PGR-GNU*/
 #ifndef GRAPHDEFINITION_H
 #define GRAPHDEFINITION_H
 
 #include <vector>
 #include <map>
 #include <queue>
-#if defined(_MSC_VER) && _MSC_VER >= 1700
+#include <string>
+#include <stdlib.h>
+#include <iostream>
 #include <functional>
-#endif
-#include <sstream>
-#include "trsp_driver.h"
-
-
-typedef std::pair<double, std::vector<int64_t> > PDVI;
-
-
-class GraphDefinition {
-    typedef std::vector<int64_t> LongVector;
-    typedef std::vector<LongVector> VectorOfLongVector;
-    typedef std::pair<int, bool> PIB;
-    typedef std::pair<double, PIB> PDP;
-    typedef struct{
-        int64_t ed_ind[2];
-        int64_t v_pos[2];
-    } PARENT_PATH;
-
-    typedef struct{
-        double cost;
-        std::vector<int64_t> precedencelist;
-    } Rule;
-
-    typedef struct{
-        double startCost, endCost;
-    } CostHolder;
 
-    typedef std::map<int64_t, std::vector<Rule> > RuleTable;
-
-
-
-    class GraphEdgeInfo {
-     public:
-         GraphEdgeInfo() = default;
-         GraphEdgeInfo(int64_t eid, int64_t index, int64_t node1, int64_t node2, double cost, double reverse_cost) :
-             m_lEdgeID(eid), m_lEdgeIndex(index), m_lStartNode(node1), m_lEndNode(node2),
-             m_dCost(cost), m_dReverseCost(reverse_cost) {
-                 m_vecStartConnectedEdge.clear();
-                 m_vecEndConnedtedEdge.clear();
-                 m_vecRestrictedEdge.clear();
-             }
 
+#include "trsp.h"
+
+//using namespace std;
+
+typedef std::vector<long> LongVector;
+typedef std::vector<LongVector> VectorOfLongVector;
+typedef std::pair<int, bool> PIB;
+typedef std::pair<double, PIB> PDP;
+typedef std::pair<double, std::vector<int> > PDVI;
+
+/*
+typedef struct edge 
+{
+    int id;
+    int source;
+    int target;
+    double cost;
+    double reverse_cost;
+} edge_t;
+
+typedef struct path_element 
+{
+    int vertex_id;
+    int edge_id;
+    double cost;
+}path_element_t;
+*/
+
+typedef struct{
+    long ed_ind[2];
+    int v_pos[2];
+} PARENT_PATH;
+
+typedef struct{
+    double cost;
+    std::vector<long> precedencelist;
+} Rule;
+
+typedef struct{
+    double startCost, endCost;
+} CostHolder;
+
+typedef std::map<long, std::vector<Rule> > RuleTable;
+
+
+
+class GraphEdgeInfo
+{
+public:
+    long m_lEdgeID;
+    long m_lEdgeIndex;
+    short m_sDirection;
+    double m_dCost;
+    double m_dReverseCost;
+    LongVector m_vecStartConnectedEdge;
+    LongVector m_vecEndConnedtedEdge;
+    //LongVector m_vecConnectedNode;
+    bool m_bIsLeadingRestrictedEdge;
+    VectorOfLongVector m_vecRestrictedEdge;
+
+    long m_lStartNode;
+    long m_lEndNode;
+};
 
-     public:
-         int64_t m_lEdgeID;
-         int64_t m_lEdgeIndex;
-         int64_t m_lStartNode;
-         int64_t m_lEndNode;
-         double m_dCost;
-         double m_dReverseCost;
-         short m_sDirection;
-         LongVector m_vecStartConnectedEdge;
-         LongVector m_vecEndConnedtedEdge;
-         //LongVector m_vecConnectedNode;
-         bool m_bIsLeadingRestrictedEdge;
-         VectorOfLongVector m_vecRestrictedEdge;
 
-    };
 
 
-    typedef std::vector<GraphEdgeInfo> GraphEdgeVector;
-    typedef std::map<int64_t,LongVector> Long2LongVectorMap;
-    typedef std::map<int64_t,int64_t> Long2LongMap;
+typedef std::vector<GraphEdgeInfo*> GraphEdgeVector;
+typedef std::map<long,LongVector> Long2LongVectorMap;
+typedef std::map<long,long> Long2LongMap;
 
 
 
 
- public:
+class GraphDefinition
+{
+public:
+    GraphDefinition(void);
     ~GraphDefinition(void);
-    GraphDefinition(
-            edge_t *edges,
-            unsigned int edge_count,
-            bool directed, 
-            bool has_rcost);
-
-
-    int my_dijkstra(
-            int64_t start_vertex, int64_t end_vertex,
-            path_element_t **path, size_t *path_count,
-            std::ostringstream &log);
-
-    void set_restrictions(
-            int64_t start_vertex,
-            int64_t end_vertex,
-            std::vector<PDVI> &ruleList);
 
-    void add_virtual_vertices(
-            int start_edge, double start_part,
-            int end_edge, double end_part,
-            int64_t &start_vertex, int64_t &end_vertex);
-
-
-    bool construct_graph(
-            edge_t *edges,
-            bool has_rcost,
-            bool directed);
-
-
- private:
-    double construct_path(int64_t ed_id, int64_t v_pos);
-    void explore(int64_t cur_node, GraphEdgeInfo& cur_edge, bool isStart, LongVector &vecIndex, std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > &que);
-    double getRestrictionCost(int64_t cur_node, GraphEdgeInfo &new_edge, bool isStart);
-    bool addEdge(edge_t edgeIn);
-    bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo &secondEdge, bool bIsStartNodeSame);
+    int my_dijkstra1(long start_vertex, long end_vertex,
+                    size_t edge_count, char** err_msg);
+
+    int my_dijkstra2(edge_t *edges, unsigned int edge_count,
+                    long start_vertex, long end_vertex,
+                    bool directed, bool has_reverse_cost,
+                    path_element_t **path, size_t *path_count,
+                    char **err_msg);
+
+    int my_dijkstra3(edge_t *edges, unsigned int edge_count,
+                    long start_vertex, long end_vertex,
+                    bool directed, bool has_reverse_cost,
+                    path_element_t **path, size_t *path_count,
+                    char **err_msg,
+                    std::vector<PDVI> &ruleList);
+
+    int my_dijkstra4(edge_t *edges, unsigned int edge_count,
+                    long start_edge, double start_part,
+                    long end_edge, double end_part,
+                    bool directed, bool has_reverse_cost,
+                    path_element_t **path, size_t *path_count,
+                    char **err_msg,
+                    std::vector<PDVI> &ruleList);
+
+    int multi_dijkstra(edge_t *edges, unsigned int edge_count,
+                       std::vector<int> vertices,
+                       bool directed, bool has_reverse_cost,
+                       path_element_t **path, size_t *path_count,
+                       char **err_msg,
+                       std::vector<PDVI> &ruleList);
+
+    bool construct_graph(edge_t *edges, int edge_count,
+                         bool has_reverse_cost, bool directed);
+
+
+private:
+    double construct_path(long ed_id, int v_pos);
+    void explore(long cur_node, GraphEdgeInfo& cur_edge, bool isStart, LongVector &vecIndex, std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > &que);
+    double getRestrictionCost(long cur_node, GraphEdgeInfo& new_edge, bool isStart);
+    bool addEdge(edge edgeIn);
+    bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
     bool get_single_cost(double total_cost, path_element_t **path, size_t *path_count);
     void init();
     void deleteall();
 
- private:
+private:
     GraphEdgeVector m_vecEdgeVector;
     Long2LongMap m_mapEdgeId2Index;
     Long2LongVectorMap m_mapNodeId2Edge;
-    int64_t max_node_id;
-    int64_t max_edge_id;
-    int m_lStartEdgeId;
-    int m_lEndEdgeId;
+    long max_node_id;
+    long max_edge_id;
+    long m_lStartEdgeId;
+    long m_lEndEdgeId;
     double m_dStartpart;
     double m_dEndPart;
     bool isStartVirtual;
     bool isEndVirtual;
-
-    unsigned int m_edge_count;
-
+    
     std::vector <path_element_t> m_vecPath;
-    std::vector < PARENT_PATH > parent;
-    std::vector < CostHolder > m_dCost;
+    PARENT_PATH *parent;
+    CostHolder *m_dCost;
     RuleTable m_ruleTable;
     bool m_bIsturnRestrictOn;
     bool m_bIsGraphConstructed;
diff --git a/src/trsp/src/trsp.c b/src/trsp/src/trsp.c
index 40be22a..7bb40c7 100644
--- a/src/trsp/src/trsp.c
+++ b/src/trsp/src/trsp.c
@@ -20,6 +20,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -29,185 +30,560 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 #include "fmgr.h"
-#include "trsp_driver.h"
+#include "trsp.h"
+
+#include "./../../common/src/debug_macro.h"
 
 PGDLLEXPORT Datum turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS);
 PGDLLEXPORT Datum turn_restrict_shortest_path_edge(PG_FUNCTION_ARGS);
 
-// #define DEBUG 
-#include "../../common/src/debug_macro.h"
-#include "../../common/src/pgr_types.h"
-#include "../../common/src/postgres_connection.h"
-#include "../../common/src/edges_input.h"
-#include "../../common/src/restrictions_input.h"
-
+#if 0
+#undef DEBUG
+//#define DEBUG 1
 
-static int compute_trsp(
-        char* edges_sql,
-        int dovertex,
-        int start_id,
-        double start_pos,
-        int end_id,
-        double end_pos,
-        bool directed, 
-        bool has_reverse_cost,
-        char *restrict_sql,
-        path_element_t **path,
-        size_t *path_count) {
-    pgr_SPI_connect();
-
-    PGR_DBG("Load edges");
-    pgr_edge_t *edges = NULL;
-    size_t total_tuples = 0;
-    pgr_get_edges(edges_sql, &edges, &total_tuples);
-    PGR_DBG("Total %ld edges", total_tuples);
-
-    PGR_DBG("Load restrictions");
-    restrict_t *restricts = NULL;
-    size_t total_restrict_tuples = 0;
-    if (restrict_sql == NULL) {
-        PGR_DBG("Sql for restrictions is null.");
-    } else {
-        pgr_get_restriction_data(restrict_sql, &restricts, &total_restrict_tuples);
-    }
 #ifdef DEBUG
-    int t1;
-    for (t1=0; t1<total_restrict_tuples; t1++) {
-        PGR_DBG("restricts: %.2f, %ld, %ld, %ld, %ld, %ld, %ld", restricts[t1].to_cost,
-                restricts[t1].target_id, restricts[t1].via[0], restricts[t1].via[1], restricts[t1].via[2], restricts[t1].via[3], restricts[t1].via[4]);
-    }
+#define PGR_DBG(format, arg...)                     \
+    elog(NOTICE, format , ## arg)
+#else
+#define PGR_DBG(format, arg...) do { ; } while (0)
+#endif
 #endif
-    PGR_DBG("Total %ld restriction", total_restrict_tuples);
-
 
-    int v_max_id=0;
-    int v_min_id=INT_MAX;
+// The number of tuples to fetch from the SPI cursor at each iteration
+#define TUPLIMIT 1000
 
-    /* track if start and end are both in edge tuples */
-    int s_count = 0;
-    int t_count = 0;
+//#ifdef PG_MODULE_MAGIC
+//PG_MODULE_MAGIC;
+//#endif
 
-    char *err_msg;
-    int ret = -1;
-    register int z;
+typedef struct edge_columns
+{
+  int id;
+  int source;
+  int target;
+  int cost;
+  int reverse_cost;
+} edge_columns_t;
+
+typedef struct restrict_columns
+{
+  int target_id;
+  int via_path;
+  int to_cost;
+} restrict_columns_t;
 
-    PGR_DBG("start turn_restrict_shortest_path\n");
 
-    if (start_id == end_id) {
-        PGR_DBG("Starting vertex and Ending Vertex are equal");
-        *path = NULL;
-        return 0;
-    }
 
+static char *
+text2char(text *in)
+{
+  char *out = palloc(VARSIZE(in));
 
-    //defining min and max vertex id
+  memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
+  out[VARSIZE(in) - VARHDRSZ] = '\0';
+  return out;
+}
 
-    PGR_DBG("Total %ld edge tuples", total_tuples);
+static int
+finish(int code, int ret)
+{
+  PGR_DBG("In finish, trying to disconnect from spi %d",ret);
+  code = SPI_finish();
+  if (code  != SPI_OK_FINISH )
+  {
+    elog(ERROR,"couldn't disconnect from SPI");
+    return -1 ;
+  }			
+  return ret;
+}
 
-    for(z=0; z<total_tuples; z++) {
-        if(edges[z].source<v_min_id)
-            v_min_id=(int)edges[z].source;
+/*
+ * This function fetches the resturction columns from an SPITupleTable..
+ *
+*/
+static int
+fetch_restrict_columns(SPITupleTable *tuptable,
+                       restrict_columns_t *restrict_columns)
+{
+  restrict_columns->target_id = SPI_fnumber(SPI_tuptable->tupdesc, "target_id");
+  restrict_columns->via_path = SPI_fnumber(SPI_tuptable->tupdesc, "via_path");
+  restrict_columns->to_cost =  SPI_fnumber(SPI_tuptable->tupdesc, "to_cost");
+  if (restrict_columns->target_id == SPI_ERROR_NOATTRIBUTE ||
+      restrict_columns->via_path == SPI_ERROR_NOATTRIBUTE ||
+      restrict_columns->to_cost == SPI_ERROR_NOATTRIBUTE) {
+    elog(ERROR, "Error, restriction query must return columns "
+        "'target_id', 'via_path' and 'to_cost'");
+    return -1;
+  }
+
+  if (SPI_gettypeid(SPI_tuptable->tupdesc, restrict_columns->target_id) != INT4OID ||
+      SPI_gettypeid(SPI_tuptable->tupdesc, restrict_columns->via_path) != TEXTOID ||
+      SPI_gettypeid(SPI_tuptable->tupdesc, restrict_columns->to_cost) != FLOAT8OID) {
+    elog(ERROR, "Error, restriction columns 'target_id' must be of type int4, 'via_path' must be of type text, 'to_cost' must be of type float8");
+    return -1;
+  }
+
+  return 0;
+}
 
-        if(edges[z].source>v_max_id)
-            v_max_id=(int)edges[z].source;
+/*
+ * This function fetches the edge columns from the SPITupleTable.
+ * 
+*/ 
+static int
+fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns, 
+                   bool has_reverse_cost)
+{
+  edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
+  edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
+  edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
+  edge_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
+  if (edge_columns->id == SPI_ERROR_NOATTRIBUTE ||
+      edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
+      edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
+      edge_columns->cost == SPI_ERROR_NOATTRIBUTE) 
+    {
+      elog(ERROR, "Error, query must return columns "
+           "'id', 'source', 'target' and 'cost'");
+      return -1;
+    }
 
-        if(edges[z].target<v_min_id)
-            v_min_id=(int)edges[z].target;
+  if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->source) != INT4OID ||
+      SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->target) != INT4OID ||
+      SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) 
+    {
+      elog(ERROR, "Error, columns 'source', 'target' must be of type int4, 'cost' must be of type float8");
+      return -1;
+    }
 
-        if(edges[z].target>v_max_id)
-            v_max_id=(int)edges[z].target;      
-        //PGR_DBG("%i <-> %i", v_min_id, v_max_id);
+  PGR_DBG("columns: id %i source %i target %i cost %i", 
+      edge_columns->id, edge_columns->source, 
+      edge_columns->target, edge_columns->cost);
 
-    }
+  if (has_reverse_cost)
+    {
+      edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc, 
+                                               "reverse_cost");
 
-//<<<<<<< HEAD
-    //::::::::::::::::::::::::::::::::::::  
-    //:: reducing vertex id (renumbering)
-    //::::::::::::::::::::::::::::::::::::
-    for(z=0; z<total_tuples; z++) {
-        //check if edges[] contains source and target
-        if (dovertex) {
-            if(edges[z].source == start_id || edges[z].target == start_id)
-                ++s_count;
-            if(edges[z].source == end_id || edges[z].target == end_id)
-                ++t_count;
+      if (edge_columns->reverse_cost == SPI_ERROR_NOATTRIBUTE) 
+        {
+          elog(ERROR, "Error, reverse_cost is used, but query did't return "
+               "'reverse_cost' column");
+          return -1;
         }
-        else {
-            if(edges[z].id == start_id)
-                ++s_count;
-            if(edges[z].id == end_id)
-                ++t_count;
+
+      if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->reverse_cost) 
+          != FLOAT8OID) 
+        {
+          elog(ERROR, "Error, columns 'reverse_cost' must be of type float8");
+          return -1;
         }
 
-        edges[z].source-=v_min_id;
-        edges[z].target-=v_min_id;
-        edges[z].cost = edges[z].cost;
-        //PGR_DBG("edgeID: %i SRc:%i - %i, cost: %f", edges[z].id,edges[z].source, edges[z].target,edges[z].cost);      
+      PGR_DBG("columns: reverse_cost cost %i", edge_columns->reverse_cost);
+    }
+    
+  return 0;
+}
 
+/*
+ * To fetch a edge from Tuple.
+ * 
+ */
+ 
+static void
+fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc, 
+           edge_columns_t *edge_columns, edge_t *target_edge)
+{
+  Datum binval;
+  bool isnull;
+
+  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->id, &isnull);
+  if (isnull)
+    elog(ERROR, "id contains a null value");
+  target_edge->id = DatumGetInt32(binval);
+
+  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->source, &isnull);
+  if (isnull)
+    elog(ERROR, "source contains a null value");
+  target_edge->source = DatumGetInt32(binval);
+
+  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->target, &isnull);
+  if (isnull)
+    elog(ERROR, "target contains a null value");
+  target_edge->target = DatumGetInt32(binval);
+
+  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->cost, &isnull);
+  if (isnull)
+    elog(ERROR, "cost contains a null value");
+  target_edge->cost = DatumGetFloat8(binval);
+
+  if (edge_columns->reverse_cost != -1) 
+    {
+      binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->reverse_cost, 
+                             &isnull);
+      if (isnull)
+        elog(ERROR, "reverse_cost contains a null value");
+      target_edge->reverse_cost =  DatumGetFloat8(binval);
     }
 
-    PGR_DBG("Min vertex id: %i , Max vid: %i",v_min_id,v_max_id);
-    PGR_DBG("Total %ld edge tuples", total_tuples);
+  /*
+  PGR_DBG("edge: %i, %i, %i, %f, %f", target_edge->id, target_edge->source,
+    target_edge->target, target_edge->cost, target_edge->reverse_cost);
+  */
+}
 
-    if(s_count == 0) {
-        elog(ERROR, "Start id was not found.");
-        return -1;
-    }
 
-    if(t_count == 0) {
-        elog(ERROR, "Target id was not found.");
-        return -1;
-    }
+/*
+ * To fetch a edge from Tuple.
+ * 
+ */
+ 
+static void
+fetch_restrict(HeapTuple *tuple, TupleDesc *tupdesc, 
+           restrict_columns_t *restrict_columns, restrict_t *rest)
+{
+  Datum binval;
+  bool isnull;
+  int t;
 
-    if (dovertex) {
-        start_id -= v_min_id;
-        end_id   -= v_min_id;
+  for(t=0; t<MAX_RULE_LENGTH;++t)
+    rest->via[t] = -1;
+
+  binval = SPI_getbinval(*tuple, *tupdesc, restrict_columns->target_id, &isnull);
+  if (isnull)
+    elog(ERROR, "target_id contains a null value");
+  rest->target_id = DatumGetInt32(binval);
+
+  binval = SPI_getbinval(*tuple, *tupdesc, restrict_columns->to_cost, &isnull);
+  if (isnull)
+    elog(ERROR, "to_cost contains a null value");
+  rest->to_cost = DatumGetFloat8(binval);
+  char *str = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, restrict_columns->via_path));
+
+  //PGR_DBG("restriction: %f, %i, %s", rest->to_cost, rest->target_id, str);
+
+  if (str != NULL) {
+    char* pch = NULL;
+    int ci = 0;
+
+    pch = (char *)strtok (str," ,");
+
+    while (pch != NULL && ci < MAX_RULE_LENGTH)
+    {
+      rest->via[ci] = atoi(pch);
+      //PGR_DBG("    rest->via[%i]=%i", ci, rest->via[ci]);
+      ci++;
+      pch = (char *)strtok (NULL, " ,");
     }
+  }
+
+}
+
 
+
+static int compute_trsp(
+    char* sql,
+    int dovertex,
+    long start_id,
+    double start_pos,
+    long end_id,
+    double end_pos,
+    bool directed, 
+    bool has_reverse_cost,
+    char* restrict_sql,
+    path_element_t **path,
+    uint32_t *path_count) 
+{
+
+  int SPIcode;
+  SPIPlanPtr SPIplan;
+  Portal SPIportal;
+  bool moredata = TRUE;
+  size_t ntuples;
+
+  edge_t *edges = NULL;
+  size_t total_tuples = 0;
+#ifndef _MSC_VER
+  edge_columns_t edge_columns = {.id= -1, .source= -1, .target= -1, 
+                                 .cost= -1, .reverse_cost= -1};
+#else // _MSC_VER
+  edge_columns_t edge_columns = {-1, -1, -1, -1, -1};
+#endif //_MSC_VER
+  restrict_t *restricts = NULL;
+  size_t total_restrict_tuples = 0;
+
+#ifndef _MSC_VER
+  restrict_columns_t restrict_columns = {.target_id= -1, .via_path= -1,
+                                 .to_cost= -1};
+#else // _MSC_VER
+  restrict_columns_t restrict_columns = {-1, -1, -1};
+#endif //_MSC_VER
+
+  long v_max_id=0;
+  long v_min_id=INT_MAX;
+
+  /* track if start and end are both in edge tuples */
+  int s_count = 0;
+  int t_count = 0;
+
+  char *err_msg;
+  int ret = -1;
+  uint32_t z;
+
+  PGR_DBG("start turn_restrict_shortest_path\n");
+        
+  SPIcode = SPI_connect();
+  if (SPIcode  != SPI_OK_CONNECT) {
+      elog(ERROR, "turn_restrict_shortest_path: couldn't open a connection to SPI");
+      return -1;
+  }
+
+  SPIplan = SPI_prepare(sql, 0, NULL);
+  if (SPIplan  == NULL) {
+      elog(ERROR, "turn_restrict_shortest_path: couldn't create query plan via SPI");
+      return -1;
+  }
+
+  if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
+      elog(ERROR, "turn_restrict_shortest_path: SPI_cursor_open('%s') returns NULL", sql);
+      return -1;
+  }
+
+  while (moredata == TRUE) {
+      //PGR_DBG("calling SPI_cursor_fetch");
+      SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
+
+      if (SPI_tuptable == NULL) {
+          elog(ERROR, "SPI_tuptable is NULL");
+          return finish(SPIcode, -1);
+      }
+
+      if (edge_columns.id == -1) {
+          if (fetch_edge_columns(SPI_tuptable, &edge_columns, 
+                                 has_reverse_cost) == -1)
+	        return finish(SPIcode, ret);
+      }
+
+      ntuples = SPI_processed;
+
+      //PGR_DBG("Reading edges: %i - %i", total_tuples, total_tuples+ntuples);
+
+      total_tuples += ntuples;
+
+      if (ntuples > 0) {
+          if (!edges)
+            edges = palloc(total_tuples * sizeof(edge_t));
+          else
+            edges = repalloc(edges, total_tuples * sizeof(edge_t));
+
+          if (edges == NULL) {
+              elog(ERROR, "Out of memory");
+              return finish(SPIcode, ret);	  
+          }
+
+          uint32_t t;
+          SPITupleTable *tuptable = SPI_tuptable;
+          TupleDesc tupdesc = SPI_tuptable->tupdesc;
+                
+          for (t = 0; t < ntuples; t++) {
+              //if (t%100 == 0) { PGR_DBG("    t: %i", t); }
+              HeapTuple tuple = tuptable->vals[t];
+              fetch_edge(&tuple, &tupdesc, &edge_columns, 
+                         &edges[total_tuples - ntuples + t]);
+          }
+          //PGR_DBG("calling SPI_freetuptable");
+          SPI_freetuptable(tuptable);
+          //PGR_DBG("back from SPI_freetuptable");
+      } 
+      else {
+          moredata = FALSE;
+      }
+  }
+  SPI_cursor_close(SPIportal);
+
+  //defining min and max vertex id
+      
+  //PGR_DBG("Total %i edge tuples", total_tuples);
+    
+  for(z=0; z<total_tuples; z++) {
+    if(edges[z].source<v_min_id)
+      v_min_id=edges[z].source;
+  
+    if(edges[z].source>v_max_id)
+      v_max_id=edges[z].source;
+		            
+    if(edges[z].target<v_min_id)
+      v_min_id=edges[z].target;
+
+    if(edges[z].target>v_max_id)
+      v_max_id=edges[z].target;      
+								        
+    //PGR_DBG("%i <-> %i", v_min_id, v_max_id);
+							
+  }
+	
+  //::::::::::::::::::::::::::::::::::::  
+  //:: reducing vertex id (renumbering)
+  //::::::::::::::::::::::::::::::::::::
+  for(z=0; z<total_tuples; z++) {
+    //check if edges[] contains source and target
     if (dovertex) {
-        PGR_DBG("Calling trsp_node_wrapper\n");
-        ret = trsp_node_wrapper(edges, total_tuples, 
-                restricts, total_restrict_tuples,
-                start_id, end_id,
-                directed, has_reverse_cost,
-                path, path_count, &err_msg);
+        if(edges[z].source == start_id || edges[z].target == start_id)
+          ++s_count;
+        if(edges[z].source == end_id || edges[z].target == end_id)
+          ++t_count;
     }
     else {
-        PGR_DBG("Calling trsp_edge_wrapper\n");
-        ret = trsp_edge_wrapper(edges, total_tuples, 
-                restricts, total_restrict_tuples,
-                start_id, start_pos, end_id, end_pos,
-                directed, has_reverse_cost,
-                path, path_count, &err_msg);
+        if(edges[z].id == start_id)
+          ++s_count;
+        if(edges[z].id == end_id)
+          ++t_count;
     }
 
-    PGR_DBG("Message received from inside:");
-    PGR_DBG("%s",err_msg);
-
-    //PGR_DBG("SIZE %i\n",*path_count);
-
-    //::::::::::::::::::::::::::::::::
-    //:: restoring original vertex id
-    //::::::::::::::::::::::::::::::::
-    for(z=0;z<*path_count;z++) {
-        //PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
-        if (z || (*path)[z].vertex_id != -1)
-            (*path)[z].vertex_id+=v_min_id;
+    edges[z].source-=v_min_id;
+    edges[z].target-=v_min_id;
+    edges[z].cost = edges[z].cost;
+    //PGR_DBG("edgeID: %i SRc:%i - %i, cost: %f", edges[z].id,edges[z].source, edges[z].target,edges[z].cost);      
+    
+  }
+
+  PGR_DBG("Min vertex id: %ld , Max vid: %ld",v_min_id,v_max_id);
+  PGR_DBG("Total %ld edge tuples", total_tuples);
+
+  if(s_count == 0) {
+    elog(ERROR, "Start id was not found.");
+    return -1;
+  }
+      
+  if(t_count == 0) {
+    elog(ERROR, "Target id was not found.");
+    return -1;
+  }
+  
+  if (dovertex) {
+      start_id -= v_min_id;
+      end_id   -= v_min_id;
+  }
+  
+  PGR_DBG("Fetching restriction tuples\n");
+        
+  if (restrict_sql == NULL) {
+      PGR_DBG("Sql for restrictions is null.");
+  }
+  else {
+      SPIplan = SPI_prepare(restrict_sql, 0, NULL);
+      if (SPIplan  == NULL) {
+          elog(ERROR, "turn_restrict_shortest_path: couldn't create query plan via SPI");
+          return -1;
+      }
+
+      if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
+          elog(ERROR, "turn_restrict_shortest_path: SPI_cursor_open('%s') returns NULL", restrict_sql);
+          return -1;
+      }
+
+      moredata = TRUE;
+      while (moredata == TRUE) {
+          SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
+
+          if (restrict_columns.target_id == -1) {
+              if (fetch_restrict_columns(SPI_tuptable, &restrict_columns) == -1) {
+                PGR_DBG("fetch_restrict_columns failed!");
+                return finish(SPIcode, ret);
+              }
+          }
+
+          ntuples = SPI_processed;
+          total_restrict_tuples += ntuples;
+
+          //PGR_DBG("Reading Restrictions: %i", total_restrict_tuples);
+
+          if (ntuples > 0) {
+              if (!restricts)
+                restricts = palloc(total_restrict_tuples * sizeof(restrict_t));
+              else
+                restricts = repalloc(restricts, total_restrict_tuples * sizeof(restrict_t));
+
+              if (restricts == NULL) {
+                  elog(ERROR, "Out of memory");
+                  return finish(SPIcode, ret);
+              }
+
+              uint32_t t;
+              SPITupleTable *tuptable = SPI_tuptable;
+              TupleDesc tupdesc = SPI_tuptable->tupdesc;
+
+              for (t = 0; t < ntuples; t++) {
+                  HeapTuple tuple = tuptable->vals[t];
+                  fetch_restrict(&tuple, &tupdesc, &restrict_columns,
+                             &restricts[total_restrict_tuples - ntuples + t]);
+              }
+              SPI_freetuptable(tuptable);
+          }
+          else {
+              moredata = FALSE;
+          }
+      }
+      SPI_cursor_close(SPIportal);
+
+  }
+
+#ifdef DEBUG_OFF
+    int t;
+    for (t=0; t<total_restrict_tuples; t++) {
+        PGR_DBG("restricts: %.2f, %i, %i, %i, %i, %i, %i", restricts[t].to_cost, restricts[t].target_id, restricts[t].via[0], restricts[t].via[1], restricts[t].via[2], restricts[t].via[3], restricts[t].via[4]);
     }
+#endif
 
-    PGR_DBG("ret = %i\n", ret);
-
-    PGR_DBG("*path_count = %ld\n", *path_count);
-
-    if (ret < 0)
+  PGR_DBG("Total %ld restriction tuples", total_restrict_tuples);
+
+  if (dovertex) {
+      PGR_DBG("Calling trsp_node_wrapper\n");
+      /** hack always returns 0 -1 when installed on EDB VC++ 64-bit without this **/
+      #if defined(__MINGW64__) 
+      //  elog(NOTICE,"Calling trsp_node_wrapper\n");
+      #endif
+      ret = trsp_node_wrapper(edges, (uint32_t)total_tuples, 
+                        restricts, (uint32_t)total_restrict_tuples,
+                        start_id, end_id,
+                        directed, has_reverse_cost,
+                        path, path_count, &err_msg);
+  }
+  else {
+      PGR_DBG("Calling trsp_edge_wrapper\n");
+      ret = trsp_edge_wrapper(edges, (uint32_t)total_tuples, 
+                        restricts, (uint32_t)total_restrict_tuples,
+                        start_id, start_pos, end_id, end_pos,
+                        directed, has_reverse_cost,
+                        path, path_count, &err_msg);
+  }
+
+  PGR_DBG("Message received from inside:");
+  PGR_DBG("%s",err_msg);
+
+  //PGR_DBG("SIZE %i\n",*path_count);
+
+  //::::::::::::::::::::::::::::::::
+  //:: restoring original vertex id
+  //::::::::::::::::::::::::::::::::
+  for(z=0;z<*path_count;z++) {
+    //PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
+    if (z || (*path)[z].vertex_id != -1)
+        (*path)[z].vertex_id+=v_min_id;
+  }
+
+  PGR_DBG("ret = %i\n", ret);
+
+  PGR_DBG("*path_count = %i\n", *path_count);
+
+  if (ret < 0)
     {
-        //elog(ERROR, "Error computing path: %s", err_msg);
-        ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), 
-                    errmsg("Error computing path: %s", err_msg)));
+      //elog(ERROR, "Error computing path: %s", err_msg);
+      ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), 
+        errmsg("Error computing path: %s", err_msg)));
     } 
-
-    pgr_SPI_finish();
-    return 0;
+    
+  return finish(SPIcode, ret);
 }
 
 
@@ -216,130 +592,130 @@ PG_FUNCTION_INFO_V1(turn_restrict_shortest_path_vertex);
 PGDLLEXPORT Datum
 turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS)
 {
+	
+  FuncCallContext     *funcctx;
+  uint32_t                  call_cntr;
+  uint32_t                  max_calls;
+  TupleDesc            tuple_desc;
+  path_element_t      *path;
+  char *               sql;
 
-    FuncCallContext     *funcctx;
-    uint32_t                  call_cntr;
-    uint32_t                  max_calls;
-    TupleDesc            tuple_desc;
-    path_element_t      *path;
-    char *               sql;
 
+  // stuff done only on the first call of the function 
+  if (SRF_IS_FIRSTCALL()) {
+      MemoryContext   oldcontext;
+      uint32_t path_count = 0;
 
-    // stuff done only on the first call of the function 
-    if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
-        size_t path_count = 0;
+      int ret = -1;
+      if (ret == -1) {}; // to avoid warning set but not used
 
-        int ret = -1;
-        if (ret == -1) {}; // to avoid warning set but not used
+      int i;
 
-        int i;
+      // create a function context for cross-call persistence
+      funcctx = SRF_FIRSTCALL_INIT();
 
-        // create a function context for cross-call persistence
-        funcctx = SRF_FIRSTCALL_INIT();
+      // switch to memory context appropriate for multiple function calls
+      oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-        // switch to memory context appropriate for multiple function calls
-        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-        // verify that the first 5 args are not NULL
-        for (i=0; i<5; i++)
-            if(PG_ARGISNULL(i)) {
-                elog(ERROR, "turn_restrict_shortest_path(): Argument %i may not be NULL", i+1);
-            }
-
-        if (PG_ARGISNULL(5))
-            sql = NULL;
-        else {
-            sql = pgr_text2char(PG_GETARG_TEXT_P(5));
-            if (strlen(sql) == 0)
-                sql = NULL;
+      // verify that the first 5 args are not NULL
+      for (i=0; i<5; i++)
+        if(PG_ARGISNULL(i)) {
+            elog(ERROR, "turn_restrict_shortest_path(): Argument %i may not be NULL", i+1);
         }
+      
+      if (PG_ARGISNULL(5))
+        sql = NULL;
+      else {
+        sql = text2char(PG_GETARG_TEXT_P(5));
+        if (strlen(sql) == 0)
+            sql = NULL;
+      }
 
-        PGR_DBG("Calling compute_trsp");
+	  PGR_DBG("Calling compute_trsp");
 
 
-        ret =
+      ret =
 
-            compute_trsp(pgr_text2char(PG_GETARG_TEXT_P(0)),
-                    1, // do vertex
-                    PG_GETARG_INT32(1),
-                    0.5,
-                    PG_GETARG_INT32(2),
-                    0.5,
-                    PG_GETARG_BOOL(3),
-                    PG_GETARG_BOOL(4), 
-                    sql,
-                    &path, &path_count);
+ compute_trsp(text2char(PG_GETARG_TEXT_P(0)),
+                                   1, // do vertex
+                                   PG_GETARG_INT32(1),
+                                   0.5,
+                                   PG_GETARG_INT32(2),
+                                   0.5,
+                                   PG_GETARG_BOOL(3),
+                                   PG_GETARG_BOOL(4), 
+                                   sql,
+                                   &path, &path_count);
 #ifdef DEBUG
-        double total_cost = 0;
-        PGR_DBG("Ret is %i", ret);
-        if (ret >= 0) 
+	double total_cost = 0;
+      PGR_DBG("Ret is %i", ret);
+      if (ret >= 0) 
         {
-            int i;
-            for (i = 0; i < path_count; i++) 
+          int i;
+          for (i = 0; i < path_count; i++) 
             {
-                //     PGR_DBG("Step %i vertex_id  %i ", i, path[i].vertex_id);
-                //   PGR_DBG("        edge_id    %i ", path[i].edge_id);
-                // PGR_DBG("        cost       %f ", path[i].cost);
-                total_cost+=path[i].cost;
+         //     PGR_DBG("Step %i vertex_id  %i ", i, path[i].vertex_id);
+           //   PGR_DBG("        edge_id    %i ", path[i].edge_id);
+             // PGR_DBG("        cost       %f ", path[i].cost);
+              total_cost+=path[i].cost;
             }
         }
         PGR_DBG("Total cost is: %f",total_cost);
 #endif
 
-        // total number of tuples to be returned 
-        funcctx->max_calls = (uint32_t)path_count;
-        funcctx->user_fctx = path;
+      // total number of tuples to be returned 
+      funcctx->max_calls = path_count;
+      funcctx->user_fctx = path;
 
-        funcctx->tuple_desc = 
-            BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
+      funcctx->tuple_desc = 
+        BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
 
-        MemoryContextSwitchTo(oldcontext);
+      MemoryContextSwitchTo(oldcontext);
     }
 
-    // stuff done on every call of the function 
-    funcctx = SRF_PERCALL_SETUP();
+  // stuff done on every call of the function 
+  funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
-    tuple_desc = funcctx->tuple_desc;
-    path = (path_element_t*) funcctx->user_fctx;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
+  tuple_desc = funcctx->tuple_desc;
+  path = (path_element_t*) funcctx->user_fctx;
 
-    if (call_cntr < max_calls)    // do when there is more left to send 
+  if (call_cntr < max_calls)    // do when there is more left to send 
     {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum *values;
-        bool* nulls;
-
-        values = palloc(4 * sizeof(Datum));
-        nulls = palloc(4 * sizeof(bool));
-
-        values[0] = Int32GetDatum(call_cntr);
-        nulls[0] = false;
-        values[1] = Int32GetDatum(path[call_cntr].vertex_id);
-        nulls[1] = false;
-        values[2] = Int32GetDatum(path[call_cntr].edge_id);
-        nulls[2] = false;
-        values[3] = Float8GetDatum(path[call_cntr].cost);
-        nulls[3] = false;
-
-        tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-        // make the tuple into a datum 
-        result = HeapTupleGetDatum(tuple);
-
-        // clean up (this is not really necessary) 
-        pfree(values);
-        pfree(nulls);
-
-        SRF_RETURN_NEXT(funcctx, result);
+      HeapTuple    tuple;
+      Datum        result;
+      Datum *values;
+      bool* nulls;
+
+      values = palloc(4 * sizeof(Datum));
+      nulls = palloc(4 * sizeof(bool));
+
+      values[0] = Int32GetDatum(call_cntr);
+      nulls[0] = false;
+      values[1] = Int32GetDatum(path[call_cntr].vertex_id);
+      nulls[1] = false;
+      values[2] = Int32GetDatum(path[call_cntr].edge_id);
+      nulls[2] = false;
+      values[3] = Float8GetDatum(path[call_cntr].cost);
+      nulls[3] = false;
+		      
+      tuple = heap_form_tuple(tuple_desc, values, nulls);
+
+      // make the tuple into a datum 
+      result = HeapTupleGetDatum(tuple);
+
+      // clean up (this is not really necessary) 
+      pfree(values);
+      pfree(nulls);
+
+      SRF_RETURN_NEXT(funcctx, result);
     }
-    else    // do when there is no more left 
+  else    // do when there is no more left 
     {
-        PGR_DBG("Going to free path");
-        if (path) free(path);
-        SRF_RETURN_DONE(funcctx);
+      PGR_DBG("Going to free path");
+      if (path) free(path);
+      SRF_RETURN_DONE(funcctx);
     }
 }
 
@@ -347,147 +723,147 @@ PG_FUNCTION_INFO_V1(turn_restrict_shortest_path_edge);
 PGDLLEXPORT Datum
 turn_restrict_shortest_path_edge(PG_FUNCTION_ARGS)
 {
-
-    FuncCallContext     *funcctx;
-    uint32_t                  call_cntr;
-    uint32_t                  max_calls;
-    TupleDesc            tuple_desc;
-    path_element_t      *path;
-    char *               sql;
-
-    // stuff done only on the first call of the function 
-    if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
-        size_t path_count = 0;
+	
+  FuncCallContext     *funcctx;
+  uint32_t                  call_cntr;
+  uint32_t                  max_calls;
+  TupleDesc            tuple_desc;
+  path_element_t      *path;
+  char *               sql;
+
+  // stuff done only on the first call of the function 
+  if (SRF_IS_FIRSTCALL()) {
+      MemoryContext   oldcontext;
+      uint32_t path_count = 0;
 #ifdef DEBUG
-        int ret = -1;
+      int ret = -1;
 #endif
-        int i;
-        double s_pos;
-        double e_pos;
-
-        // create a function context for cross-call persistence
-        funcctx = SRF_FIRSTCALL_INIT();
+      int i;
+      double s_pos;
+      double e_pos;
 
-        // switch to memory context appropriate for multiple function calls
-        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-        // verify that the first 5 args are not NULL
-        for (i=0; i<7; i++) {
-            if(i==2 || i==4) continue;
-            if(PG_ARGISNULL(i)) {
-                elog(ERROR, "turn_restrict_shortest_path(): Argument %i may not be NULL", i+1);
-            }
-        }
+      // create a function context for cross-call persistence
+      funcctx = SRF_FIRSTCALL_INIT();
 
-        if (PG_ARGISNULL(2))
-            s_pos = 0.5;
-        else {
-            s_pos = PG_GETARG_FLOAT8(2);
-            if (s_pos < 0.0) s_pos = 0.5;
-            if (s_pos > 1.0) s_pos = 0.5;
-        }
+      // switch to memory context appropriate for multiple function calls
+      oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-        if (PG_ARGISNULL(4))
-            e_pos = 0.5;
-        else {
-            e_pos = PG_GETARG_FLOAT8(4);
-            if (e_pos < 0.0) e_pos = 0.5;
-            if (e_pos > 1.0) e_pos = 0.5;
+      // verify that the first 5 args are not NULL
+      for (i=0; i<7; i++) {
+        if(i==2 || i==4) continue;
+        if(PG_ARGISNULL(i)) {
+            elog(ERROR, "turn_restrict_shortest_path(): Argument %i may not be NULL", i+1);
         }
-
-        if (PG_ARGISNULL(7))
+      }
+
+      if (PG_ARGISNULL(2))
+        s_pos = 0.5;
+      else {
+        s_pos = PG_GETARG_FLOAT8(2);
+        if (s_pos < 0.0) s_pos = 0.5;
+        if (s_pos > 1.0) s_pos = 0.5;
+      }
+      
+      if (PG_ARGISNULL(4))
+        e_pos = 0.5;
+      else {
+        e_pos = PG_GETARG_FLOAT8(4);
+        if (e_pos < 0.0) e_pos = 0.5;
+        if (e_pos > 1.0) e_pos = 0.5;
+      }
+      
+      if (PG_ARGISNULL(7))
+        sql = NULL;
+      else {
+        sql = text2char(PG_GETARG_TEXT_P(7));
+        if (strlen(sql) == 0)
             sql = NULL;
-        else {
-            sql = pgr_text2char(PG_GETARG_TEXT_P(7));
-            if (strlen(sql) == 0)
-                sql = NULL;
-        }
+      }
 
-        PGR_DBG("Calling compute_trsp");
+	  PGR_DBG("Calling compute_trsp");
 
 #ifdef DEBUG
-        ret =
+      ret =
 #endif
-            compute_trsp(pgr_text2char(PG_GETARG_TEXT_P(0)),
-                    0,  //sdo edge
-                    PG_GETARG_INT32(1),
-                    s_pos,
-                    PG_GETARG_INT32(3),
-                    e_pos,
-                    PG_GETARG_BOOL(5),
-                    PG_GETARG_BOOL(6), 
-                    sql,
-                    &path, &path_count);
+         compute_trsp(text2char(PG_GETARG_TEXT_P(0)),
+                                   0,  //sdo edge
+                                   PG_GETARG_INT32(1),
+                                   s_pos,
+                                   PG_GETARG_INT32(3),
+                                   e_pos,
+                                   PG_GETARG_BOOL(5),
+                                   PG_GETARG_BOOL(6), 
+                                   sql,
+                                   &path, &path_count);
 #ifdef DEBUG
-        double total_cost = 0;
-        PGR_DBG("Ret is %i", ret);
-        if (ret >= 0) 
+	double total_cost = 0;
+      PGR_DBG("Ret is %i", ret);
+      if (ret >= 0) 
         {
-            int i;
-            for (i = 0; i < path_count; i++) 
+          int i;
+          for (i = 0; i < path_count; i++) 
             {
-                //     PGR_DBG("Step %i vertex_id  %i ", i, path[i].vertex_id);
-                //   PGR_DBG("        edge_id    %i ", path[i].edge_id);
-                // PGR_DBG("        cost       %f ", path[i].cost);
-                total_cost+=path[i].cost;
+         //     PGR_DBG("Step %i vertex_id  %i ", i, path[i].vertex_id);
+           //   PGR_DBG("        edge_id    %i ", path[i].edge_id);
+             // PGR_DBG("        cost       %f ", path[i].cost);
+              total_cost+=path[i].cost;
             }
         }
         PGR_DBG("Total cost is: %f",total_cost);
 #endif
 
-        // total number of tuples to be returned 
-        funcctx->max_calls = (uint32_t)path_count;
-        funcctx->user_fctx = path;
+      // total number of tuples to be returned 
+      funcctx->max_calls = path_count;
+      funcctx->user_fctx = path;
 
-        funcctx->tuple_desc = 
-            BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
+      funcctx->tuple_desc = 
+        BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
 
-        MemoryContextSwitchTo(oldcontext);
+      MemoryContextSwitchTo(oldcontext);
     }
 
-    // stuff done on every call of the function 
-    funcctx = SRF_PERCALL_SETUP();
+  // stuff done on every call of the function 
+  funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
-    tuple_desc = funcctx->tuple_desc;
-    path = (path_element_t*) funcctx->user_fctx;
+  call_cntr = (uint32_t)funcctx->call_cntr;
+  max_calls = (uint32_t)funcctx->max_calls;
+  tuple_desc = funcctx->tuple_desc;
+  path = (path_element_t*) funcctx->user_fctx;
 
-    if (call_cntr < max_calls)    // do when there is more left to send 
+  if (call_cntr < max_calls)    // do when there is more left to send 
     {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum *values;
-        bool* nulls;
-
-        values = palloc(4 * sizeof(Datum));
-        nulls = palloc(4 * sizeof(bool));
-
-        values[0] = Int32GetDatum(call_cntr);
-        nulls[0] = false;
-        values[1] = Int32GetDatum(path[call_cntr].vertex_id);
-        nulls[1] = false;
-        values[2] = Int32GetDatum(path[call_cntr].edge_id);
-        nulls[2] = false;
-        values[3] = Float8GetDatum(path[call_cntr].cost);
-        nulls[3] = false;
-
-        tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-        // make the tuple into a datum 
-        result = HeapTupleGetDatum(tuple);
-
-        // clean up (this is not really necessary) 
-        pfree(values);
-        pfree(nulls);
-
-        SRF_RETURN_NEXT(funcctx, result);
+      HeapTuple    tuple;
+      Datum        result;
+      Datum *values;
+      bool* nulls;
+
+      values = palloc(4 * sizeof(Datum));
+      nulls = palloc(4 * sizeof(bool));
+
+      values[0] = Int32GetDatum(call_cntr);
+      nulls[0] = false;
+      values[1] = Int32GetDatum(path[call_cntr].vertex_id);
+      nulls[1] = false;
+      values[2] = Int32GetDatum(path[call_cntr].edge_id);
+      nulls[2] = false;
+      values[3] = Float8GetDatum(path[call_cntr].cost);
+      nulls[3] = false;
+		      
+      tuple = heap_form_tuple(tuple_desc, values, nulls);
+
+      // make the tuple into a datum 
+      result = HeapTupleGetDatum(tuple);
+
+      // clean up (this is not really necessary) 
+      pfree(values);
+      pfree(nulls);
+
+      SRF_RETURN_NEXT(funcctx, result);
     }
-    else    // do when there is no more left 
+  else    // do when there is no more left 
     {
-        PGR_DBG("Going to free path");
-        if (path) free(path);
-        SRF_RETURN_DONE(funcctx);
+      PGR_DBG("Going to free path");
+      if (path) free(path);
+      SRF_RETURN_DONE(funcctx);
     }
 }
diff --git a/src/trsp/src/trsp.h b/src/trsp/src/trsp.h
new file mode 100644
index 0000000..fa427ed
--- /dev/null
+++ b/src/trsp/src/trsp.h
@@ -0,0 +1,91 @@
+/*
+ * Shortest path with turn restrictions algorithm for PostgreSQL
+ *
+ * Copyright (c) 2011 Stephen Woodbridge
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+ 
+#ifndef _TRSP_H
+#define _TRSP_H
+
+#define MAX_RULE_LENGTH 5
+
+#include <stdint.h>
+
+typedef struct edge
+{
+    long id;
+    long source;
+    long target;
+    double cost;
+    double reverse_cost;
+} edge_t;
+
+typedef struct restrict_struct
+{
+		int target_id;
+		double to_cost;
+        int via[MAX_RULE_LENGTH];
+} 
+restrict_t;
+
+typedef struct path_element 
+{
+    long vertex_id;
+    long edge_id;
+    double cost;
+} path_element_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int trsp_node_wrapper(
+			edge_t *edges, 
+			uint32_t edge_count, 
+			restrict_t *restricts, 
+			uint32_t restrict_count,
+			long start_vertex, 
+			long end_vertex,
+		    bool directed, 
+		    bool has_reverse_cost,
+            path_element_t **path, 
+            uint32_t *path_count, 
+            char **err_msg
+            );
+
+int trsp_edge_wrapper(
+			edge_t *edges, 
+			uint32_t edge_count, 
+			restrict_t *restricts, 
+			uint32_t restrict_count,
+			long start_edge, 
+            double start_pos,
+			long end_edge,
+            double end_pos,
+		    bool directed, 
+		    bool has_reverse_cost,
+            path_element_t **path, 
+            uint32_t *path_count, 
+            char **err_msg
+            );
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/src/trsp/src/trsp_core.cpp b/src/trsp/src/trsp_core.cpp
new file mode 100644
index 0000000..e237399
--- /dev/null
+++ b/src/trsp/src/trsp_core.cpp
@@ -0,0 +1,137 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 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.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include "GraphDefinition.h"
+#include "utils.h"
+
+
+int trsp_node_wrapper(
+    edge_t *edges,
+    uint32_t edge_count,
+    restrict_t *restricts,
+    uint32_t restrict_count,
+    long start_vertex,
+    long end_vertex,
+    bool directed,
+    bool has_reverse_cost,
+    path_element_t **path,
+    uint32_t *path_count,
+    char **err_msg
+    )
+{
+    try {
+
+        std::vector<PDVI> ruleTable;
+
+        int j;
+        ruleTable.clear();
+        for (size_t i=0; i<restrict_count; i++) {
+            std::vector<int> seq;
+            seq.clear();
+            seq.push_back(restricts[i].target_id);
+            for(j = 0; j<MAX_RULE_LENGTH && restricts[i].via[j]>-1; j++)
+            {
+                seq.push_back(restricts[i].via[j]);
+            }
+            ruleTable.push_back(make_pair(restricts[i].to_cost, seq));
+        }
+
+        size_t count;
+        GraphDefinition gdef;
+        int res = gdef.my_dijkstra3(edges, edge_count, start_vertex, end_vertex, directed, has_reverse_cost, path, &count, err_msg, ruleTable);
+        *path_count = static_cast<uint32_t> (count);
+
+
+        if (res < 0)
+            return res;
+        else
+            return EXIT_SUCCESS;
+    }
+    catch(std::exception& e) {
+        *err_msg = (char *) e.what();
+        return -1;
+    }
+    catch(...) {
+        *err_msg = (char *) "Caught unknown exception!";
+        return -1;
+    }
+}
+
+int trsp_edge_wrapper(
+    edge_t *edges,
+    uint32_t edge_count,
+    restrict_t *restricts,
+    uint32_t restrict_count,
+    long start_edge,
+    double start_pos,
+    long end_edge,
+    double end_pos,
+    bool directed,
+    bool has_reverse_cost,
+    path_element_t **path,
+    uint32_t *path_count,
+    char **err_msg
+    )
+{
+    try {
+
+        std::vector<PDVI> ruleTable;
+
+        int j;
+        ruleTable.clear();
+        for (size_t i=0; i<restrict_count; i++) {
+            std::vector<int> seq;
+            seq.clear();
+            seq.push_back(restricts[i].target_id);
+            for(j = 0; j<MAX_RULE_LENGTH && restricts[i].via[j]>-1; j++)
+            {
+                seq.push_back(restricts[i].via[j]);
+            }
+            ruleTable.push_back(make_pair(restricts[i].to_cost, seq));
+        }
+
+        GraphDefinition gdef;
+        size_t count;
+        int res = gdef.my_dijkstra4(edges, edge_count, start_edge, start_pos, end_edge, end_pos, directed, has_reverse_cost, path, &count, err_msg, ruleTable);
+        *path_count = static_cast<uint32_t>(count);
+
+
+        if (res < 0)
+            return res;
+        else
+            return EXIT_SUCCESS;
+    }
+    catch(std::exception& e) {
+        *err_msg = (char *) e.what();
+        return -1;
+    }
+    catch(...) {
+        *err_msg = (char *) "Caught unknown exception!";
+        return -1;
+    }
+}
diff --git a/src/trsp/src/utils.h b/src/trsp/src/utils.h
new file mode 100644
index 0000000..2feb047
--- /dev/null
+++ b/src/trsp/src/utils.h
@@ -0,0 +1,106 @@
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <string>
+#include <map>
+#include <vector>
+#include <queue>
+#include <iostream>
+
+
+
+
+typedef std::vector<long> LongVector;
+typedef std::vector<int> IntVector;
+typedef std::vector<double> DoubleVector;
+typedef std::vector<std::string> StringVector;
+
+
+class StringOperation
+{
+	
+public:
+	
+	static std::string TRIMWHITESPACE(std::string strInput)
+	{
+		std::string strOut = strInput;
+		std::string strWht = " \f\n\r\t\v";	
+
+		strOut.erase(0,strOut.find_first_not_of(strWht));
+		strOut.erase(strOut.find_last_not_of(strWht) + 1);
+		return strOut;
+	};
+};
+
+class StringTokenizer
+{
+public:
+	StringTokenizer()
+	{
+		reset();
+	}
+
+	void reset()
+	{
+		vecTokens.clear();
+		strInput = "";
+	}
+
+	bool parse(std::string strInput, std::string chDelim)
+	{
+		size_t iStartPos = 0;
+		while(true)	
+		{
+			size_t iPos = strInput.find(chDelim[0],iStartPos);
+			if(iPos != std::string::npos)
+			{
+				std::string strToken;
+				strToken = strInput.substr(iStartPos,iPos - iStartPos);
+				vecTokens.push_back(strToken);
+				iStartPos = iPos + 1;
+			}
+			else if(iPos == std::string::npos && strInput.length() > 0 )
+			{
+				std::string strToken;
+				strToken = strInput.substr(iStartPos, strInput.length() - iStartPos);
+				if(strToken.length() > 0)
+					vecTokens.push_back(strToken);
+				break;
+			}		
+			else 
+				break;
+
+		}		
+		return true;
+	}
+
+	size_t getTokenCount() 
+	{
+		return vecTokens.size();
+	}
+
+	bool getToken(std::string& strToken, size_t iTokenIndex)
+	{
+		auto lTokenCount = vecTokens.size();
+		if(iTokenIndex < lTokenCount)
+		{
+			strToken = vecTokens[iTokenIndex];
+			return true;
+		}
+		return false;
+	}
+
+	bool getTokens(StringVector& vecTokensRef)
+	{
+		vecTokensRef = vecTokens;
+		return true;
+	}
+
+private:
+	std::string strInput;
+	StringVector vecTokens;
+	
+};
+
+#endif
diff --git a/src/trsp/test/doc-trsp.test.sql b/src/trsp/test/doc-trsp.test.sql
index 6d50122..68091c8 100644
--- a/src/trsp/test/doc-trsp.test.sql
+++ b/src/trsp/test/doc-trsp.test.sql
@@ -19,14 +19,14 @@ BEGIN;
     SELECT * FROM pgr_trsp(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
         2, 7, false, false,
-        'SELECT to_cost, target_id,
+        'SELECT to_cost, target_id::int4,
         from_edge || coalesce('','' || via_path, '''') AS via_path
         FROM restrictions'
     );
     SELECT * FROM pgr_trsp(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
         7, 11, false, false,
-        'SELECT to_cost, target_id,
+        'SELECT to_cost, target_id::int4,
         from_edge || coalesce('','' || via_path, '''') AS via_path
         FROM restrictions'
     );
@@ -35,9 +35,9 @@ BEGIN;
 \echo --q4
     SELECT * FROM pgr_trspViaVertices(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
-        ARRAY[2,7,11]::INTEGER[],     
-        false,  false,  
-        'SELECT to_cost, target_id, from_edge ||
+        ARRAY[2,7,11]::INTEGER[],
+        false,  false,
+        'SELECT to_cost, target_id::int4, from_edge ||
         coalesce('',''||via_path,'''') AS via_path FROM restrictions');
 
 
@@ -45,11 +45,11 @@ BEGIN;
     SELECT * FROM pgr_trspViaEdges(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost,
         reverse_cost FROM edge_table',
-        ARRAY[2,7,11]::INTEGER[],           
-        ARRAY[0.5, 0.5, 0.5]::FLOAT[],     
-        true,  
-        true,  
-        'SELECT to_cost, target_id, FROM_edge ||
+        ARRAY[2,7,11]::INTEGER[],
+        ARRAY[0.5, 0.5, 0.5]::FLOAT[],
+        true,
+        true,
+        'SELECT to_cost, target_id::int4, FROM_edge ||
         coalesce('',''||via_path,'''') AS via_path FROM restrictions');
     
 \echo --q6
diff --git a/src/trsp/test/issue693.result b/src/trsp/test/issue693.result
new file mode 100644
index 0000000..55260cd
--- /dev/null
+++ b/src/trsp/test/issue693.result
@@ -0,0 +1,5 @@
+(0,-1,1,1000)
+(1,1,2,5)
+(2,3,3,10)
+(3,4,4,10)
+(4,2,1,1000)
diff --git a/src/trsp/test/issue693.test.sql b/src/trsp/test/issue693.test.sql
new file mode 100644
index 0000000..0f179c5
--- /dev/null
+++ b/src/trsp/test/issue693.test.sql
@@ -0,0 +1,16 @@
+
+BEGIN;
+
+    CREATE TABLE routing (gid serial, length integer, source integer, target integer, reverse_cost integer);
+    INSERT INTO routing (length, source, target, reverse_cost) VALUES
+     (10000, 1, 2, 10000),
+     (5, 3, 1, 5),
+     (10, 4, 3, 10),
+     (10, 2, 4, 10);
+
+    SELECT pgr_trsp(
+          'SELECT gid as id, source::int4, target::int4, length::float8 as cost, length::float8 as reverse_cost FROM routing', 
+          1, 0.1, 1, 0.9, false, true
+    );
+
+    ROLLBACK;
diff --git a/src/trsp/test/pgtap/from1to3.test.sql b/src/trsp/test/pgtap/from1to3.test.sql
index adeae94..9082a1e 100644
--- a/src/trsp/test/pgtap/from1to3.test.sql
+++ b/src/trsp/test/pgtap/from1to3.test.sql
@@ -89,7 +89,10 @@ FROM pgr_dijkstraVia(
 
 SELECT is_empty('q41', '5: Undirected: No path from 1 to 1');
 SELECT set_eq('q51','q52','6: Undirected: without retrictions returns the same as pgr_dijkstra');
+
+SELECT todo_start();
 SELECT set_eq('q61','q62','7: Undirected: with retrictions returns expected path');
+SELECT todo_end();
 
 -- Finish the tests and clean up.
 SELECT * FROM finish();
diff --git a/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-directed.test.sql b/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-directed.test.sql
index 77712d0..f9c8159 100644
--- a/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-directed.test.sql
+++ b/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-directed.test.sql
@@ -2,7 +2,7 @@
 
 \i setup.sql
 
-SELECT plan(1224);
+SELECT plan(612);
 
 UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
 
@@ -24,7 +24,7 @@ BEGIN
         k := 1;
         inner_sql1 = quote_literal('SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost from edge_table ORDER BY id');
         inner_sql2 = quote_literal('SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost from edge_table ORDER BY id');
-        FOR i IN 1.. cant LOOP
+        FOR i IN 1.. cant BY 2 LOOP
             FOR j IN 1..cant LOOP
 
                 -- this special case is tested on the other test
diff --git a/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-undirected.test.sql b/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-undirected.test.sql
index fd634bc..c23f464 100644
--- a/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-undirected.test.sql
+++ b/src/trsp/test/pgtap/no-restrictions-compare-dijkstra-undirected.test.sql
@@ -1,7 +1,7 @@
 
 \i setup.sql
 
-    SELECT plan(1224);
+    SELECT plan(612);
 
     UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
 
@@ -24,7 +24,7 @@
         inner_sql1 = quote_literal('SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table ORDER BY id');
         inner_sql2 = quote_literal('SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table ORDER BY id');
         FOR i IN 1.. cant LOOP
-            FOR j IN 1..cant LOOP
+            FOR j IN 1..cant BY 2 LOOP
 
                 -- this special case is tested on the other test
                 CONTINUE WHEN i = j;
diff --git a/src/trsp/test/test.conf b/src/trsp/test/test.conf
index 10b9eaf..21a0829 100644
--- a/src/trsp/test/test.conf
+++ b/src/trsp/test/test.conf
@@ -8,6 +8,7 @@
             doc-trsp
             trsp-any-02 
             trsp_vias-any-04 
+            issue693
             )],
         'documentation' => [qw(
             doc-trsp
diff --git a/src/trsp/test/trsp-any-02.test.sql b/src/trsp/test/trsp-any-02.test.sql
index 405237e..2e611f5 100644
--- a/src/trsp/test/trsp-any-02.test.sql
+++ b/src/trsp/test/trsp-any-02.test.sql
@@ -17,7 +17,7 @@ COPY restrictions2 (rid, to_cost, teid, feid, via) FROM stdin WITH NULL '__NULL_
 UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
 
 select * from pgr_trsp(
-    'select id, source::integer, target::integer,cost, reverse_cost from edge_table ORDER BY ID',
+    'select id::integer, source::integer, target::integer,cost, reverse_cost from edge_table ORDER BY ID',
     1,    -- edge_id for start
     0.5,  -- midpoint of edge
     6,    -- edge_id of route end
diff --git a/src/trsp/test/trsp_vias-any-04.test.sql b/src/trsp/test/trsp_vias-any-04.test.sql
index e151a3e..bbe198c 100644
--- a/src/trsp/test/trsp_vias-any-04.test.sql
+++ b/src/trsp/test/trsp_vias-any-04.test.sql
@@ -30,7 +30,7 @@ BEGIN;
         true,  -- directed graph?
         true,  -- has_reverse_cost?
         -- include the turn restrictions
-        'SELECT to_cost, target_id, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
+        'SELECT to_cost, target_id::INTEGER, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
 
     \echo '---------------------------'
     SELECT * FROM pgr_trspViaEdges(
@@ -40,7 +40,7 @@ BEGIN;
         true,  -- directed graph?
         true,  -- has_reverse_cost?
         -- include the turn restrictions
-        'SELECT to_cost, target_id, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
+        'SELECT to_cost, target_id::INTEGER, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
     \echo '---------------------------'
     SELECT * FROM pgr_trspViaEdges(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER,cost, reverse_cost FROM edge_table',
@@ -49,7 +49,7 @@ BEGIN;
         true,  -- directed graph?
         true,  -- has_reverse_cost?
         -- include the turn restrictions
-        'SELECT to_cost, target_id, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
+        'SELECT to_cost, target_id::INTEGER, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
     \echo '---------------------------'
     SELECT * FROM pgr_trspViaEdges(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER,cost, reverse_cost FROM edge_table',
@@ -58,6 +58,6 @@ BEGIN;
         true,  -- directed graph?
         true,  -- has_reverse_cost?
         -- include the turn restrictions
-        'SELECT to_cost, target_id, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
+        'SELECT to_cost, target_id::INTEGER, from_edge||coalesce('',''||via_path,'''') AS via_path FROM restrictions');
     \echo '---------------------------'
     ROLLBACK;
diff --git a/src/tsp/src/eucledianTSP.c b/src/tsp/src/eucledianTSP.c
index 434f49f..cadff5b 100644
--- a/src/tsp/src/eucledianTSP.c
+++ b/src/tsp/src/eucledianTSP.c
@@ -230,8 +230,8 @@ eucledianTSP(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/tsp/src/newTSP.c b/src/tsp/src/newTSP.c
index 072b501..08913c3 100644
--- a/src/tsp/src/newTSP.c
+++ b/src/tsp/src/newTSP.c
@@ -231,8 +231,8 @@ newTSP(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/tsp/src/tsp2.c b/src/tsp/src/tsp2.c
index 188f99d..9c297b0 100644
--- a/src/tsp/src/tsp2.c
+++ b/src/tsp/src/tsp2.c
@@ -292,8 +292,8 @@ tsp_matrix(PG_FUNCTION_ARGS) {
     /* stuff done on every call of the function */
     funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr  = funcctx->call_cntr;
-    max_calls  = funcctx->max_calls;
+    call_cntr  = (uint32_t)funcctx->call_cntr;
+    max_calls  = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     tsp_res    = funcctx->user_fctx;
 
diff --git a/src/tsp/src/tsplib.c b/src/tsp/src/tsplib.c
index bb9b523..3b9c8d3 100644
--- a/src/tsp/src/tsplib.c
+++ b/src/tsp/src/tsplib.c
@@ -290,11 +290,11 @@ DTYPE pathLength(TSP *tsp) {
     unsigned int i;
     DTYPE len = 0;
 
-    int *iorder = tsp->iorder;
+    int* iorder = tsp->iorder;
     DTYPE *dist   = tsp->dist;
     int  n = tsp->n;
 
-    for (i = 0; i < n-1; i++) {
+    for (i = 0; (int)i < (int)(n-1); i++) {
         len += D(iorder[i], iorder[i+1]);
     }
     len += D(iorder[n-1], iorder[0]); /* close path */
diff --git a/src/vrp_basic/src/VRP.c b/src/vrp_basic/src/VRP.c
index 1e9f4fb..c8afe78 100644
--- a/src/vrp_basic/src/VRP.c
+++ b/src/vrp_basic/src/VRP.c
@@ -798,8 +798,8 @@ vrp(PG_FUNCTION_ARGS) {
     /* stuff done on every call of the function */
     funcctx = SRF_PERCALL_SETUP();
 
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
 
     path = (vrp_result_element_t *)funcctx->user_fctx;
diff --git a/src/withPoints/src/many_to_many_withPoints.c b/src/withPoints/src/many_to_many_withPoints.c
index 22607f5..94886d1 100644
--- a/src/withPoints/src/many_to_many_withPoints.c
+++ b/src/withPoints/src/many_to_many_withPoints.c
@@ -216,8 +216,8 @@ many_to_many_withPoints(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/withPoints/src/many_to_one_withPoints.c b/src/withPoints/src/many_to_one_withPoints.c
index dab7dd0..6971526 100644
--- a/src/withPoints/src/many_to_one_withPoints.c
+++ b/src/withPoints/src/many_to_one_withPoints.c
@@ -206,8 +206,8 @@ many_to_one_withPoints(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/withPoints/src/one_to_many_withPoints.c b/src/withPoints/src/one_to_many_withPoints.c
index 3f5d82b..32ed61e 100644
--- a/src/withPoints/src/one_to_many_withPoints.c
+++ b/src/withPoints/src/one_to_many_withPoints.c
@@ -261,8 +261,8 @@ one_to_many_withPoints(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/src/withPoints/src/one_to_one_withPoints.c b/src/withPoints/src/one_to_one_withPoints.c
index 84d05d0..d80836a 100644
--- a/src/withPoints/src/one_to_one_withPoints.c
+++ b/src/withPoints/src/one_to_one_withPoints.c
@@ -246,8 +246,8 @@ one_to_one_withPoints(PG_FUNCTION_ARGS) {
     }
 
     funcctx = SRF_PERCALL_SETUP();
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
+    call_cntr = (uint32_t)funcctx->call_cntr;
+    max_calls = (uint32_t)funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
     result_tuples = (General_path_element_t*) funcctx->user_fctx;
 
diff --git a/tools/curr-sig/pgrouting--2.3.1.sig b/tools/curr-sig/pgrouting--2.3.1.sig
new file mode 100644
index 0000000..bf44758
--- /dev/null
+++ b/tools/curr-sig/pgrouting--2.3.1.sig
@@ -0,0 +1,141 @@
+#VERSION pgrouting 2.3.1
+#TYPES
+contraction_vertex(int,int,char,text)
+pgr_costResult(integer,integer,integer,float8)
+pgr_costResult3(integer,integer,integer,integer,float8)
+pgr_geomResult(integer,integer,integer,geometry)
+#FUNCTIONS
+_pgr_astar(text,bigint,bigint,boolean ,integer ,float ,float ,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_checkverttab(text,text[],in int ,in text ,out text,out text)
+_pgr_createindex(text,text,text,text,in int ,in text )
+_pgr_createindex(text,text,text,in int ,in text )
+_pgr_dijkstra(text,bigint,bigint,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,bigint,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,bigint,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,bigint,float8,boolean,out integer,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,anyarray,float8,boolean,boolean,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_endpoint(geometry)
+_pgr_getcolumnname(text,text,text,in int ,in text )
+_pgr_getcolumnname(text,text,in int ,in text )
+_pgr_getcolumntype(text,text,text,in int ,in text )
+_pgr_getcolumntype(text,text,in int ,in text )
+_pgr_gettablename(in text,in int ,in text ,out text,out text)
+_pgr_get_statement(text)
+_pgr_iscolumnintable(text,text)
+_pgr_iscolumnindexed(text,text,text,in int ,in text )
+_pgr_iscolumnindexed(text,text,in int ,in text )
+_pgr_ksp(text,bigint,bigint,integer,boolean,boolean,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_makedistancematrix(text,out double precision[],out integer[])
+_pgr_maxflow(text,bigint,bigint,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,bigint,anyarray,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,anyarray,bigint,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,anyarray,anyarray,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_msg(in int,in text,in text )
+_pgr_onerror(in boolean,in int,in text,in text,in text ,in text )
+_pgr_parameter_check(text,text,boolean )
+_pgr_pickdeliver(text,integer,float,float ,integer ,out integer,out integer,out integer,out bigint,out float,out float,out float,out float,out float )
+_pgr_pointtoid(geometry,double precision,text,integer)
+_pgr_quote_ident(text)
+_pgr_startpoint(geometry)
+_pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text )
+_pgr_trsp(text,integer,integer,boolean,boolean,text )
+_pgr_trspviavertices(text,integer[],boolean,boolean,text )
+_pgr_versionless(text,text)
+_pgr_withpoints(text,text,bigint,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,bigint,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpointsvia(text,bigint[],float[],boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_tsp(text,bigint ,bigint ,float ,integer ,integer ,integer ,float ,float ,float ,boolean ,out integer,out bigint,out float,out float)
+pgr_alphashape(text,float8 ,out float8,out float8)
+pgr_analyzeoneway(text,text[],text[],text[],text[],boolean ,text ,text ,text )
+pgr_analyzegraph(text,double precision,text ,text ,text ,text ,text )
+pgr_apspjohnson(text)
+pgr_apspwarshall(text,boolean,boolean)
+pgr_astar(text,bigint,bigint,boolean ,integer ,float ,float ,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_astar(text,integer,integer,boolean,boolean)
+pgr_bdastar(text,integer,integer,boolean,boolean)
+pgr_bddijkstra(text,integer,integer,boolean,boolean)
+pgr_contractgraph(text,bigint[],integer ,bigint[] ,boolean ,out integer,out text,out bigint,out bigint[],out bigint,out bigint,out float)
+pgr_createtopology(text,double precision,text ,text ,text ,text ,text ,boolean )
+pgr_createverticestable(text,text ,text ,text ,text )
+pgr_dijkstra(text,bigint,bigint,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,bigint,boolean,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,integer,integer,boolean,boolean)
+pgr_dijkstra(text,anyarray,bigint,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,anyarray,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstracost(text,bigint,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,bigint,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracostmatrix(text,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstravia(text,anyarray,boolean ,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_drivingdistance(text,bigint,float8,boolean,boolean)
+pgr_drivingdistance(text,bigint,float8,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_drivingdistance(text,anyarray,float8,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_edgedisjointpaths(in text,in bigint,in bigint,in boolean ,out integer,out integer,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in bigint,in anyarray,in boolean ,out integer,out integer,out bigint,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in anyarray,in bigint,in boolean ,out integer,out integer,out bigint,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in anyarray,in anyarray,in boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint )
+pgr_endpoint(geometry)
+pgr_euclediantsp(text,bigint ,bigint ,float ,integer ,integer ,integer ,float ,float ,float ,boolean ,out integer,out bigint,out float,out float)
+pgr_fakecontraction(text,integer[])
+pgr_flipedges(geometry[])
+pgr_floydwarshall(text,boolean ,out bigint,out bigint,out float)
+pgr_getcolumnname(text,text)
+pgr_gettablename(in text,out text,out text)
+pgr_gsoc_vrppdtw(text,integer,integer )
+pgr_iscolumnintable(text,text)
+pgr_iscolumnindexed(text,text)
+pgr_johnson(text,boolean ,out bigint,out bigint,out float)
+pgr_kdijkstrapath(text,integer,integer array,boolean,boolean)
+pgr_kdijkstracost(text,integer,integer array,boolean,boolean)
+pgr_ksp(text,bigint,bigint,integer,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_ksp(text,integer,integer,integer,boolean)
+pgr_labelgraph(text,text ,text ,text ,text ,text )
+pgr_maxflowboykovkolmogorov(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maximumcardinalitymatching(text,boolean ,out integer,out bigint,out bigint,out bigint )
+pgr_nodenetwork(text,double precision,text ,text ,text ,text ,boolean )
+pgr_pointsaspolygon(varchar,float8 )
+pgr_pointstodmatrix(geometry[],integer )
+pgr_pointstovids(geometry[],text,float8 )
+pgr_pointtoedgenode(text,geometry,float8)
+pgr_quote_ident(text)
+pgr_startpoint(geometry)
+pgr_texttopoints(text,integer )
+pgr_trsp(text,integer,integer,boolean,boolean,text )
+pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text )
+pgr_trspviaedges(text,integer[],float8[],boolean,boolean,text )
+pgr_trspviavertices(text,anyarray,boolean,boolean,text )
+pgr_tsp(float8[][],integer,integer ,out integer,out integer)
+pgr_tsp(text,integer,integer )
+pgr_version()
+pgr_versionless(text,text)
+pgr_vidstodmatrix(text,integer[],boolean,boolean,boolean)
+pgr_vidstodmatrix(in integer[],in geometry[],in text,float8 )
+pgr_vrponedepot(text,text,text,integer,out integer,out integer,out integer,out integer,out integer)
+pgr_withpoints(text,text,bigint,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,bigint,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointscost(text,text,bigint,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,bigint,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscostmatrix(text,text,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointsdd(text,text,anyarray,float,boolean ,char ,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointsdd(text,text,bigint,float,boolean ,char ,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_withpointsksp(text,text,bigint,bigint,integer,boolean ,boolean ,char ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
diff --git a/tools/sigs/pgrouting--2.3.0.sig b/tools/sigs/pgrouting--2.3.0.sig
new file mode 100644
index 0000000..d22bfe3
--- /dev/null
+++ b/tools/sigs/pgrouting--2.3.0.sig
@@ -0,0 +1,140 @@
+#VERSION pgrouting 2.3.0
+#TYPES
+contraction_vertex(int,int,char,text)
+pgr_costResult(integer,integer,integer,float8)
+pgr_costResult3(integer,integer,integer,integer,float8)
+pgr_geomResult(integer,integer,integer,geometry)
+#FUNCTIONS
+_pgr_astar(text,bigint,bigint,boolean ,integer ,float ,float ,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_checkverttab(text,text[],in int ,in text ,out text,out text)
+_pgr_createindex(text,text,text,text,in int ,in text )
+_pgr_createindex(text,text,text,in int ,in text )
+_pgr_dijkstra(text,bigint,bigint,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,bigint,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,bigint,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,bigint,float8,boolean,out integer,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,anyarray,float8,boolean,boolean,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_endpoint(geometry)
+_pgr_getcolumnname(text,text,text,in int ,in text )
+_pgr_getcolumnname(text,text,in int ,in text )
+_pgr_getcolumntype(text,text,text,in int ,in text )
+_pgr_getcolumntype(text,text,in int ,in text )
+_pgr_gettablename(in text,in int ,in text ,out text,out text)
+_pgr_get_statement(text)
+_pgr_iscolumnintable(text,text)
+_pgr_iscolumnindexed(text,text,text,in int ,in text )
+_pgr_iscolumnindexed(text,text,in int ,in text )
+_pgr_ksp(text,bigint,bigint,integer,boolean,boolean,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_makedistancematrix(text,out double precision[],out integer[])
+_pgr_maxflow(text,bigint,bigint,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,bigint,anyarray,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,anyarray,bigint,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_maxflow(text,anyarray,anyarray,text ,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+_pgr_msg(in int,in text,in text )
+_pgr_onerror(in boolean,in int,in text,in text,in text ,in text )
+_pgr_parameter_check(text,text,boolean )
+_pgr_pickdeliver(text,integer,float,float ,integer ,out integer,out integer,out integer,out bigint,out float,out float,out float,out float,out float )
+_pgr_pointtoid(geometry,double precision,text,integer)
+_pgr_quote_ident(text)
+_pgr_startpoint(geometry)
+_pgr_trsp(text,integer,integer,boolean,boolean,text )
+_pgr_trspviavertices(text,integer[],boolean,boolean,text )
+_pgr_versionless(text,text)
+_pgr_withpoints(text,text,bigint,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,bigint,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpointsvia(text,bigint[],float[],boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_tsp(text,bigint ,bigint ,float ,integer ,integer ,integer ,float ,float ,float ,boolean ,out integer,out bigint,out float,out float)
+pgr_alphashape(text,float8 ,out float8,out float8)
+pgr_analyzeoneway(text,text[],text[],text[],text[],boolean ,text ,text ,text )
+pgr_analyzegraph(text,double precision,text ,text ,text ,text ,text )
+pgr_apspjohnson(text)
+pgr_apspwarshall(text,boolean,boolean)
+pgr_astar(text,bigint,bigint,boolean ,integer ,float ,float ,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_astar(text,integer,integer,boolean,boolean)
+pgr_bdastar(text,integer,integer,boolean,boolean)
+pgr_bddijkstra(text,integer,integer,boolean,boolean)
+pgr_contractgraph(text,bigint[],integer ,bigint[] ,boolean ,out integer,out text,out bigint,out bigint[],out bigint,out bigint,out float)
+pgr_createtopology(text,double precision,text ,text ,text ,text ,text ,boolean )
+pgr_createverticestable(text,text ,text ,text ,text )
+pgr_dijkstra(text,bigint,bigint,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,bigint,boolean,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,integer,integer,boolean,boolean)
+pgr_dijkstra(text,anyarray,bigint,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,anyarray,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstracost(text,bigint,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,bigint,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracostmatrix(text,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstravia(text,anyarray,boolean ,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_drivingdistance(text,bigint,float8,boolean,boolean)
+pgr_drivingdistance(text,bigint,float8,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_drivingdistance(text,anyarray,float8,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_edgedisjointpaths(in text,in bigint,in bigint,in boolean ,out integer,out integer,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in bigint,in anyarray,in boolean ,out integer,out integer,out bigint,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in anyarray,in bigint,in boolean ,out integer,out integer,out bigint,out bigint,out bigint )
+pgr_edgedisjointpaths(in text,in anyarray,in anyarray,in boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint )
+pgr_endpoint(geometry)
+pgr_euclediantsp(text,bigint ,bigint ,float ,integer ,integer ,integer ,float ,float ,float ,boolean ,out integer,out bigint,out float,out float)
+pgr_fakecontraction(text,integer[])
+pgr_flipedges(geometry[])
+pgr_floydwarshall(text,boolean ,out bigint,out bigint,out float)
+pgr_getcolumnname(text,text)
+pgr_gettablename(in text,out text,out text)
+pgr_gsoc_vrppdtw(text,integer,integer )
+pgr_iscolumnintable(text,text)
+pgr_iscolumnindexed(text,text)
+pgr_johnson(text,boolean ,out bigint,out bigint,out float)
+pgr_kdijkstrapath(text,integer,integer array,boolean,boolean)
+pgr_kdijkstracost(text,integer,integer array,boolean,boolean)
+pgr_ksp(text,bigint,bigint,integer,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_ksp(text,integer,integer,integer,boolean)
+pgr_labelgraph(text,text ,text ,text ,text ,text )
+pgr_maxflowboykovkolmogorov(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowboykovkolmogorov(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowedmondskarp(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,bigint,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,bigint,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,anyarray,bigint,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maxflowpushrelabel(text,anyarray,anyarray,out integer,out bigint,out bigint,out bigint,out bigint,out bigint )
+pgr_maximumcardinalitymatching(text,boolean ,out integer,out bigint,out bigint,out bigint )
+pgr_nodenetwork(text,double precision,text ,text ,text ,text ,boolean )
+pgr_pointsaspolygon(varchar,float8 )
+pgr_pointstodmatrix(geometry[],integer )
+pgr_pointstovids(geometry[],text,float8 )
+pgr_pointtoedgenode(text,geometry,float8)
+pgr_quote_ident(text)
+pgr_startpoint(geometry)
+pgr_texttopoints(text,integer )
+pgr_trsp(text,integer,integer,boolean,boolean,text )
+pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text )
+pgr_trspviaedges(text,integer[],float8[],boolean,boolean,text )
+pgr_trspviavertices(text,anyarray,boolean,boolean,text )
+pgr_tsp(float8[][],integer,integer ,out integer,out integer)
+pgr_tsp(text,integer,integer )
+pgr_version()
+pgr_versionless(text,text)
+pgr_vidstodmatrix(text,integer[],boolean,boolean,boolean)
+pgr_vidstodmatrix(in integer[],in geometry[],in text,float8 )
+pgr_vrponedepot(text,text,text,integer,out integer,out integer,out integer,out integer,out integer)
+pgr_withpoints(text,text,bigint,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,bigint,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointscost(text,text,bigint,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,bigint,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscostmatrix(text,text,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointsdd(text,text,anyarray,float,boolean ,char ,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointsdd(text,text,bigint,float,boolean ,char ,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_withpointsksp(text,text,bigint,bigint,integer,boolean ,boolean ,char ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
diff --git a/tools/testers/pg_prove_tests.sh b/tools/testers/pg_prove_tests.sh
index 69b0ad1..e2c79c6 100755
--- a/tools/testers/pg_prove_tests.sh
+++ b/tools/testers/pg_prove_tests.sh
@@ -35,7 +35,7 @@ run_psql -f setup_db.sql
 #TODO comment out peformance test before merging to MASTER
 
 
-if [ $RELEASE_TYPE = "bDEBUG" ]
+if [ $RELEASE_TYPE = "bDebug" ]
 then
     pg_prove ../../src/internalQueryTests/test/pgtap/* -d $PGDATABASE  -U $PGUSER
     echo "MADE TEST **********************"
diff --git a/tools/testers/update-tester.sh b/tools/testers/update-tester.sh
index a2583a8..8f6317f 100755
--- a/tools/testers/update-tester.sh
+++ b/tools/testers/update-tester.sh
@@ -39,6 +39,7 @@ echo -
 #  bash tools/testers/update-tester.sh
 #
 
+CURRENT=2.3.1
 
 function update_test {
 set -e
@@ -55,7 +56,7 @@ then
     echo "/usr/share/postgresql/9.3/extension/pgrouting--$1.sql found"
 else
     echo "/usr/share/postgresql/9.3/extension/pgrouting--$1.sql Not found"
-    exit 1
+#    exit 1
 fi
 
 createdb  ___test_update
@@ -71,43 +72,35 @@ dropdb   ___test_update
 } 
 
 #------------------------------------
+### updates from 2.3.0
+#------------------------------------
+
+update_test 2.3.0 $CURRENT
+
+#------------------------------------
 ### updates from 2.2.x
 #------------------------------------
 
-update_test 2.2.4 2.3.0
-update_test 2.2.3 2.3.0
-update_test 2.2.2 2.3.0
-update_test 2.2.1 2.3.0
-update_test 2.2.0 2.3.0
+update_test 2.2.4 $CURRENT
+update_test 2.2.3 $CURRENT
+update_test 2.2.2 $CURRENT
+update_test 2.2.1 $CURRENT
+update_test 2.2.0 $CURRENT
 
 
 #------------------------------------
 ### updates from 2.1.x
 #------------------------------------
 
-update_test 2.1.0 2.3.0
+update_test 2.1.0 $CURRENT
 
 #------------------------------------
 ### updates from 2.0.x
 #------------------------------------
 
-echo ------------------------------------
-echo ------------------------------------
-echo Updating from 2.0.0  to 2.3.0
-echo ------------------------------------
-
-createdb  ___test_update
-psql  ___test_update  <<EOF
-create extension postgis;
-create extension pgrouting with version '2.0.0';
-select pgr_version();
-alter extension pgrouting update to '2.1.0';
-select pgr_version();
-alter extension pgrouting update to '2.3.0';
-select pgr_version();
-EOF
-dropdb   ___test_update
+update_test 2.0.0 $CURRENT
 
-# CAN NOT BE Update test from 2.0.1  to 2.3.0
+echo Reached end of test, all tests passed
+# CAN NOT BE Update test from 2.0.1  to $CURRENT;
 
 
diff --git a/tools/travis/install-doxygen.sh b/tools/travis/install-doxygen.sh
new file mode 100755
index 0000000..b57be1a
--- /dev/null
+++ b/tools/travis/install-doxygen.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Travis CI scripts 
+# Copyright(c) pgRouting Contributors
+#
+# Install Doxygen
+# ------------------------------------------------------------------------------
+
+set -e
+
+OS="$(lsb_release -c -s)"
+
+if [[ "$OS" != "trusty" ]] ; then
+    exit 0
+fi
+
+
+#install doxygen only on trusty
+
+sudo \
+    sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen  && \
+    doxygen --version ;
+
+#sudo add-apt-repository ppa:libreoffice/libreoffice-4-4 -y && \
+#    sudo apt-get -qq update && \
+#    sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen  && \
+#    doxygen --version ;
+
diff --git a/tools/travis/install-postgres.sh b/tools/travis/install-postgres.sh
new file mode 100755
index 0000000..ec9d32a
--- /dev/null
+++ b/tools/travis/install-postgres.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Travis CI scripts 
+# Copyright(c) pgRouting Contributors
+#
+# Install pgRouting prerequesits
+# ------------------------------------------------------------------------------
+
+set -e
+
+POSTGRESQL_VERSION="$1"
+PGUSER="$2"
+
+if [[ -z "$POSTGRESQL_VERSION" ]] ; then
+    exit 1
+fi
+
+
+if [[ "$POSTGRESQL_VERSION" = "9.5" ||  "$POSTGRESQL_VERSION" = "9.6"  ]] ; then
+    POSTGIS_VERSION="2.3"
+fi
+
+echo "Postgres $POSTGRESQL_VERSION"
+echo "User $PGUSER"
+
+sudo /etc/init.d/postgresql stop
+sudo apt-get install -y \
+    postgresql-server-dev-$POSTGRESQL_VERSION
+
+if [[ "$POSTGRESQL_VERSION" = "9.5" ||  "$POSTGRESQL_VERSION" = "9.6"  ]] ; then
+
+    ## removing unused postgresql
+    #sudo apt-get -y remove --purge postgresql-9.1
+    #sudo apt-get -y remove --purge postgresql-9.2
+    #sudo apt-get -y remove --purge postgresql-9.3
+    #sudo apt-get -y remove --purge postgresql-9.4
+    #sudo apt-get -y remove --purge postgresql-9.5
+    #sudo apt-get -y remove --purge postgresql-9.6
+
+    echo "Installing postgresql $POSTGRESQL_VERSION  & postgis "
+
+    sudo apt-get install -y \
+        postgresql-$POSTGRESQL_VERSION \
+        postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION
+
+    sudo cp /usr/lib/postgresql/$POSTGRESQL_VERSION/bin/pg_config /usr/bin/pg_config
+
+    sudo /etc/init.d/postgresql stop
+
+
+    sudo cat /etc/postgresql/$POSTGRESQL_VERSION/main/pg_hba.conf
+
+    sudo sed -i -e 's/port = 5433/port = 5432/g' /etc/postgresql/$POSTGRESQL_VERSION/main/postgresql.conf
+    sudo cp $TRAVIS_BUILD_DIR/tools/travis/pg_hba.conf /etc/postgresql/$POSTGRESQL_VERSION/main/pg_hba.conf
+
+    ps -fea | grep postgres
+fi
+
+sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION
+
+# intall pgtap after postgres instance has started
+sudo apt-get install -y  postgresql-$POSTGRESQL_VERSION-pgtap
+sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
diff --git a/tools/travis/test-documentation.sh b/tools/travis/test-documentation.sh
new file mode 100755
index 0000000..22ca023
--- /dev/null
+++ b/tools/travis/test-documentation.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# ------------------------------------------------------------------------------
+# Travis CI scripts 
+# Copyright(c) pgRouting Contributors
+#
+# testing documentation
+# ------------------------------------------------------------------------------
+
+set -e
+
+OS="$(lsb_release -c -s)"
+
+if [[ "$OS" != "trusty" ]] ; then
+    exit 0
+fi
+
+
+#testing doxygen only on trusty
+
+make doc
+make doxy
+

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



More information about the Pkg-grass-devel mailing list