1

My problem is that I have lines that I want to lengthen and tied them to a point enter image description here

And in case that I have two line one in continuous and the other is cutted I want only the cutted one to be tied( attached or snaped) to the point and the other to stay at its place.

enter image description here

I've tried this code but in the result the two lines has snapped to the point.

SELECT f.gid as gid, 
   ST_Snap(f.Geom, g.Geom, 2) as geom 
FROM cablen as f,  
    (SELECT ST_Collect(Geom) as Geom FROM boiten) as g

enter image description here

enter image description here

In the last case the line has snapped to the point and become tow so like you see i have three line and in the result i found four ones but I want them to be like this

enter image description here

Update

after editing my code to this ,i Found the result geom Null

SELECT f.gid AS gid,
   ST_Snap(
       ST_StartPoint(f.geom),
       ST_ClosestPoint(g.Geom,  ST_StartPoint(f.geom) ),
       ST_Distance(
           ST_StartPoint(f.geom)  ,
           ST_ClosestPoint(g.Geom, ST_StartPoint(f.geom) )
        ) * 1.2
    ) AS geom
FROM (
   SELECT ST_Collect(Geom) as Geom
   FROM bt_sout
   ) AS g,
   cablen AS f

enter image description here

4
  • So you want only the end points to be snapped, and to keep other vertices in place?
    – JGH
    Commented Jan 25, 2018 at 12:22
  • yes that's exactly what I want ..i've tried to use st_endpoint and st_startpoint but it doesn't work Commented Jan 25, 2018 at 12:29
  • mmh, could you add: do you want them to be snapped (essentially moving parts of the line) or to fill the gap between line and point with a line extension? will there always be one point (the nearest maybe) that each line has to be connected with? and, will it be either the start point or the endpoint, or both?
    – geozelot
    Commented Jan 25, 2018 at 13:28
  • if i use snap the whole line will be snapped at the point and in case the point is not in the extrimite of the line that line will be divised in two and what i really want is just to be attached to the point maybe lenghten it ,, in case where i have a cutted line i want both end point and the start point to be attached to the point (point as the nearest point) Commented Jan 25, 2018 at 13:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.