<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Thanks for sharing this! Such a great example of collaboration.
You are all amazing.<br>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Date: Wed, 5 Aug 2020 10:09:14 -0700
From: Martin Davis <a class="moz-txt-link-rfc2396E" href="mailto:mtnclimb@gmail.com"><mtnclimb@gmail.com></a>
To: PostGIS Users Discussion <a class="moz-txt-link-rfc2396E" href="mailto:postgis-users@lists.osgeo.org"><postgis-users@lists.osgeo.org></a>
Subject: Re: [postgis-users] Find LineString segment index containing
closest point?
Message-ID:
<a class="moz-txt-link-rfc2396E" href="mailto:CAK2ens38O2ng2CR2gevM-LM6HGAzq1S8eQO3dsJ9pBjM2msrJQ@mail.gmail.com"><CAK2ens38O2ng2CR2gevM-LM6HGAzq1S8eQO3dsJ9pBjM2msrJQ@mail.gmail.com></a>
Content-Type: text/plain; charset="utf-8"
On Wed, Aug 5, 2020 at 9:38 AM Martin Davis <a class="moz-txt-link-rfc2396E" href="mailto:mtnclimb@gmail.com"><mtnclimb@gmail.com></a> wrote:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre class="moz-quote-pre" wrap="">Added to the wiki:
<a class="moz-txt-link-freetext" href="https://trac.osgeo.org/postgis/wiki/UsersWikiLinearRefFunctions">https://trac.osgeo.org/postgis/wiki/UsersWikiLinearRefFunctions</a>
It seems a bit awkward to use this as it stands for inserting a vertex in
a line at the closest point. I wonder if the function should also return
the closest point itself? (In fact, I am certain that it should if it is
implemented as a native function, since that additional useful information
costs very little to obtain).
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">And done... updated the wiki with a new version of the function which
returns the index, distance and computed point on line. Here it is in
action, used for adding a vertex to a line:
WITH data(id, line) AS (VALUES
( 1, 'LINESTRING (0 0, 10 10, 20 20, 30 30)'::geometry )
),
loc AS (
SELECT id, line, index, geom AS pt
FROM data
JOIN LATERAL ST_LineLocateSegment( data.line, 'POINT(15
15.1)'::geometry ) AS lls ON true
)
SELECT id, ST_AsText( ST_AddPoint( line, pt, index ) )
FROM loc;
Note this is probably better done using ST_Snap, but sometimes it's useful
to do things in a more explicit way.</pre>
</blockquote>
-- <br>
</p>
<div class="moz-signature">
<hr>Phil Hurvitz, Research Scientist, <a
href="https://csde.washington.edu/">CSDE</a>, <a
href="sites.uw.edu/ufl">UFL</a><br>
<a href="http://gis.washington.edu/phurvitz/contact">Contact
information</a><br>
<a href="http://staff.washington.edu/phurvitz/calendar">Calendar</a><br>
<br>
<br>
</div>
</body>
</html>