1
1
Fork 0

Change semantic of value 0 for tolerance parameter

Let 0 really mean 0, use -1 to mean "automatically determine"
master
Sandro Santilli 2016-09-06 11:11:57 +02:00
parent d66c984293
commit e66a403a48
3 changed files with 17 additions and 10 deletions

View File

@ -1,6 +1,13 @@
Release 1.1.0-dev
YYYY-MM-DD
* Important / Breaking Changes *
- Support for tolerance/precision=0 added, -1 is the new value
for automatic computation of minimal tolerance.
* New Features *
Release 1.0.0
2016-05-19

View File

@ -1034,7 +1034,7 @@ RTT_ELEMID rtt_GetFaceByPoint(RTT_TOPOLOGY *topo, RTPOINT *pt, double tol);
*
* @param topo the topology to operate on
* @param point the point to add
* @param tol snap tolerance, the topology tolerance will be used if 0
* @param tol snap tolerance, the topology tolerance will be used if -1
*
* @return identifier of added (or pre-existing) node or -1 on error
* (librtgeom error handler will be invoked with error message)
@ -1049,7 +1049,7 @@ RTT_ELEMID rtt_AddPoint(RTT_TOPOLOGY* topo, RTPOINT* point, double tol);
*
* @param topo the topology to operate on
* @param line the line to add
* @param tol snap tolerance, the topology tolerance will be used if 0
* @param tol snap tolerance, the topology tolerance will be used if -1
* @param nedges output parameter, will be set to number of edges the
* line was split into, or -1 on error
* (librtgeom error handler will be invoked with error message)
@ -1071,7 +1071,7 @@ RTT_ELEMID* rtt_AddLine(RTT_TOPOLOGY* topo, RTLINE* line, double tol,
*
* @param topo the topology to operate on
* @param poly the polygon to add
* @param tol snap tolerance, the topology tolerance will be used if 0
* @param tol snap tolerance, the topology tolerance will be used if -1
* @param nfaces output parameter, will be set to number of faces the
* polygon was split into, or -1 on error
* (librtgeom error handler will be invoked with error message)

View File

@ -5028,7 +5028,7 @@ _rtt_minTolerance(const RTCTX *ctx, RTGEOM *g )
}
#define _RTT_MINTOLERANCE( topo, geom ) ( \
topo->precision ? topo->precision : _rtt_minTolerance(topo->be_iface->ctx, geom) )
topo->precision >= 0 ? topo->precision : _rtt_minTolerance(topo->be_iface->ctx, geom) )
typedef struct scored_pointer_t {
void *ptr;
@ -5061,8 +5061,8 @@ rtt_AddPoint(RTT_TOPOLOGY* topo, RTPOINT* point, double tol)
RTT_ELEMID id = 0;
scored_pointer *sorted;
/* Get tolerance, if 0 was given */
if ( ! tol ) tol = _RTT_MINTOLERANCE( topo, pt );
/* Get tolerance, if -1 was given */
if ( tol == -1 ) tol = _RTT_MINTOLERANCE( topo, pt );
RTDEBUGG(1, pt, "Adding point");
@ -5667,8 +5667,8 @@ rtt_AddLine(RTT_TOPOLOGY* topo, RTLINE* line, double tol, int* nedges)
*nedges = -1; /* error condition, by default */
/* Get tolerance, if 0 was given */
if ( ! tol ) tol = _RTT_MINTOLERANCE( topo, (RTGEOM*)line );
/* Get tolerance, if -1 was given */
if ( tol == -1 ) tol = _RTT_MINTOLERANCE( topo, (RTGEOM*)line );
RTDEBUGF(1, "Working tolerance:%.15g", tol);
RTDEBUGF(1, "Input line has srid=%d", line->srid);
@ -5916,8 +5916,8 @@ rtt_AddPolygon(RTT_TOPOLOGY* topo, RTPOLY* poly, double tol, int* nfaces)
const GEOSPreparedGeometry *ppoly;
GEOSGeometry *polyg;
/* Get tolerance, if 0 was given */
if ( ! tol ) tol = _RTT_MINTOLERANCE( topo, (RTGEOM*)poly );
/* Get tolerance, if -1 was given */
if ( tol == -1 ) tol = _RTT_MINTOLERANCE( topo, (RTGEOM*)poly );
RTDEBUGF(1, "Working tolerance:%.15g", tol);
/* Add each ring as an edge */