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

Shaozhong SHI shishaozhong at gmail.com
Thu Dec 2 23:50:49 PST 2021


Hi, Simon,
I think that it is worthwhile to make it work as a function.
Regards, David

On Fri, 3 Dec 2021 at 00:29, Simon G Greener <simon at spatialdbadvisor.com>
wrote:

> Not that I am aware.
>
> You could try wrapping something like the following SQL in a function....
>
> with data as (
>     select 0.01 as tolerance,
>               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) as geom
> )
> select SUM(isDuplicate) as duplicateCount
>   from (select case when
> ST_Distance(ST_PointN(a.geom,b.*),lead(ST_PointN(a.geom,b.*)) over (order
> by b.*)) < a.tolerance
>                     then 1
>                     else 0
>                 end as isDuplicate
>           from data as a,
>                generate_series(1,ST_NumPoints(a.geom),1) as b
>        ) as f;
>
> Note that if the linestring was a compoundCurve repeated vertices are part
> of the definition.
>
> regards
>
> Simon
> On 3/12/2021 9:46 am, Shaozhong SHI wrote:
>
> Is there a generic function to find coincident vertex and count?
>
>
> It will do the following:
>
>
> Create an array of all vertex present in a data set
>
> Iterate over and find out whether there be any coincident vertex as
> defined by a tolerance
>
> Count all occurrences
>
>
> Regards,
>
>
> David
>
> _______________________________________________
> postgis-users mailing listpostgis-users at lists.osgeo.orghttps://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/1c38ce43/attachment.html>


More information about the postgis-users mailing list