<html><head></head><body style="zoom: 0%;"><div dir="auto">Works for me.<br></div>
<div dir="auto">That is all i will do.<br></div>
<div dir="auto">Simon<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->39 Cliff View Drive<!-- tmjah_g_1299e --><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Allens Rivulet Tas 7150<!-- tmjah_g_1299e --><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->(W) 0418 396 391<!-- tmjah_g_1299e --></div>
<div class="gmail_quote" >On 3 Dec 2021, at 20:03, Shaozhong SHI <<a href="mailto:shishaozhong@gmail.com" target="_blank">shishaozhong@gmail.com</a>> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">
Hi, Simon,
<div>
<br>
</div>
<div>
That will not work.
</div>
<div>
Try turn p_geometry as an array.
</div>
<div>
Loop over the array and check each element of the array against the rest elements of the array.
</div>
<div>
<br>
</div>
<div>
Regards,
</div>
<div>
<br>
</div>
<div>
David
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">
On Fri, 3 Dec 2021 at 08:48, Simon SPDBA Greener <
<a href="mailto:simon@spdba.com.au">simon@spdba.com.au</a>> wrote:
<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Here is a simple wrapper SQL function.
<br>
<br> It checks that the geometry type is a LineString. Other types could be
<br> supported by extension of the SQL.
<br>
<br> create or replace function STNumDuplicateVertices( p_geometry geometry,
<br> p_tolerance numeric )
<br> returns integer
<br> language sql
<br> as
<br> $$
<br> select SUM(isDuplicate) as duplicateCount
<br> from (select case when
<br> ST_Distance(ST_PointN(p_geometry,b.*),lead(ST_PointN(p_geometry,b.*))
<br> over (order by b.*)) < p_tolerance
<br> then 1
<br> else 0
<br> end as isDuplicate
<br> from generate_series(1,ST_NumPoints(p_geometry),1) as b
<br> where ST_GeometryType(p_geometry) = 'ST_LineString'
<br> ) as f;
<br> $$
<br>
<br> select STNumDuplicateVertices(ST_GeomFromText('LINESTRING(0 0 1.1,1
<br> 1.001 1.2,1 1.0005 1.3,1 1 1.1,2 2 1.2)',0),0.01);
<br> select STNumDuplicateVertices(ST_GeomFromText('POLYGON((0 0,1 0,1 0,1
<br> 1,0 1,0 0))',0),0.01);
<br>
<br> _______________________________________________
<br> postgis-users mailing list
<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>
<br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
<br>
</blockquote>
</div>
<pre class="blue"> <hr><br>postgis-users mailing list<br>postgis-users@lists.osgeo.org<br><a href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br></pre></blockquote></div></body></html>