-- Get tolerance, if 0 was given
tol := COALESCE( NULLIF(tolerance, 0), topology._st_mintolerance(atopology, apoint) );
- -- 1. Check if any existing node falls within tolerance
+ -- 1. Check if any existing node is closer than the given precision
-- and if so pick the closest
sql := 'SELECT a.node_id FROM '
|| quote_ident(atopology)
|| '.node as a WHERE ST_DWithin(a.geom,'
|| quote_literal(apoint::text) || '::geometry,'
- || tol || ') ORDER BY ST_Distance('
+ || tol || ') AND ST_Distance('
+ || quote_literal(apoint::text)
+ || '::geometry, a.geom) < ' || tol || ' ORDER BY ST_Distance('
|| quote_literal(apoint::text)
|| '::geometry, a.geom) LIMIT 1;';
#ifdef POSTGIS_TOPOLOGY_DEBUG
OR n.end_node > m.max
ORDER BY n.edge_id;
+-- Test precision
+SELECT 'prec1', 'N' || topogeo_addpoint('city_data', 'POINT(39 26)', 2);
+SELECT 'prec2', 'N' || topogeo_addpoint('city_data', 'POINT(39 26)', 1);
+SELECT 'prec3', 'N' || topogeo_addpoint('city_data', 'POINT(36 26)', 1);
+
SELECT DropTopology('city_data');
-- See http://trac.osgeo.org/postgis/ticket/2033
SELECT 'tt2033', 'N' || topogeo_addpoint('t', 'POINT(0.2 1 1)', 0.5);
SELECT 'tt2033', 'NC', node_id, ST_AsText(geom) FROM t.node ORDER BY node_id;
SELECT 'tt2033.end' || DropTopology('t');
+