<div dir="ltr">Hey fellow postgis users,<div>I ran into some precision issue.<br>(I use latest postgis/postgres/geos release on a ubuntu 12.0.4 :</div><div>postgis_full_version</div><div>POSTGIS="2.1.0 r11822" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.8.0" TOPOLOGY (topology procs from "2.0.3 r11128" need upgrade) RASTER ).<br>
<br><b>I would appreciate expert answers on this as precision issued introduce</b><b> (silently) </b><b>very incoherent results. </b></div><div><br><br>During a geometry processing, I project a point on a line using the ST_CLosestPoint() function.<br>
<br>The issue are </div><div>_the projected point is at a residual distance of 2 x 10^-9 meters of the line</div><div>_the projected point is not related to the line (ST_Relate FF*FF****)</div><div>_snapping the point to the line does nothing</div>
<div>_snapping the line to the point moves the line (and they relate : 0F*FF****).</div><div><div><br></div>So it appears to me that : </div><div><ul><li>if spatial testing is more precise than 10^-9, ST_ClosestPoint() should return something more precise than this<br>
</li><ul><li>(in the above example, a point projected on a  line is disjoint from this line)</li></ul><li>ST_Snap() does nothing when snapping point on line with a vastly sufficient tolerance, but snapping the line to the point moves the line. This is at best incoherent.</li>
</ul><div></div></div><div><br></div><div>It seems to be not related to size of coordinates (650880,X being the limit for a float)</div><div><br></div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><div>WITH the_geom AS (</div><div><span class="" style="white-space:pre">                                </span>SELECT ST_GeomFromText('MULTILINESTRING((651006 6860741.8,650880.2 6860649.4,650872.7 6860644.9))', 931008) AS the_line</div>
<div><span class="" style="white-space:pre">                            </span>, ST_GeomFromText('POINT(650996.890345122 6860735.10896573)', 931008) AS the_point</div><div><span class="" style="white-space:pre">                 </span>),</div><div><span class="" style="white-space:pre">                 </span>the_geom_plus AS (</div>
<div><span class="" style="white-space:pre">                            </span>SELECT the_line, the_point, </div><div><span class="" style="white-space:pre">                              </span>ST_Snap(the_point,the_line,0.1) AS the_snapped_point,</div><div><span class="" style="white-space:pre">                              </span>ST_Snap(the_line,the_point,0.1) AS the_snapped_line</div>
<div><span class="" style="white-space:pre">                            </span>FROM the_geom</div><div><span class="" style="white-space:pre">                      </span>)</div><div><span class="" style="white-space:pre">                  </span>SELECT ST_Distance(the_point,the_line) AS distance_between_point_and_line,</div>
<div><span class="" style="white-space:pre">                            </span>ST_Distance(the_snapped_point,the_line) AS distance_between_point_snapped_and_line,</div><div><span class="" style="white-space:pre">                                </span>ST_Distance(the_line, ST_ClosestPoint(the_line,the_point) ) distance_with_closest_point,</div>
<div><span class="" style="white-space:pre">                            </span>ST_Distance(the_point, the_snapped_line) AS distance_betweenpoint_and_snapped_line,</div><div><span class="" style="white-space:pre">                                </span>ST_Disjoint(the_point,the_line) are_they_disjoint,</div>
<div><span class="" style="white-space:pre">                            </span>ST_Relate(the_point,the_line) relation_between_point_and_line,</div><div><span class="" style="white-space:pre">                             </span>ST_Relate(the_snapped_point,the_line) relation_between_snapped_point_and_line,</div>
<div><span class="" style="white-space:pre">                            </span>ST_Relate(the_snapped_point,the_snapped_line) relation_between_snapped_point_and_snapped_line,</div><div><span class="" style="white-space:pre">                             </span>ST_Intersects(the_point,the_line) do_they_intersect,</div>
<div><span class="" style="white-space:pre">                            </span>ST_Touches(the_point,the_line) do_they_touch,</div><div><span class="" style="white-space:pre">                              </span>ST_Within(the_point,the_line) is_the_point_within_the_line</div>
<div><span class="" style="white-space:pre">                    </span>FROM the_geom_plus</div></div><div><br></div><div><br></div><div><img src="cid:ii_1419d7b665aa2668" alt="Images intégrées 1" width="565" height="21"><br></div></blockquote>
</div>