<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi, i'm a postgis beginner, too, but i
think i see the problem, if not the exact solution:<br>
<br>
Point 27 is the <i>first </i>point that postgis found that
matched your search-and-snap criteria, not the <i>best</i>
(closest) point.<br>
<br>
You need to somehow get all the candidate points (ones that match
the criteria), sort (order by) by distance, and use the first one.<br>
Easier said than done maybe, but that's my guess...<br>
<br>
<pre class="moz-signature" cols="72">Martin Feuchtwanger <a class="moz-txt-link-abbreviated" href="mailto:feumar@shaw.ca">feumar@shaw.ca</a> 604-254-0361
302 - 1429 E 4th Ave, Vancouver, BC V5N 1J6
<a class="moz-txt-link-freetext" href="http://members.shaw.ca/geomatics.developer">http://members.shaw.ca/geomatics.developer</a>
</pre>
On 21/11/2012 1:50 PM, Guillaume Drolet wrote:<br>
</div>
<blockquote
cite="mid:CAOkiyv7LfW1yJQCN0ZqPDwik15GwUA-vJK26ry_qH2F1B7oRvw@mail.gmail.com"
type="cite">Hi Nicolas,<br>
<br>
I didn't quite follow the tips in the "Closing Coutour" thread but
got some inspiration from it (I think it's a bit complicated for
my PostGIS level).<br>
<br>
I can now snap lines but some of them (see attached file) don't
snap at the right place. In the attached image, I want the last
point of the line in the southern area (the un-numbered point
closest to the north area in grey) to snap to point 26.
Unfortunately, it is point 27 that snapped to 26. The second image
shows another case where the snap didn't do as I expected (multi
snaps on the same line..). In some other cases however, it did
work alright.<br>
<br>
I'm sure this has to do with the conditions in my query below but
I don't understand what. Maybe you have some clues about it?<br>
<br>
DROP TABLE IF EXISTS hydrology.snappedlines;<br>
SELECT b.gid, ST_Snap(a.geom_intersections, b.geom_intersections,
50) geom<br>
INTO TABLE hydrology.snappedlines<br>
FROM hydrology.nhn_coursdeau_merge_test a, -- lines in the north
area<br>
hydrology.bdtq_20k_hydro_lo_merge_test b, -- lines in the
south area<br>
hydrology.test_north c, -- north area polygon<br>
hydrology.test_south d -- south area polygon<br>
WHERE ST_DWithin(a.geom_intersections, b.geom_intersections, 50)
-- units in meters<br>
AND ST_DWithin(a.geom_intersections, c.geom, 0.001) <br>
AND ST_DWithin(a.geom_intersections, d.geom, 0.001)<br>
AND ST_DWithin(b.geom_intersections, c.geom, 0.001)<br>
AND ST_DWithin(b.geom_intersections, d.geom, 0.001);<br>
<br>
Thanks for helping,<br>
<br>
Guillaume
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a>
</pre>
</blockquote>
<br>
</body>
</html>