[postgis-users] Is there a generic function to find coincident vertex?

Simon Greener simon at spdba.com.au
Fri Dec 3 03:15:14 PST 2021


Works for me.
That is all i will do.
Simon

⁣39 Cliff View Drive
Allens Rivulet Tas 7150
(W) 0418 396 391​

On 3 Dec 2021, 20:03, at 20:03, Shaozhong SHI <shishaozhong at gmail.com> wrote:
>Hi, Simon,
>
>That will not work.
>Try turn p_geometry as an array.
>Loop over the array and check each element of the array against the
>rest
>elements of the array.
>
>Regards,
>
>David
>
>On Fri, 3 Dec 2021 at 08:48, Simon SPDBA Greener <simon at spdba.com.au>
>wrote:
>
>> Here is a simple wrapper SQL function.
>>
>> It checks that the geometry type is a LineString. Other types could
>be
>> supported by extension of the SQL.
>>
>> create or replace function STNumDuplicateVertices( p_geometry
>geometry,
>> p_tolerance numeric )
>> returns integer
>> language sql
>> as
>> $$
>> select SUM(isDuplicate) as duplicateCount
>>    from (select case when
>> ST_Distance(ST_PointN(p_geometry,b.*),lead(ST_PointN(p_geometry,b.*))
>> over (order by b.*)) < p_tolerance
>>                      then 1
>>                      else 0
>>                  end as isDuplicate
>>            from generate_series(1,ST_NumPoints(p_geometry),1) as b
>>          where ST_GeometryType(p_geometry) = 'ST_LineString'
>>         ) as f;
>> $$
>>
>> select STNumDuplicateVertices(ST_GeomFromText('LINESTRING(0 0 1.1,1
>> 1.001 1.2,1 1.0005 1.3,1 1 1.1,2 2 1.2)',0),0.01);
>> select STNumDuplicateVertices(ST_GeomFromText('POLYGON((0 0,1 0,1 0,1
>> 1,0 1,0 0))',0),0.01);
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>postgis-users mailing list
>postgis-users at lists.osgeo.org
>https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211203/aaeee0fb/attachment.html>


More information about the postgis-users mailing list