[librttopo] 01/06: New upstream version 1.1.0~rc1

Bas Couwenberg sebastic at debian.org
Thu Jan 25 09:17:03 UTC 2018


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

sebastic pushed a commit to branch master
in repository librttopo.

commit fb1f9c93f45b9e3b631f718774dedfb546d9aead
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Thu Jan 25 10:08:34 2018 +0100

    New upstream version 1.1.0~rc1
---
 HOWTO_RELEASE                 |   4 +-
 NEWS.md                       |   3 +
 README.md                     |   4 +-
 configure.ac                  |  21 ++-
 headers/librttopo.h           |  17 +-
 headers/librttopo_geom.h.in   |   2 +-
 src/Makefile.am               |   4 +-
 src/box2d.c                   |   3 +-
 src/bytebuffer.c              |   3 +-
 src/bytebuffer.h              |   2 +-
 src/g_box.c                   |   3 +-
 src/g_serialized.c            |   3 +-
 src/g_util.c                  |   3 +-
 src/librttopo_geom_internal.h |   3 +-
 src/librttopo_internal.h      |   3 +-
 src/measures.c                |   3 +-
 src/measures.h                |   4 +-
 src/measures3d.c              |   5 +-
 src/measures3d.h              |   2 +-
 src/ptarray.c                 |   2 +-
 src/rtalgorithm.c             |   3 +-
 src/rtcircstring.c            |   3 +-
 src/rtcollection.c            |   3 +-
 src/rtcompound.c              |   3 +-
 src/rtcurvepoly.c             |   3 +-
 src/rtgeodetic.c              |   3 +-
 src/rtgeodetic.h              |   2 +-
 src/rtgeom.c                  |   3 +-
 src/rtgeom_api.c              |  10 +-
 src/rtgeom_debug.c            |   3 +-
 src/rtgeom_geos.c             |  74 +--------
 src/rtgeom_geos.h             |   2 +-
 src/rtgeom_geos_clean.c       |   4 +-
 src/rtgeom_geos_node.c        |   5 +-
 src/rtgeom_geos_split.c       |   3 +-
 src/rtgeom_log.h              |   2 +-
 src/rtgeom_topo.c             |  68 ++++----
 src/rthomogenize.c            |   3 +-
 src/rtin_geojson.c            |   2 +-
 src/rtin_twkb.c               |   3 +-
 src/rtin_wkb.c                |   2 +-
 src/rtiterator.c              |   3 +-
 src/rtline.c                  |   3 +-
 src/rtlinearreferencing.c     |   3 +-
 src/rtmcurve.c                |   3 +-
 src/rtmline.c                 |   3 +-
 src/rtmpoint.c                |   3 +-
 src/rtmpoly.c                 |   3 +-
 src/rtmsurface.c              |   3 +-
 src/rtout_encoded_polyline.c  |   3 +-
 src/rtout_geojson.c           |   3 +-
 src/rtout_gml.c               |   3 +-
 src/rtout_kml.c               |   3 +-
 src/rtout_svg.c               |   3 +-
 src/rtout_twkb.c              |   3 +-
 src/rtout_twkb.h              |   4 +-
 src/rtout_wkb.c               |   3 +-
 src/rtout_wkt.c               |   3 +-
 src/rtout_x3d.c               |   3 +-
 src/rtpoint.c                 |   2 +-
 src/rtpoly.c                  |   3 +-
 src/rtprint.c                 |   3 +-
 src/rtpsurface.c              |   3 +-
 src/rtspheroid.c              |   3 +-
 src/rtstroke.c                |   3 +-
 src/rtt_tpsnap.c              | 350 ++++++++++++++++++++----------------------
 src/rttin.c                   |   3 +-
 src/rttree.c                  |   3 +-
 src/rttree.h                  |   2 +-
 src/rttriangle.c              |   3 +-
 src/rtutil.c                  | 102 ++++++------
 src/stringbuffer.c            |   3 +-
 src/stringbuffer.h            |   2 +-
 src/varint.c                  |   3 +-
 src/varint.h                  |   2 +-
 75 files changed, 420 insertions(+), 423 deletions(-)

diff --git a/HOWTO_RELEASE b/HOWTO_RELEASE
index f203112..c59f9d0 100644
--- a/HOWTO_RELEASE
+++ b/HOWTO_RELEASE
@@ -1,9 +1,7 @@
 - Set version in configure.ac
 - Tweak -version-info in src/Makefile.am
 - Run make distcheck, fix if needed
-- Commit all of the above
-- Regenerate ChangeLog (make cl) and commit again
-- Commit and push to repository, confirm bots are all happy
+- Commit all of the above, confirm bots are all happy
 - Add annotated tag: git tag -sa librttopo-<version>
 - Push annotated tag to repository: git push <remote> librttopo-<version>
 - Create release artifacts: make dist
diff --git a/NEWS.md b/NEWS.md
index 952fdd7..5f515dc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,6 +6,9 @@ YYYY-MM-DD
  - Support for tolerance/precision=0 added, -1 is the new value
    for automatic computation of minimal tolerance.
 
+ - The getEdgeWithinBox2D backend callback needs to support a NULL
+   value as BBOX pointer (to return all edges)
+
  # New Features
 
  - Function `rtt_AddLineNoFace`, to add lines w/out determining new
diff --git a/README.md b/README.md
index ba94315..8e1d562 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ RT Topology Library
 
 | OSGeo | GitLab |
 |:---   |:---    |
-| [![Build Status](https://drone.osgeo.kbt.io/api/badges/rttopo/librttopo/status.svg)] (https://drone.osgeo.kbt.io/rttopo/librttopo) | [![Gitlab-CI](https://gitlab.com/rttopo/rttopo/badges/master/build.svg)] (https://gitlab.com/rttopo/rttopo/commits/master) |
+| [![Build Status](https://drone.osgeo.org/api/badges/rttopo/librttopo/status.svg)] (https://drone.osgeo.org/rttopo/librttopo) | [![Gitlab-CI](https://gitlab.com/rttopo/rttopo/badges/master/build.svg)] (https://gitlab.com/rttopo/rttopo/commits/master) |
 
 
 ## About
@@ -23,7 +23,7 @@ The RT Topology Library was funded by "Regione Toscana - SITA"
 (CIG: 6445512CC1), which also funded many improvements in the
 originating liblwgeom.
 
-Official code repository is https://git.osgeo.org/gogs/rttopo/librttopo.
+Official code repository is https://git.osgeo.org/gitea/rttopo/librttopo.
 
 A mirror exists at https://gitlab.com/rttopo/rttopo, automatically
 updated on every push to the official repository.
diff --git a/configure.ac b/configure.ac
index 1ba5764..1a02c7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,10 +20,23 @@ AC_DEFINE_UNQUOTED([LIBRTGEOM_VERSION], ["$VERSION"], [rtgeom version])
 AC_SUBST([LIBRTGEOM_VERSION])
 AH_TEMPLATE([RTGEOM_GEOS_VERSION],
             [RTTOPO GEOS version.])
-AH_TEMPLATE([RTGEOM_DEBUG_LEVEL],
-            [RTGEOM Debug Level.])
-AC_DEFINE(RTGEOM_DEBUG_LEVEL)
-AC_DEFINE_UNQUOTED([RTGEOM_DEBUG_LEVEL], [0], [debug level])
+
+AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug@<:@=LEVEL@:>@],
+  [Enable debugging messages up to LEVEL (4 if omitted)]),
+  [
+if test "$enableval" = "no"; then
+  RTGEOM_DEBUG_LEVEL=0;
+else
+  if test "$enableval" = "yes"; then
+    RTGEOM_DEBUG_LEVEL=4;
+  else
+    RTGEOM_DEBUG_LEVEL=$enableval;
+  fi;
+fi
+  ],
+  [RTGEOM_DEBUG_LEVEL=0])
+AC_DEFINE_UNQUOTED([RTGEOM_DEBUG_LEVEL], [$RTGEOM_DEBUG_LEVEL], [RTGEOM Debug level])
+
 
 # Checks for header files.
 AC_CHECK_HEADERS(stdlib.h,, [AC_MSG_ERROR([cannot find stdlib.h, bailing out])])
diff --git a/headers/librttopo.h b/headers/librttopo.h
index 6c77f34..15ba384 100644
--- a/headers/librttopo.h
+++ b/headers/librttopo.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -458,7 +458,7 @@ typedef struct RTT_BE_CALLBACKS_T {
    * Get edges whose bounding box overlaps a given 2D bounding box
    *
    * @param topo the topology to act upon
-   * @param box the query box
+   * @param box the query box, to be considered infinite if NULL
    * @param numelems output parameter, gets number of elements found
    *                 if the return is not null, otherwise see @return
    *                 section for semantic.
@@ -1418,21 +1418,22 @@ RTGEOM* rtt_GetFaceGeometry(RTT_TOPOLOGY* topo, RTT_ELEMID face);
 /*
  * rtt_tpsnap - snap geometry to topology
  *
- * Uses Trevisani-Peri algorithm version 7 as reported here:
- * https://git.osgeo.org/gogs/rttopo/librttopo/wiki/SnapToTopo-algorithm
+ * Uses Trevisani-Peri algorithm version 13 as reported here:
+ * https://git.osgeo.org/gitea/rttopo/librttopo/wiki/SnapToTopo-algorithm
  *
  * @param topo the reference topology
  * @param gin the input geometry
- * @param tssnap snap tolerance
+ * @param tolerance_snap snap tolerance
+ * @param tolerance_removal removal tolerance (use -1 to skip removal phase)
  * @param iterate if non zero, allows snapping to more than a single vertex,
  *                iteratively
- * @param remove_vertices if non zero, makes an initial pass removing
- *                        vertices within tolerance
  *
  * @return a new geometry, or NULL on error
  *
  */
 RTGEOM* rtt_tpsnap(RTT_TOPOLOGY *topo, const RTGEOM *gin,
-                   double tssnap, int iterate, int remove_vertices);
+                   double tolerance_snap,
+                   double tolerance_removal,
+                   int iterate);
 
 #endif /* LIBRTGEOM_TOPO_H */
diff --git a/headers/librttopo_geom.h.in b/headers/librttopo_geom.h.in
index d27c32f..6aaa840 100644
--- a/headers/librttopo_geom.h.in
+++ b/headers/librttopo_geom.h.in
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/Makefile.am b/src/Makefile.am
index dd4ff3f..9085cda 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 
-AM_CPPFLAGS = -I$(top_srcdir)/src
-AM_CPPFLAGS += -I$(top_srcdir)/headers
+AM_CPPFLAGS = -I$(top_builddir)/src
+AM_CPPFLAGS += -I$(top_builddir)/headers -I$(top_srcdir)/headers
 
 lib_LTLIBRARIES = librttopo.la
 
diff --git a/src/box2d.c b/src/box2d.c
index 4548091..188bb4d 100644
--- a/src/box2d.c
+++ b/src/box2d.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
  **********************************************************************/
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/bytebuffer.c b/src/bytebuffer.c
index 2f6e318..fef9f1e 100644
--- a/src/bytebuffer.c
+++ b/src/bytebuffer.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "bytebuffer.h"
 
diff --git a/src/bytebuffer.h b/src/bytebuffer.h
index 321f971..0c230fa 100644
--- a/src/bytebuffer.h
+++ b/src/bytebuffer.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/g_box.c b/src/g_box.c
index 69e35a7..de4e1fe 100644
--- a/src/g_box.c
+++ b/src/g_box.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 #if !HAVE_ISFINITE
 #endif
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 #include <stdlib.h>
diff --git a/src/g_serialized.c b/src/g_serialized.c
index 1d6da56..2b4ce9a 100644
--- a/src/g_serialized.c
+++ b/src/g_serialized.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 
diff --git a/src/g_util.c b/src/g_util.c
index 85cbca9..3dcf39d 100644
--- a/src/g_util.c
+++ b/src/g_util.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <ctype.h>
 
 #include "librttopo_geom_internal.h"
diff --git a/src/librttopo_geom_internal.h b/src/librttopo_geom_internal.h
index 6e44182..c0a6c77 100644
--- a/src/librttopo_geom_internal.h
+++ b/src/librttopo_geom_internal.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,6 @@
 #ifndef _LIBRTGEOM_INTERNAL_H
 #define _LIBRTGEOM_INTERNAL_H 1
 
-#include "rttopo_config.h"
 #include "librttopo_geom.h"
 
 #include "rtgeom_log.h"
diff --git a/src/librttopo_internal.h b/src/librttopo_internal.h
index 82dd854..8ac77a5 100644
--- a/src/librttopo_internal.h
+++ b/src/librttopo_internal.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@
 #ifndef LIBRTGEOM_TOPO_INTERNAL_H
 #define LIBRTGEOM_TOPO_INTERNAL_H 1
 
-#include "rttopo_config.h"
 #include "geos_c.h"
 
 #include "librttopo_geom.h"
diff --git a/src/measures.c b/src/measures.c
index 7176084..6d6a2a6 100644
--- a/src/measures.c
+++ b/src/measures.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <string.h>
 #include <stdlib.h>
 
diff --git a/src/measures.h b/src/measures.h
index 1f3e278..9325ca6 100644
--- a/src/measures.h
+++ b/src/measures.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  * Copyright 2010 Nicklas Avén
  *
  * This is free software; you can redistribute and/or modify it under
diff --git a/src/measures3d.c b/src/measures3d.c
index 550624d..454f830 100644
--- a/src/measures3d.c
+++ b/src/measures3d.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  * Copyright 2011 Nicklas Avén
  *
  * This is free software; you can redistribute and/or modify it under
@@ -36,6 +36,7 @@
  *
  **********************************************************************/
 
+#include "rttopo_config.h"
 #include <string.h>
 #include <stdlib.h>
 
diff --git a/src/measures3d.h b/src/measures3d.h
index 0dc8e6e..cb149ac 100644
--- a/src/measures3d.h
+++ b/src/measures3d.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/ptarray.c b/src/ptarray.c
index 2e082e2..6531695 100644
--- a/src/ptarray.c
+++ b/src/ptarray.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtalgorithm.c b/src/rtalgorithm.c
index 2eb2563..b710d9f 100644
--- a/src/rtalgorithm.c
+++ b/src/rtalgorithm.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 #include <ctype.h> /* for tolower */
diff --git a/src/rtcircstring.c b/src/rtcircstring.c
index 67bd9e3..e3f1888 100644
--- a/src/rtcircstring.c
+++ b/src/rtcircstring.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 /* basic RTCIRCSTRING functions */
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtcollection.c b/src/rtcollection.c
index 7ac1c80..58cec05 100644
--- a/src/rtcollection.c
+++ b/src/rtcollection.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtcompound.c b/src/rtcompound.c
index 85fe19a..3b1711c 100644
--- a/src/rtcompound.c
+++ b/src/rtcompound.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtcurvepoly.c b/src/rtcurvepoly.c
index 8288757..bef192d 100644
--- a/src/rtcurvepoly.c
+++ b/src/rtcurvepoly.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 /* basic RTCURVEPOLY manipulation */
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtgeodetic.c b/src/rtgeodetic.c
index 6a7ef7d..49074a5 100644
--- a/src/rtgeodetic.c
+++ b/src/rtgeodetic.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeodetic.h"
 #include "rtgeom_log.h"
diff --git a/src/rtgeodetic.h b/src/rtgeodetic.h
index cdb654e..d8ae714 100644
--- a/src/rtgeodetic.h
+++ b/src/rtgeodetic.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtgeom.c b/src/rtgeom.c
index e1f2386..9034df6 100644
--- a/src/rtgeom.c
+++ b/src/rtgeom.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/src/rtgeom_api.c b/src/rtgeom_api.c
index c698ee1..bb78928 100644
--- a/src/rtgeom_api.c
+++ b/src/rtgeom_api.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,9 +22,7 @@
  *
  **********************************************************************/
 
-
-
-
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 
@@ -240,6 +238,8 @@ rt_getPoint4d(const RTCTX *ctx, const RTPOINTARRAY *pa, int n)
  * will set point's m=NO_M_VALUE  if pa is 3d or 2d
  *
  * NOTE: this will modify the point4d pointed to by 'point'.
+ *
+ * @return 0 on error, 1 on success
  */
 int
 rt_getPoint4d_p(const RTCTX *ctx, const RTPOINTARRAY *pa, int n, RTPOINT4D *op)
@@ -253,6 +253,7 @@ rt_getPoint4d_p(const RTCTX *ctx, const RTPOINTARRAY *pa, int n, RTPOINT4D *op)
   if ( (n<0) || (n>=pa->npoints))
   {
     rterror(ctx, "rt_getPoint4d_p: point offset out of range");
+    return 0;
   }
 #endif
 
@@ -289,6 +290,7 @@ rt_getPoint4d_p(const RTCTX *ctx, const RTPOINTARRAY *pa, int n, RTPOINT4D *op)
 
   default:
     rterror(ctx, "Unknown ZM flag ??");
+    return 0;
   }
   return 1;
 
diff --git a/src/rtgeom_debug.c b/src/rtgeom_debug.c
index e3bfe5f..9ddd2ab 100644
--- a/src/rtgeom_debug.c
+++ b/src/rtgeom_debug.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "rtgeom_log.h"
 #include "librttopo_geom.h"
 
diff --git a/src/rtgeom_geos.c b/src/rtgeom_geos.c
index 4e66082..0afaf96 100644
--- a/src/rtgeom_geos.c
+++ b/src/rtgeom_geos.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,7 @@
  *
  **********************************************************************/
 
-
-
+#include "rttopo_config.h"
 #include "rtgeom_geos.h"
 #include "librttopo_geom.h"
 #include "librttopo_geom_internal.h"
@@ -237,7 +236,10 @@ ptarray_to_GEOSCoordSeq(const RTCTX *ctx, const RTPOINTARRAY *pa)
     dims = 3;
 
   if ( ! (sq = GEOSCoordSeq_create_r(ctx->gctx, pa->npoints, dims)) )
+  {
     rterror(ctx, "Error creating GEOS Coordinate Sequence");
+    return NULL;
+  }
 
   for ( i=0; i < pa->npoints; i++ )
   {
@@ -253,15 +255,6 @@ ptarray_to_GEOSCoordSeq(const RTCTX *ctx, const RTPOINTARRAY *pa)
       RTDEBUGF(ctx, 4, "Point: %g,%g", p2d->x, p2d->y);
     }
 
-#if RTGEOM_GEOS_VERSION < 33
-    /* Make sure we don't pass any infinite values down into GEOS */
-    /* GEOS 3.3+ is supposed to  handle this stuff OK */
-    if ( isinf(p2d->x) || isinf(p2d->y) || (dims == 3 && isinf(p3d->z)) )
-      rterror(ctx, "Infinite coordinate value found in geometry.");
-    if ( isnan(p2d->x) || isnan(p2d->y) || (dims == 3 && isnan(p3d->z)) )
-      rterror(ctx, "NaN coordinate value found in geometry.");
-#endif
-
     GEOSCoordSeq_setX_r(ctx->gctx, sq, i, p2d->x);
     GEOSCoordSeq_setY_r(ctx->gctx, sq, i, p2d->y);
 
@@ -375,23 +368,13 @@ RTGEOM2GEOS(const RTCTX *ctx, const RTGEOM *rtgeom, int autofix)
     RTPOLY *rtpoly = NULL;
     RTLINE *rtl = NULL;
     RTCOLLECTION *rtc = NULL;
-#if RTGEOM_GEOS_VERSION < 33
-    RTPOINTARRAY *pa = NULL;
-#endif
 
   case RTPOINTTYPE:
     rtp = (RTPOINT *)rtgeom;
 
     if ( rtgeom_is_empty(ctx, rtgeom) )
     {
-#if RTGEOM_GEOS_VERSION < 33
-      pa = ptarray_construct_empty(ctx, rtgeom_has_z(ctx, rtgeom), rtgeom_has_m(ctx, rtgeom), 2);
-      sq = ptarray_to_GEOSCoordSeq(ctx, pa);
-      shell = GEOSGeom_createLinearRing_r(ctx->gctx, sq);
-      g = GEOSGeom_createPolygon_r(ctx->gctx, shell, NULL, 0);
-#else
       g = GEOSGeom_createEmptyPolygon_r(ctx->gctx);
-#endif
     }
     else
     {
@@ -427,14 +410,7 @@ RTGEOM2GEOS(const RTCTX *ctx, const RTGEOM *rtgeom, int autofix)
     rtpoly = (RTPOLY *)rtgeom;
     if ( rtgeom_is_empty(ctx, rtgeom) )
     {
-#if RTGEOM_GEOS_VERSION < 33
-      RTPOINTARRAY *pa = ptarray_construct_empty(ctx, rtgeom_has_z(ctx, rtgeom), rtgeom_has_m(ctx, rtgeom), 2);
-      sq = ptarray_to_GEOSCoordSeq(ctx, pa);
-      shell = GEOSGeom_createLinearRing_r(ctx->gctx, sq);
-      g = GEOSGeom_createPolygon_r(ctx->gctx, shell, NULL, 0);
-#else
       g = GEOSGeom_createEmptyPolygon_r(ctx->gctx);
-#endif
     }
     else
     {
@@ -1439,14 +1415,6 @@ rtgeom_geos_noop(const RTCTX *ctx, const RTGEOM* geom_in)
 RTGEOM*
 rtgeom_snap(const RTCTX *ctx, const RTGEOM* geom1, const RTGEOM* geom2, double tolerance)
 {
-#if RTGEOM_GEOS_VERSION < 33
-  rterror(ctx, "The GEOS version this rtgeom library "
-          "was compiled against (%d) doesn't support "
-          "'Snap' function (3.3.0+ required)",
-          RTGEOM_GEOS_VERSION);
-  return NULL;
-#else /* RTGEOM_GEOS_VERSION >= 33 */
-
   int srid, is3d;
   GEOSGeometry *g1, *g2, *g3;
   RTGEOM* out;
@@ -1496,20 +1464,11 @@ rtgeom_snap(const RTCTX *ctx, const RTGEOM* geom1, const RTGEOM* geom2, double t
   GEOSGeom_destroy_r(ctx->gctx, g3);
 
   return out;
-
-#endif /* RTGEOM_GEOS_VERSION >= 33 */
 }
 
 RTGEOM*
 rtgeom_sharedpaths(const RTCTX *ctx, const RTGEOM* geom1, const RTGEOM* geom2)
 {
-#if RTGEOM_GEOS_VERSION < 33
-  rterror(ctx, "The GEOS version this postgis binary "
-          "was compiled against (%d) doesn't support "
-          "'SharedPaths' function (3.3.0+ required)",
-          RTGEOM_GEOS_VERSION);
-  return NULL;
-#else /* RTGEOM_GEOS_VERSION >= 33 */
   GEOSGeometry *g1, *g2, *g3;
   RTGEOM *out;
   int is3d, srid;
@@ -1558,15 +1517,11 @@ rtgeom_sharedpaths(const RTCTX *ctx, const RTGEOM* geom1, const RTGEOM* geom2)
   }
 
   return out;
-#endif /* RTGEOM_GEOS_VERSION >= 33 */
 }
 
 RTGEOM*
 rtgeom_offsetcurve(const RTCTX *ctx, const RTLINE *rtline, double size, int quadsegs, int joinStyle, double mitreLimit)
 {
-#if RTGEOM_GEOS_VERSION < 32
-  rterror(ctx, "rtgeom_offsetcurve: GEOS 3.2 or higher required");
-#else
   GEOSGeometry *g1, *g3;
   RTGEOM *rtgeom_result;
   RTGEOM *rtgeom_in = rtline_as_rtgeom(ctx, rtline);
@@ -1580,14 +1535,7 @@ rtgeom_offsetcurve(const RTCTX *ctx, const RTLINE *rtline, double size, int quad
     return NULL;
   }
 
-#if RTGEOM_GEOS_VERSION < 33
-  /* Size is artays positive for GEOSSingleSidedBuffer, and a flag determines left/right */
-  g3 = GEOSSingleSidedBuffer_r(ctx->gctx, g1, size < 0 ? -size : size,
-                             quadsegs, joinStyle, mitreLimit,
-                             size < 0 ? 0 : 1);
-#else
   g3 = GEOSOffsetCurve_r(ctx->gctx, g1, size, quadsegs, joinStyle, mitreLimit);
-#endif
   /* Don't need input geometry anymore */
   GEOSGeom_destroy_r(ctx->gctx, g1);
 
@@ -1610,8 +1558,6 @@ rtgeom_offsetcurve(const RTCTX *ctx, const RTLINE *rtline, double size, int quad
   }
 
   return rtgeom_result;
-
-#endif /* RTGEOM_GEOS_VERSION < 32 */
 }
 
 RTTIN * rttin_from_geos(const RTCTX *ctx, const GEOSGeometry *geom, int want3d) {
@@ -1679,11 +1625,9 @@ RTTIN * rttin_from_geos(const RTCTX *ctx, const GEOSGeometry *geom, int want3d)
 /*
  * output = 1 for edges, 2 for TIN, 0 for polygons
  */
-RTGEOM* rtgeom_delaunay_triangulation(const RTCTX *ctx, const RTGEOM *rtgeom_in, double tolerance, int output) {
-#if RTGEOM_GEOS_VERSION < 34
-  rterror(ctx, "rtgeom_delaunay_triangulation: GEOS 3.4 or higher required");
-  return NULL;
-#else
+RTGEOM*
+rtgeom_delaunay_triangulation(const RTCTX *ctx, const RTGEOM *rtgeom_in, double tolerance, int output)
+{
   GEOSGeometry *g1, *g3;
   RTGEOM *rtgeom_result;
 
@@ -1735,6 +1679,4 @@ RTGEOM* rtgeom_delaunay_triangulation(const RTCTX *ctx, const RTGEOM *rtgeom_in,
   }
 
   return rtgeom_result;
-
-#endif /* RTGEOM_GEOS_VERSION < 34 */
 }
diff --git a/src/rtgeom_geos.h b/src/rtgeom_geos.h
index d202cc8..ab7a53a 100644
--- a/src/rtgeom_geos.h
+++ b/src/rtgeom_geos.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtgeom_geos_clean.c b/src/rtgeom_geos_clean.c
index d352b1a..f5203dd 100644
--- a/src/rtgeom_geos_clean.c
+++ b/src/rtgeom_geos_clean.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
  *
  **********************************************************************/
 
-
+#include "rttopo_config.h"
 
 #include "librttopo_geom.h"
 #include "rtgeom_geos.h"
diff --git a/src/rtgeom_geos_node.c b/src/rtgeom_geos_node.c
index 777ac0a..5e9a22d 100644
--- a/src/rtgeom_geos_node.c
+++ b/src/rtgeom_geos_node.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,7 @@
  *
  **********************************************************************/
 
-
-
+#include "rttopo_config.h"
 #include "rtgeom_geos.h"
 #include "librttopo_geom_internal.h"
 
diff --git a/src/rtgeom_geos_split.c b/src/rtgeom_geos_split.c
index 472b4ea..74eeab0 100644
--- a/src/rtgeom_geos_split.c
+++ b/src/rtgeom_geos_split.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "rtgeom_geos.h"
 #include "librttopo_geom_internal.h"
 
diff --git a/src/rtgeom_log.h b/src/rtgeom_log.h
index c920395..e706936 100644
--- a/src/rtgeom_log.h
+++ b/src/rtgeom_log.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtgeom_topo.c b/src/rtgeom_topo.c
index 92e4687..7cc0e4b 100644
--- a/src/rtgeom_topo.c
+++ b/src/rtgeom_topo.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1511,11 +1511,13 @@ _rtt_InitEdgeEndByLine(const RTCTX *ctx, edgeend *fee, edgeend *lee, RTLINE *edg
     return -1;
   }
   if ( ! azimuth_pt_pt(ctx, fp, &pt, &(fee->myaz)) ) {
-    rterror(ctx, "error computing azimuth of first edgeend [%g %g,%g %g]",
+    rterror(ctx, "error computing azimuth of first edgeend"
+            " [%.15g %.15g,%.15g %.15g]",
             fp->x, fp->y, pt.x, pt.y);
     return -2;
   }
-  RTDEBUGF(ctx, 1, "azimuth of first edge end [%g %g,%g %g] is %g",
+  RTDEBUGF(ctx, 1, "azimuth of first edge end"
+            " [%.15g %.15g,%.15g %.15g] is %.15g",
             fp->x, fp->y, pt.x, pt.y, fee->myaz);
 
   /* Compute azimuth of second edge end */
@@ -1526,11 +1528,13 @@ _rtt_InitEdgeEndByLine(const RTCTX *ctx, edgeend *fee, edgeend *lee, RTLINE *edg
     return -1;
   }
   if ( ! azimuth_pt_pt(ctx, lp, &pt, &(lee->myaz)) ) {
-    rterror(ctx, "error computing azimuth of last edgeend [%g %g,%g %g]",
+    rterror(ctx, "error computing azimuth of last segment"
+            " [%.15g %.15g,%.15g %.15g]",
             lp->x, lp->y, pt.x, pt.y);
     return -2;
   }
-  RTDEBUGF(ctx, 1, "azimuth of last edge end [%g %g,%g %g] is %g",
+  RTDEBUGF(ctx, 1, "azimuth of last edge end"
+            " [%.15g %.15g,%.15g %.15g] is %.15g",
             lp->x, lp->y, pt.x, pt.y, lee->myaz);
 
   return 0;
@@ -1620,13 +1624,14 @@ _rtt_FindAdjacentEdges( RTT_TOPOLOGY* topo, RTT_ELEMID node, edgeend *data,
       rt_getPoint2d_p(iface->ctx, pa, 1, &p2);
       RTDEBUGF(iface->ctx, 1, "edge %" RTTFMT_ELEMID
                   " starts on node %" RTTFMT_ELEMID
-                  ", edgeend is %g,%g-%g,%g",
+                  ", edgeend is %.15g %.15g,%.15g %.15g",
                   edge->edge_id, node, p1.x, p1.y, p2.x, p2.y);
       if ( ! azimuth_pt_pt(iface->ctx, &p1, &p2, &az) ) {{
         RTT_ELEMID id = edge->edge_id;
         rtt_release_edges(iface->ctx, edges, numedges);
         rtgeom_free(iface->ctx, cleangeom);
-        rterror(iface->ctx, "error computing azimuth of edge %d first edgeend [%g,%g-%g,%g]",
+        rterror(iface->ctx, "error computing azimuth of edge %d first segment"
+                " [%.15g %.15g,%.15g,%.15g]",
                 id, p1.x, p1.y, p2.x, p2.y);
         return -1;
       }}
@@ -1675,14 +1680,16 @@ _rtt_FindAdjacentEdges( RTT_TOPOLOGY* topo, RTT_ELEMID node, edgeend *data,
     if ( edge->end_node == node ) {
       rt_getPoint2d_p(iface->ctx, pa, pa->npoints-1, &p1);
       rt_getPoint2d_p(iface->ctx, pa, pa->npoints-2, &p2);
-      RTDEBUGF(iface->ctx, 1, "edge %" RTTFMT_ELEMID " ends on node %" RTTFMT_ELEMID
-                  ", edgeend is %g,%g-%g,%g",
+      RTDEBUGF(iface->ctx, 1, "edge %" RTTFMT_ELEMID
+                  " ends on node %" RTTFMT_ELEMID
+                  ", edgeend is %.15g %.15g,%.15g %.15g",
                   edge->edge_id, node, p1.x, p1.y, p2.x, p2.y);
       if ( ! azimuth_pt_pt(iface->ctx, &p1, &p2, &az) ) {{
         RTT_ELEMID id = edge->edge_id;
         rtt_release_edges(iface->ctx, edges, numedges);
         rtgeom_free(iface->ctx, cleangeom);
-        rterror(iface->ctx, "error computing azimuth of edge %d last edgeend [%g,%g-%g,%g]",
+        rterror(iface->ctx, "error computing azimuth of edge %d last segment"
+                " [%.15g %.15g,%.15g %.15g]",
                 id, p1.x, p1.y, p2.x, p2.y);
         return -1;
       }}
@@ -2442,7 +2449,8 @@ _rtt_AddEdge( RTT_TOPOLOGY* topo,
   }
   if ( ! azimuth_pt_pt(iface->ctx, &p1, &pn, &span.myaz) ) {
     rtgeom_free(iface->ctx, cleangeom);
-    rterror(iface->ctx, "error computing azimuth of first edgeend [%g,%g-%g,%g]",
+    rterror(iface->ctx, "error computing azimuth of first segment"
+            " [%.15g %.15g,%.15g %.15g]",
             p1.x, p1.y, pn.x, pn.y);
     return -1;
   }
@@ -2453,7 +2461,8 @@ _rtt_AddEdge( RTT_TOPOLOGY* topo,
   rt_getPoint2d_p(iface->ctx, pa, pa->npoints-2, &pn);
   rtgeom_free(iface->ctx, cleangeom);
   if ( ! azimuth_pt_pt(iface->ctx, &p2, &pn, &epan.myaz) ) {
-    rterror(iface->ctx, "error computing azimuth of last edgeend [%g,%g-%g,%g]",
+    rterror(iface->ctx, "error computing azimuth of last segment"
+            " [%.15g %.15g,%.15g %.15g]",
             p2.x, p2.y, pn.x, pn.y);
     return -1;
   }
@@ -6005,7 +6014,7 @@ rtt_AddLineNoFace(RTT_TOPOLOGY* topo, RTLINE* line, double tol, int* nedges)
     /* Backend error, message should have been printed already */
     return NULL;
   }
-  
+
   return _rtt_AddLine(topo, line, tol, nedges, 0);
 }
 
@@ -6183,6 +6192,7 @@ _rtt_getIsoEdgeById(RTT_ISO_EDGE_TABLE *tab, RTT_ELEMID id)
 typedef struct RTT_EDGERING_ELEM_T {
   /* externally owned */
   RTT_ISO_EDGE *edge;
+  /* 0 if false, 1 if true */
   int left;
 } RTT_EDGERING_ELEM;
 
@@ -6349,12 +6359,9 @@ _rtt_FetchAllEdges(RTT_TOPOLOGY *topo, int *numedges)
   RTT_ISO_EDGE *edge;
   int fields = RTT_COL_EDGE_ALL;
   int nelems = 1;
-  RTGBOX qbox;
   const RTCTX *ctx = topo->be_iface->ctx;
 
-  qbox.xmin = qbox.ymin = -DBL_MAX;
-  qbox.xmax = qbox.ymax = DBL_MAX;
-  edge = rtt_be_getEdgeWithinBox2D( topo, &qbox, &nelems, fields, 0);
+  edge = rtt_be_getEdgeWithinBox2D( topo, NULL, &nelems, fields, 0);
   *numedges = nelems;
   if ( nelems == -1 ) {
     rterror(ctx, "Backend error: %s", rtt_be_lastErrorMessage(topo->be_iface));
@@ -6511,7 +6518,7 @@ _rtt_BuildEdgeRing(RTT_TOPOLOGY *topo, RTT_ISO_EDGE_TABLE *edges,
     }
   } while (cur != edge || curside != side);
 
-  RTDEBUGF(ctx, 1, "Ring for edge %d has %d elems", edge->edge_id, ring->size);
+  RTDEBUGF(ctx, 1, "Ring for edge %d has %d elems", edge->edge_id*side, ring->size);
 
   return ring;
 }
@@ -6706,7 +6713,7 @@ _rtt_RegisterFaceOnEdgeSide(RTT_TOPOLOGY *topo, RTT_ISO_EDGE *edge,
     /* Create new face */
     RTT_ISO_FACE newface;
 
-    RTDEBUGF(ctx, 1, "Ring of edge %d is a shell", sedge);
+    RTDEBUGF(ctx, 1, "Ring of edge %d is a shell (shell %d)", sedge, shells->size);
 
     newface.mbr = _rtt_EdgeRingGetBbox(ctx, ring);
 
@@ -6742,7 +6749,7 @@ _rtt_RegisterFaceOnEdgeSide(RTT_TOPOLOGY *topo, RTT_ISO_EDGE *edge,
   }
   else /* cw, so is an hole */
   {
-    RTDEBUGF(ctx, 1, "Ring of edge %d is a hole", sedge);
+    RTDEBUGF(ctx, 1, "Ring of edge %d is a hole (hole %d)", sedge, holes->size);
     *registered = placeholder_faceid;
     RTT_EDGERING_ARRAY_PUSH(ctx, holes, ring);
   }
@@ -6835,8 +6842,8 @@ _rtt_FindFaceContainingRing(RTT_TOPOLOGY* topo, RTT_EDGERING *ring,
   accumulator.ctx = ctx;
   RTT_EDGERING_ARRAY_INIT(ctx, &candidates);
 	GEOSSTRtree_query_r(ctx->gctx, shells->tree, ghole, &_rtt_AccumulateCanditates, &accumulator);
-  RTDEBUGF(ctx, 1, "Found %d candidate shells for containement of ring %d point",
-          candidates.size, ring->elems[0]->edge->edge_id);
+  RTDEBUGF(ctx, 1, "Found %d candidate shells containing first point of ring's originating edge %d",
+          candidates.size, ring->elems[0]->edge->edge_id * ( ring->elems[0]->left ? 1 : -1 ) );
 
   /* TODO: sort candidates by bounding box size */
 
@@ -6848,15 +6855,24 @@ _rtt_FindFaceContainingRing(RTT_TOPOLOGY* topo, RTT_EDGERING *ring,
 
     if ( sring->elems[0]->edge->edge_id == ring->elems[0]->edge->edge_id )
     {
-      RTDEBUGF(ctx, 1, "Shell %d is on other side of ring", _rtt_EdgeRingGetFace(sring));
+      RTDEBUGF(ctx, 1, "Shell %d is on other side of ring",
+               _rtt_EdgeRingGetFace(sring));
+      continue;
+    }
+
+    /* The hole envelope cannot equal the shell envelope */
+    if ( gbox_same(ctx, shellbox, testbox) )
+    {
+      RTDEBUGF(ctx, 1, "Bbox of shell %d equals that of hole ring",
+               _rtt_EdgeRingGetFace(sring));
       continue;
     }
 
-    /* Skip if test point is not in shellbox */
+    /* Skip if ring box is not in shell box */
     if ( ! gbox_contains_2d(ctx, shellbox, testbox) )
     {
-      /* TODO: skip this, should never happen, as we're candidates! */
-      RTDEBUGF(ctx, 1, "Bbox of shell %d does not contain bbox of ring point", _rtt_EdgeRingGetFace(sring));
+      RTDEBUGF(ctx, 1, "Bbox of shell %d does not contain bbox of ring point",
+               _rtt_EdgeRingGetFace(sring));
       continue;
     }
 
diff --git a/src/rthomogenize.c b/src/rthomogenize.c
index 773a8b7..f51cf54 100644
--- a/src/rthomogenize.c
+++ b/src/rthomogenize.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdlib.h>
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
diff --git a/src/rtin_geojson.c b/src/rtin_geojson.c
index 289127b..d0aa54b 100644
--- a/src/rtin_geojson.c
+++ b/src/rtin_geojson.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtin_twkb.c b/src/rtin_twkb.c
index bd48fc1..1b2a7ae 100644
--- a/src/rtin_twkb.c
+++ b/src/rtin_twkb.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <math.h>
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
diff --git a/src/rtin_wkb.c b/src/rtin_wkb.c
index a19228f..b2294d5 100644
--- a/src/rtin_wkb.c
+++ b/src/rtin_wkb.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtiterator.c b/src/rtiterator.c
index 447c14b..8f14336 100644
--- a/src/rtiterator.c
+++ b/src/rtiterator.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom.h"
 #include "rtgeom_log.h"
 
diff --git a/src/rtline.c b/src/rtline.c
index 115a541..0d55ee3 100644
--- a/src/rtline.c
+++ b/src/rtline.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 
 /* basic RTLINE functions */
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtlinearreferencing.c b/src/rtlinearreferencing.c
index 4e45647..09a95f3 100644
--- a/src/rtlinearreferencing.c
+++ b/src/rtlinearreferencing.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 #include "measures3d.h"
diff --git a/src/rtmcurve.c b/src/rtmcurve.c
index 26c46c4..17f5043 100644
--- a/src/rtmcurve.c
+++ b/src/rtmcurve.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtmline.c b/src/rtmline.c
index 328fbb4..03f10f4 100644
--- a/src/rtmline.c
+++ b/src/rtmline.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtmpoint.c b/src/rtmpoint.c
index 47dbaeb..215d695 100644
--- a/src/rtmpoint.c
+++ b/src/rtmpoint.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtmpoly.c b/src/rtmpoly.c
index 2cf95bb..c73f31b 100644
--- a/src/rtmpoly.c
+++ b/src/rtmpoly.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtmsurface.c b/src/rtmsurface.c
index e959433..479c65d 100644
--- a/src/rtmsurface.c
+++ b/src/rtmsurface.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtout_encoded_polyline.c b/src/rtout_encoded_polyline.c
index 68883dd..4815f23 100644
--- a/src/rtout_encoded_polyline.c
+++ b/src/rtout_encoded_polyline.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "stringbuffer.h"
 #include "librttopo_geom_internal.h"
 
diff --git a/src/rtout_geojson.c b/src/rtout_geojson.c
index 4a545c6..45fe1b8 100644
--- a/src/rtout_geojson.c
+++ b/src/rtout_geojson.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include <string.h>  /* strlen */
 #include <assert.h>
diff --git a/src/rtout_gml.c b/src/rtout_gml.c
index 40728af..811e2fc 100644
--- a/src/rtout_gml.c
+++ b/src/rtout_gml.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
 **********************************************************************/
 
 
+#include "rttopo_config.h"
 #include <string.h>
 #include "librttopo_geom_internal.h"
 
diff --git a/src/rtout_kml.c b/src/rtout_kml.c
index d3367f3..a290e9f 100644
--- a/src/rtout_kml.c
+++ b/src/rtout_kml.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "stringbuffer.h"
 
diff --git a/src/rtout_svg.c b/src/rtout_svg.c
index 3b87f1b..ea6e131 100644
--- a/src/rtout_svg.c
+++ b/src/rtout_svg.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@
 * BNF SVG Path: <http://www.w3.org/TR/SVG/paths.html#PathDataBNF>
 **********************************************************************/
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 
 static char * assvg_point(const RTCTX *ctx, const RTPOINT *point, int relative, int precision);
diff --git a/src/rtout_twkb.c b/src/rtout_twkb.c
index da48753..72bbef1 100644
--- a/src/rtout_twkb.c
+++ b/src/rtout_twkb.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "rtout_twkb.h"
 
 /*
diff --git a/src/rtout_twkb.h b/src/rtout_twkb.h
index 20f1029..29c147d 100644
--- a/src/rtout_twkb.h
+++ b/src/rtout_twkb.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  * Copyright 2013 Nicklas Avén
  *
  * This is free software; you can redistribute and/or modify it under
diff --git a/src/rtout_wkb.c b/src/rtout_wkb.c
index 34f8c82..7cfeda6 100644
--- a/src/rtout_wkb.c
+++ b/src/rtout_wkb.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <math.h>
 
 #include "librttopo_geom_internal.h"
diff --git a/src/rtout_wkt.c b/src/rtout_wkt.c
index 014085a..fa1845b 100644
--- a/src/rtout_wkt.c
+++ b/src/rtout_wkt.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 #include "stringbuffer.h"
diff --git a/src/rtout_x3d.c b/src/rtout_x3d.c
index e03fbd0..3dad3ab 100644
--- a/src/rtout_x3d.c
+++ b/src/rtout_x3d.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 **********************************************************************/
 
 
+#include "rttopo_config.h"
 #include <string.h>
 #include "librttopo_geom_internal.h"
 
diff --git a/src/rtpoint.c b/src/rtpoint.c
index 8291fd1..87da8fa 100644
--- a/src/rtpoint.c
+++ b/src/rtpoint.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rtpoly.c b/src/rtpoly.c
index e4924e1..18a0e02 100644
--- a/src/rtpoly.c
+++ b/src/rtpoly.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 
 /* basic RTPOLY manipulation */
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtprint.c b/src/rtprint.c
index e160fe3..43e7dd3 100644
--- a/src/rtprint.c
+++ b/src/rtprint.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <string.h>
 #include "librttopo_geom_internal.h"
diff --git a/src/rtpsurface.c b/src/rtpsurface.c
index bd7751b..7e19ce9 100644
--- a/src/rtpsurface.c
+++ b/src/rtpsurface.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtspheroid.c b/src/rtspheroid.c
index 9c673fb..0d715a1 100644
--- a/src/rtspheroid.c
+++ b/src/rtspheroid.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeodetic.h"
 #include "rtgeom_log.h"
diff --git a/src/rtstroke.c b/src/rtstroke.c
index 06ff361..25fdf89 100644
--- a/src/rtstroke.c
+++ b/src/rtstroke.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/src/rtt_tpsnap.c b/src/rtt_tpsnap.c
index 2bab00a..de02fe3 100644
--- a/src/rtt_tpsnap.c
+++ b/src/rtt_tpsnap.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
  * Implementation of Trevisani-Peri snap algoritm
  *
  * See
- * https://git.osgeo.org/gogs/rttopo/librttopo/wiki/SnapToTopo-algorithm
+ * https://git.osgeo.org/gitea/rttopo/librttopo/wiki/SnapToTopo-algorithm
  *
  **********************************************************************
  *
@@ -31,7 +31,7 @@
 
 #include "rttopo_config.h"
 
-/*#define RTGEOM_DEBUG_LEVEL 1*/
+/*#define RTGEOM_DEBUG_LEVEL 4*/
 #include "rtgeom_log.h"
 
 #include "librttopo_geom.h"
@@ -86,48 +86,6 @@ typedef struct {
   (a)->pts[(a)->size++] = (r); \
 }
 
-/* A pair of points with their distance */
-typedef struct {
-  RTT_SNAPV *p1;
-  RTT_SNAPV *p2;
-  double totdist; /* sum of the two points distances */
-  double segdist; /* between the two points */
-} RTT_VPAIR;
-
-/* An array of RTT_VPAIR structs */
-typedef struct {
-  RTT_VPAIR *pts;
-  int size;
-  int capacity;
-} RTT_VPAIR_ARRAY;
-
-#define RTT_VPAIR_ARRAY_INIT(c, a) { \
-  (a)->size = 0; \
-  (a)->capacity = 1; \
-  (a)->pts = rtalloc((c), sizeof(RTT_VPAIR) * (a)->capacity); \
-}
-
-#define RTT_VPAIR_ARRAY_CLEAN(c, a) { \
-  rtfree((c), (a)->pts); \
-  (a)->pts = NULL; \
-  (a)->size = 0; \
-  (a)->capacity = 0; \
-}
-
-#define RTT_VPAIR_ARRAY_INIT(c, a) { \
-  (a)->size = 0; \
-  (a)->capacity = 1; \
-  (a)->pts = rtalloc((c), sizeof(RTT_VPAIR) * (a)->capacity); \
-}
-
-#define RTT_VPAIR_ARRAY_PUSH(c, a, r) { \
-  if ( (a)->size + 1 > (a)->capacity ) { \
-    (a)->capacity *= 2; \
-    (a)->pts = rtrealloc((c), (a)->pts, sizeof(RTT_VPAIR) * (a)->capacity); \
-  } \
-  (a)->pts[(a)->size++] = (r); \
-}
-
 typedef struct
 {
 
@@ -135,15 +93,16 @@ typedef struct
    * Input parameters / configuration
    */
   const RTT_TOPOLOGY *topo;
-  double tssnap;
+  double tolerance_snap;
+  double tolerance_removal;
   int iterate;
-  int remove_vertices;
 
   /*
    * Extent of the geometry being snapped,
    * will be updated as needed as snapping occurs
    */
   RTGBOX workext;
+  RTGBOX expanded_workext;
 
   /*
    * Edges within workext,
@@ -163,10 +122,8 @@ static const RTT_ISO_EDGE *
 rtgeom_tpsnap_state_get_edges(rtgeom_tpsnap_state *state, int *num_edges)
 {
   if ( ! state->workedges ) {
-    RTGBOX qbox = state->workext;
-    gbox_expand(state->topo->be_iface->ctx, &qbox, state->tssnap);
     state->workedges = rtt_be_getEdgeWithinBox2D(state->topo,
-              &qbox,
+              &state->expanded_workext,
               &state->num_workedges,
               RTT_COL_EDGE_ALL, 0);
   }
@@ -176,8 +133,8 @@ rtgeom_tpsnap_state_get_edges(rtgeom_tpsnap_state *state, int *num_edges)
 }
 
 /*
- * Write number of edges in *num_edges, -1 on error.
- * @return edges, or NULL if none-or-error (look *num_edges to tell)
+ * Expand working extent to include new point.
+ * Resets working edges if new point expands the last used bounding box.
  */
 static void
 rtgeom_tpsnap_state_expand_workext_to_include(rtgeom_tpsnap_state *state,
@@ -194,6 +151,8 @@ rtgeom_tpsnap_state_expand_workext_to_include(rtgeom_tpsnap_state *state,
   p3d.z = 0.0;
 
   gbox_merge_point3d(ctx, &p3d, &state->workext);
+  state->expanded_workext = state->workext;
+  gbox_expand(ctx, &(state->expanded_workext), state->tolerance_snap);
 
   /* Reset workedges */
   if ( state->workedges ) {
@@ -228,12 +187,14 @@ _rt_find_closest_segment(const RTCTX *ctx, RTPOINT2D *pt, RTPOINTARRAY *pa,
   *segno = -1;
   *dist = FLT_MAX;
 
+  if ( pa->npoints < 2 ) return 0;
+
   rt_dist2d_distpts_init(ctx, &dl, DIST_MIN);
 
   /* Find closest segment */
+  rt_getPoint2d_p(ctx, pa, 0, &s0);
   for (j=0; j<pa->npoints-1; ++j)
   {
-    rt_getPoint2d_p(ctx, pa, j, &s0);
     rt_getPoint2d_p(ctx, pa, j+1, &s1);
 
     if ( rt_dist2d_pt_seg(ctx, pt, &s0, &s1, &dl) == RT_FALSE )
@@ -242,19 +203,21 @@ _rt_find_closest_segment(const RTCTX *ctx, RTPOINT2D *pt, RTPOINTARRAY *pa,
       return -1;
     }
 
-    /* Segment is too far, check next */
     if ( dl.distance < *dist )
     {
+      /* Segment is closest so far */
       *segno = j;
       *dist = dl.distance;
     }
+
+    s0 = s1;
   }
 
   return 0;
 }
 
 /*
- * Extract from edge all vertices where distance from pa <= tssnap
+ * Extract from edge all vertices where distance from pa <= tolerance_snap
  *
  * @return -1 on error, 0 on success
  */
@@ -274,10 +237,20 @@ _rt_extract_vertices_within_dist(rtgeom_tpsnap_state *state,
 
     rt_getPoint2d_p(ctx, edge->points, i, &(vert.pt));
 
+    /* skip if not covered by expanded_workext */
+    if ( vert.pt.x < state->expanded_workext.xmin ||
+         vert.pt.x > state->expanded_workext.xmax ||
+         vert.pt.y < state->expanded_workext.ymin ||
+         vert.pt.y > state->expanded_workext.ymax )
+    {
+      RTDEBUGF(ctx, 3, "skip point %g,%g outside expanded workext %g,%g,%g,%g", vert.pt.x, vert.pt.y, state->expanded_workext.xmin,state->expanded_workext.ymin,state->expanded_workext.xmax,state->expanded_workext.ymax);
+      continue;
+    }
+
     ret = _rt_find_closest_segment(ctx, &(vert.pt), pa, &vert.segno, &vert.dist);
     if ( ret == -1 ) return -1;
 
-    if ( vert.dist <= state->tssnap )
+    if ( vert.dist <= state->tolerance_snap )
     {
       /* push vert to array */
       RTT_SNAPV_ARRAY_PUSH(ctx, vset, vert);
@@ -290,7 +263,7 @@ _rt_extract_vertices_within_dist(rtgeom_tpsnap_state *state,
 
 /*
  * Find all topology edge vertices where distance from
- * given pointarray <= tssnap
+ * given pointarray <= tolerance_snap
  *
  * @return -1 on error, 0 on success
  */
@@ -322,59 +295,25 @@ _rt_find_vertices_within_dist(
 }
 
 static int
-compare_vpairs(const void *si1, const void *si2)
+compare_snapv(const void *si1, const void *si2)
 {
-  RTT_VPAIR *a = (RTT_VPAIR *)si1;
-  RTT_VPAIR *b = (RTT_VPAIR *)si2;
+  RTT_SNAPV *a = (RTT_SNAPV *)si1;
+  RTT_SNAPV *b = (RTT_SNAPV *)si2;
 
-  if ( a->totdist < b->totdist )
+  if ( a->dist < b->dist )
     return -1;
-  else if ( a->totdist > b->totdist )
+  else if ( a->dist > b->dist )
     return 1;
 
-  if ( a->segdist < b->segdist )
+  if ( a->pt.x < b->pt.x )
     return -1;
-  else if ( a->segdist > b->segdist )
+  else if ( a->pt.x > b->pt.x )
     return 1;
 
-  return 0;
-}
-
-/*
- * Let *VPlist* be a list of all vertices pairs (*VP*) in *Vset*
- * For each element *VP* in *VPlist*:
- *   Let *VP.TotDist* be the sum of the distances of each of the vertices in *VP*
- *   Let *VP.SegDist* be the distances between the two vertices in *VP*
- * Order *VPlist* by growing *VP.TotDist*, *VP.SegDist*
- *
- * @return 0 on success, -1 on error.
- *
- */
-static int
-_rt_make_sorted_vertices_pairs(const RTCTX *ctx,
-      RTT_SNAPV_ARRAY *vset,
-      RTT_VPAIR_ARRAY *vplist)
-{
-  int i, j, ret;
-  DISTPTS dl;
-  rt_dist2d_distpts_init(ctx, &dl, DIST_MIN);
-  for (i=0; i<vset->size; ++i)
-  {
-    for (j=i+1; j<vset->size; ++j)
-    {
-      RTT_VPAIR pair;
-      pair.p1 = &(vset->pts[i]);
-      pair.p2 = &(vset->pts[j]);
-      ret = rt_dist2d_pt_pt(ctx, &(pair.p1->pt), &(pair.p2->pt), &dl);
-      pair.segdist = dl.distance;
-      pair.totdist = pair.p1->dist + pair.p2->dist;
-      if ( ret == RT_FALSE ) return -1;
-      RTT_VPAIR_ARRAY_PUSH(ctx, vplist, pair);
-    }
-  }
-
-  /* Now sort it */
-  qsort(vplist->pts, vplist->size, sizeof(RTT_VPAIR), compare_vpairs);
+  if ( a->pt.y < b->pt.y )
+    return -1;
+  else if ( a->pt.y > b->pt.y )
+    return 1;
 
   return 0;
 }
@@ -439,7 +378,10 @@ rtgeom_visit_lines(const RTCTX *ctx, RTGEOM *rtgeom,
 /*
  * Vertex removal phase
  *
- * @return 0 on success, -1 on error.
+ * Remove internal vertices of `pa` that are within state.tolerance_snap
+ * distance from edges of state.topo topology.
+ *
+ * @return -1 on error, number of points removed on success
  */
 static int
 _rtgeom_tpsnap_ptarray_remove(const RTCTX *ctx, RTPOINTARRAY *pa,
@@ -448,6 +390,7 @@ _rtgeom_tpsnap_ptarray_remove(const RTCTX *ctx, RTPOINTARRAY *pa,
   int num_edges, i, j, ret;
   const RTT_ISO_EDGE *edges;
   const RTT_TOPOLOGY *topo = state->topo;
+  int removed = 0;
 
   /* Let *Eset* be the set of edges of *Topo-ref*
    *             with distance from *Gcomp* <= *TSsnap*
@@ -458,17 +401,24 @@ _rtgeom_tpsnap_ptarray_remove(const RTCTX *ctx, RTPOINTARRAY *pa,
     return -1;
   }
 
+  RTDEBUG(ctx, 1, "vertices removal phase starts");
+
   /* For each non-endpoint vertex *V* of *Gcomp* */
   for (i=1; i<pa->npoints-1; ++i)
   {
     RTPOINT2D V;
+    RTLINE *closest_segment_edge = NULL;
+    int closest_segment_number;
+    double closest_segment_distance = state->tolerance_removal+1;
+
     rt_getPoint2d_p(ctx, pa, i, &V);
 
-    /* For each edge *E* of *Eset* */
+    RTDEBUGF(ctx, 2, "Analyzing internal vertex POINT(%.15g %.15g)", V.x, V.y);
+
+    /* Find closest edge segment */
     for (j=0; j<num_edges; ++j)
     {
       RTLINE *E = edges[j].geom;
-      RTPOINT4D p, sp1, sp2, proj;
       int segno;
       double dist;
 
@@ -476,29 +426,57 @@ _rtgeom_tpsnap_ptarray_remove(const RTCTX *ctx, RTPOINTARRAY *pa,
       if ( ret < 0 ) return ret; /* error */
 
       /* Edge is too far */
-      if ( dist > state->tssnap ) continue;
+      if ( dist > state->tolerance_removal ) {
+        RTDEBUGF(ctx, 2, " Vertex is too far (%g) from edge %d", dist, edges[j].edge_id);
+        continue;
+      }
+
+      RTDEBUGF(ctx, 2, " Vertex within distance from segment %d of edge %d",
+        segno, edges[j].edge_id);
+
+      if ( dist < closest_segment_distance )
+      {
+        closest_segment_edge = E;
+        closest_segment_number = segno;
+        closest_segment_distance = dist;
+      }
+    }
+
+    if ( closest_segment_edge )
+    {{
+      RTPOINT4D V4d, Ep1, Ep2, proj;
+      RTPOINTARRAY *epa = closest_segment_edge->points;
+
+      /* Let *Proj* be the closest point in *closest_segment_edge* to *V* */
+      V4d.x = V.x; V4d.y = V.y; V4d.m = V4d.z = 0.0;
+      rt_getPoint4d_p(ctx, epa, closest_segment_number, &Ep1);
+      rt_getPoint4d_p(ctx, epa, closest_segment_number+1, &Ep2);
+      closest_point_on_segment(ctx, &V4d, &Ep1, &Ep2, &proj);
 
-      /* Let *Proj* be the closest point in *E* to *V* */
-      p.x = V.x; p.y = V.y; p.m = p.z = 0.0;
-      rt_getPoint4d_p(ctx, pa, segno, &sp1);
-      rt_getPoint4d_p(ctx, pa, segno+1, &sp2);
-      closest_point_on_segment(ctx, &p, &sp1, &sp2, &proj);
+      RTDEBUGF(ctx, 2, " Closest point on edge segment LINESTRING(%.15g %.15g, %.15g %.15g) is POINT(%.15g %.15g)",
+        Ep1.x, Ep1.y, Ep2.x, Ep2.y, proj.x, proj.y);
 
       /* Closest point here matches segment endpoint */
-      if ( p4d_same(ctx, &p, &sp1) || p4d_same(ctx, &p, &sp2) ) {
+      if ( p4d_same(ctx, &proj, &Ep1) || p4d_same(ctx, &proj, &Ep2) ) {
+        RTDEBUG(ctx, 2, " Closest point on edge matches segment endpoint");
         continue;
       }
 
       /* Remove vertex *V* from *Gcomp* */
+      RTDEBUGF(ctx, 1, " Removing internal point POINT(%.14g %.15g)",
+        V.x, V.y);
       ret = ptarray_remove_point(ctx, pa, i);
       if ( ret == RT_FAILURE ) return -1;
       /* rewind i */
       --i;
-      break;
-    }
+      /* increment removed count */
+      ++removed;
+    }}
   }
 
-  return 0;
+  RTDEBUGF(ctx, 1, "vertices removal phase ended (%d removed)", removed);
+
+  return removed;
 }
 
 /* Return NULL on error, or a GEOSGeometry on success */
@@ -577,83 +555,70 @@ _rt_snap_to_valid_vertex(const RTCTX *ctx, RTPOINTARRAY *pa,
 {
   int ret;
   RTPOINT4D p, sp1, sp2, proj;
+
   p.x = v->pt.x; p.y = v->pt.y; p.m = p.z = 0.0;
   rt_getPoint4d_p(ctx, pa, v->segno, &sp1);
   rt_getPoint4d_p(ctx, pa, v->segno+1, &sp2);
+
+  RTDEBUGF(ctx, 2, "Analyzing snap vertex POINT(%.15g %.15g)", p.x, p.y);
+  RTDEBUGF(ctx, 2, " Closest segment %d is LINESTRING(%.15g %.15g, %.15g %.15g)",
+    v->segno, sp1.x, sp1.y, sp2.x, sp2.y);
+
   closest_point_on_segment(ctx, &p, &sp1, &sp2, &proj);
 
+  RTDEBUGF(ctx, 2, " Closest point on segment is POINT(%.15g %.15g)",
+    proj.x, proj.y);
+
+
   /* Check if closest point matches segment endpoint (could be cached) */
-  if ( p4d_same(ctx, &p, &sp1) || p4d_same(ctx, &p, &sp2) ) {
+  if ( p4d_same(ctx, &proj, &sp1) || p4d_same(ctx, &proj, &sp2) )
+  {
+    RTDEBUG(ctx, 2, " Closest point matches a segment's endpoint");
     return 0;
   }
 
   /* Skip if closest segment is covered by topo-ref */
   ret = _rt_segment_covered(state, &sp1, &sp2);
   if ( ret == -1 ) return -1;
-  if ( ret == 1 ) {
+  if ( ret == 1 )
+  {
+    RTDEBUG(ctx, 2, " Closest segment is covered by topo edges");
     /* it is covered */
     return 0;
   }
 
   /* Snap ! */
-  ret = ptarray_insert_point(ctx, pa, &p, 0);
+  RTDEBUGF(ctx, 2, "Snapping input segment %d to POINT(%.15g %.15g)",
+    v->segno, p.x, p.y);
+  ret = ptarray_insert_point(ctx, pa, &p, v->segno+1);
   if ( ret == RT_FAILURE ) return -1;
 
   return 1;
 
 }
 
-/*
- * @return 0 if no valid snap was found, <0 on error, >0 if snapped
- */
-static int
-_rt_snap_to_valid_pair(const RTCTX *ctx, RTPOINTARRAY *pa,
-  RTT_VPAIR *pair, rtgeom_tpsnap_state *state)
-{
-  int snapCount = 0, ret;
-
-  ret = _rt_snap_to_valid_vertex(ctx, pa, pair->p1, state);
-  if ( ret < 0 ) return ret;
-  snapCount += ret;
-
-  if ( ret ) {
-    /* Expand working extent */
-    rtgeom_tpsnap_state_expand_workext_to_include(state,
-      &(pair->p1->pt));
-
-    /* Recompute distance from second point, if first was snapped */
-    ret = _rt_find_closest_segment(ctx, &(pair->p2->pt), pa,
-              &(pair->p2->segno), &(pair->p2->dist));
-    if ( ret < 0 ) return ret; /* error */
-
-  }
-
-  ret = _rt_snap_to_valid_vertex(ctx, pa, pair->p2, state);
-  if ( ret < 0 ) return ret;
-  snapCount += ret;
-
-  if ( ret ) {
-    /* Expand working extent */
-    rtgeom_tpsnap_state_expand_workext_to_include(state,
-      &(pair->p2->pt));
-  }
-
-  return snapCount;
-}
-
 /* @return 0 if no valid snap was found, <0 on error, >0 if snapped */
 static int
-_rt_snap_to_first_valid_pair(const RTCTX *ctx, RTPOINTARRAY *pa,
-  RTT_VPAIR_ARRAY *vplist, rtgeom_tpsnap_state *state)
+_rt_snap_to_first_valid_vertex(const RTCTX *ctx, RTPOINTARRAY *pa,
+  RTT_SNAPV_ARRAY *vset, rtgeom_tpsnap_state *state)
 {
   int foundSnap = 0;
   int i;
 
-  for (i=0; i<vplist->size; ++i)
+  for (i=0; i<vset->size; ++i)
   {
-    RTT_VPAIR *pair = &(vplist->pts[i]);
-    foundSnap = _rt_snap_to_valid_pair(ctx, pa, pair, state);
-    if ( foundSnap ) break;
+    RTT_SNAPV *v = &(vset->pts[i]);
+    foundSnap = _rt_snap_to_valid_vertex(ctx, pa, v, state);
+    if ( foundSnap ) {
+      if ( foundSnap < 0 ) {
+        RTDEBUGF(ctx, 1, "vertex %d/%d triggered an error while snapping",
+          i, vset->size);
+        return -1;
+      }
+      RTDEBUGF(ctx, 1, "vertex %d/%d was a valid snap",
+        i, vset->size);
+      break;
+    }
   }
 
   return foundSnap;
@@ -671,48 +636,40 @@ _rtgeom_tpsnap_ptarray_add(const RTCTX *ctx, RTPOINTARRAY *pa,
 {
   int ret;
   int lookingForSnap = 1;
+
+  RTDEBUG(ctx, 1, "vertices addition phase starts");
   while (lookingForSnap)
   {
     int foundSnap;
     RTT_SNAPV_ARRAY vset;
-    RTT_VPAIR_ARRAY vplist;
 
     lookingForSnap = 0;
     RTT_SNAPV_ARRAY_INIT(ctx, &vset);
-    RTT_VPAIR_ARRAY_INIT(ctx, &vplist);
 
     ret = _rt_find_vertices_within_dist(&vset, pa, state);
     if ( ret < 0 ) {
       RTT_SNAPV_ARRAY_CLEAN(ctx, &vset);
-      RTT_VPAIR_ARRAY_CLEAN(ctx, &vplist);
       return -1;
     }
     RTDEBUGF(ctx, 1, "vertices within dist: %d", vset.size);
-    if ( vset.size < 2 ) {
+    if ( vset.size < 1 ) {
       RTT_SNAPV_ARRAY_CLEAN(ctx, &vset);
-      RTT_VPAIR_ARRAY_CLEAN(ctx, &vplist);
       break;
     }
 
-    ret = _rt_make_sorted_vertices_pairs(ctx, &vset, &vplist);
-    if ( ret < 0 ) {
-      RTT_SNAPV_ARRAY_CLEAN(ctx, &vset);
-      RTT_VPAIR_ARRAY_CLEAN(ctx, &vplist);
-      return -1;
-    }
-    RTDEBUGF(ctx, 1, "vertices pairs: %d", vplist->size);
+    qsort(vset.pts, vset.size, sizeof(RTT_SNAPV), compare_snapv);
 
-    foundSnap = _rt_snap_to_first_valid_pair(ctx, pa, &vplist, state);
+    foundSnap = _rt_snap_to_first_valid_vertex(ctx, pa, &vset, state);
     RTDEBUGF(ctx, 1, "foundSnap: %d", foundSnap);
 
     RTT_SNAPV_ARRAY_CLEAN(ctx, &vset);
-    RTT_VPAIR_ARRAY_CLEAN(ctx, &vplist);
 
     if ( foundSnap < 0 ) return foundSnap; /* error */
     if ( foundSnap && state->iterate ) {
       lookingForSnap = 1;
     }
   }
+  RTDEBUG(ctx, 1, "vertices addition phase ends");
 
   return 0;
 }
@@ -729,14 +686,27 @@ _rtgeom_tpsnap_ptarray(const RTCTX *ctx, RTPOINTARRAY *pa,
   int ret;
   rtgeom_tpsnap_state *state = udata;
 
-  if ( state->remove_vertices )
-  {
-    ret = _rtgeom_tpsnap_ptarray_remove(ctx, pa, state);
-    if ( ret != 0 ) return ret;
-  }
+  /* Set work extent to that of the POINTARRAY bounding box */
+  ptarray_calculate_gbox_cartesian(ctx, pa, &(state->workext));
+  state->expanded_workext = state->workext;
+  gbox_expand(ctx, &(state->expanded_workext), state->tolerance_snap);
 
-  ret = _rtgeom_tpsnap_ptarray_add(ctx, pa, state);
-  return ret;
+  RTDEBUGF(ctx, 1, "Snapping pointarray with %d points", pa->npoints);
+
+  do {
+    ret = _rtgeom_tpsnap_ptarray_add(ctx, pa, state);
+    if ( ret == -1 ) return -1;
+
+    if ( state->tolerance_removal >= 0 )
+    {
+      ret = _rtgeom_tpsnap_ptarray_remove(ctx, pa, state);
+      if ( ret == -1 ) return -1;
+    }
+  } while (ret && state->iterate);
+
+  RTDEBUGF(ctx, 1, "Snapped pointarray has %d points", pa->npoints);
+
+  return 0;
 
 }
 
@@ -744,20 +714,26 @@ _rtgeom_tpsnap_ptarray(const RTCTX *ctx, RTPOINTARRAY *pa,
 /* public, exported */
 RTGEOM *
 rtt_tpsnap(RTT_TOPOLOGY *topo, const RTGEOM *gin,
-                         double tssnap, int iterate, int remove_vertices)
+                         double tolerance_snap,
+                         double tolerance_removal,
+                         int iterate)
 {
   rtgeom_tpsnap_state state;
   const RTCTX *ctx = topo->be_iface->ctx;
   RTGEOM *gtmp = rtgeom_clone_deep(ctx, gin);
   int ret;
 
+  RTDEBUGF(ctx, 1, "snapping: tol %g, iterate %d, remove %d",
+    tolerance_snap, iterate, remove_vertices);
+
   state.topo = topo;
-  state.tssnap = tssnap;
+  state.tolerance_snap = tolerance_snap;
+  state.tolerance_removal = tolerance_removal;
   state.iterate = iterate;
-  state.remove_vertices = remove_vertices;
-  state.workext = *rtgeom_get_bbox(ctx, gin);
   state.workedges = NULL;
 
+  rtgeom_geos_ensure_init(ctx);
+
   ret = rtgeom_visit_lines(ctx, gtmp, _rtgeom_tpsnap_ptarray, &state);
 
   rtgeom_tpsnap_state_destroy(&state);
diff --git a/src/rttin.c b/src/rttin.c
index 961e4e0..4ff97bb 100644
--- a/src/rttin.c
+++ b/src/rttin.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 
 
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rttree.c b/src/rttree.c
index 5ae38dc..ec9c3e4 100644
--- a/src/rttree.c
+++ b/src/rttree.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
  **********************************************************************/
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 #include "rttree.h"
diff --git a/src/rttree.h b/src/rttree.h
index 1b7dc31..6fe86a6 100644
--- a/src/rttree.h
+++ b/src/rttree.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/rttriangle.c b/src/rttriangle.c
index 20950eb..ec65fa8 100644
--- a/src/rttriangle.c
+++ b/src/rttriangle.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 /* basic RTTRIANGLE manipulation */
 
+#include "rttopo_config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/rtutil.c b/src/rtutil.c
index 5137ca1..8fa7f7f 100644
--- a/src/rtutil.c
+++ b/src/rtutil.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,11 +33,13 @@
 #include <string.h>
 #include <ctype.h> /* for tolower */
 
-/* Global variables */
 #include "rttopo_config.h"
+/*#define RTGEOM_DEBUG_LEVEL 4*/
 #include "librttopo_geom_internal.h"
 #include "rtgeom_log.h"
 
+/* Global variables */
+
 /* Default allocators */
 static void * default_allocator(size_t size);
 static void default_freeor(void *mem);
@@ -66,53 +68,6 @@ static char *rtgeomTypeName[] =
 };
 
 /*
- * Default rtnotice/rterror handlers
- *
- * Since variadic functions cannot pass their parameters directly, we need
- * wrappers for these functions to convert the arguments into a va_list
- * structure.
- */
-
-void
-rtnotice(const RTCTX *ctx, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start(ap, fmt);
-
-  /* Call the supplied function */
-  (*ctx->notice_logger)(fmt, ap, ctx->notice_logger_arg);
-
-  va_end(ap);
-}
-
-void
-rterror(const RTCTX *ctx, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start(ap, fmt);
-
-  /* Call the supplied function */
-  (*ctx->error_logger)(fmt, ap, ctx->error_logger_arg);
-
-  va_end(ap);
-}
-
-void
-rtdebug(const RTCTX *ctx, int level, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start(ap, fmt);
-
-  /* Call the supplied function */
-  (*ctx->debug_logger)(level, fmt, ap, ctx->debug_logger_arg);
-
-  va_end(ap);
-}
-
-/*
  * Default allocators
  *
  * We include some default allocators that use malloc/free/realloc
@@ -140,6 +95,14 @@ default_reallocator(void *mem, size_t size)
   return ret;
 }
 
+/*
+ * Default rtnotice/rterror handlers
+ *
+ * Since variadic functions cannot pass their parameters directly, we need
+ * wrappers for these functions to convert the arguments into a va_list
+ * structure.
+ */
+
 static void
 default_noticereporter(const char *fmt, va_list ap, void *arg)
 {
@@ -229,6 +192,47 @@ rtgeom_set_debug_logger(RTCTX *ctx, rtdebuglogger logger, void *arg)
   ctx->debug_logger_arg = arg;
 }
 
+void
+rtnotice(const RTCTX *ctx, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start(ap, fmt);
+
+  /* Call the supplied function */
+  (*ctx->notice_logger)(fmt, ap, ctx->notice_logger_arg);
+
+  va_end(ap);
+}
+
+void
+rterror(const RTCTX *ctx, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start(ap, fmt);
+
+  /* Call the supplied function */
+  (*ctx->error_logger)(fmt, ap, ctx->error_logger_arg);
+
+  va_end(ap);
+}
+
+void
+rtdebug(const RTCTX *ctx, int level, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start(ap, fmt);
+
+  /* Call the supplied function */
+  (*ctx->debug_logger)(level, fmt, ap, ctx->debug_logger_arg);
+
+  va_end(ap);
+}
+
+
+
 const char*
 rttype_name(const RTCTX *ctx, uint8_t type)
 {
diff --git a/src/stringbuffer.c b/src/stringbuffer.c
index 2571815..cafd10c 100644
--- a/src/stringbuffer.c
+++ b/src/stringbuffer.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "librttopo_geom_internal.h"
 #include "stringbuffer.h"
 
diff --git a/src/stringbuffer.h b/src/stringbuffer.h
index 1c1fa8f..bbafaed 100644
--- a/src/stringbuffer.h
+++ b/src/stringbuffer.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/varint.c b/src/varint.c
index dc465a3..185d0f9 100644
--- a/src/varint.c
+++ b/src/varint.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 
 
 
+#include "rttopo_config.h"
 #include "varint.h"
 #include "rtgeom_log.h"
 #include "librttopo_geom.h"
diff --git a/src/varint.h b/src/varint.h
index 1100d6e..4a2eef9 100644
--- a/src/varint.h
+++ b/src/varint.h
@@ -1,7 +1,7 @@
 /**********************************************************************
  *
  * rttopo - topology library
- * http://git.osgeo.org/gogs/rttopo/librttopo
+ * http://git.osgeo.org/gitea/rttopo/librttopo
  *
  * rttopo is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by

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



More information about the Pkg-grass-devel mailing list