Re: [postgis-users] help with a query

2016-09-27 Thread Birgit Laggner
Hi Jonatan, I am glad I could help. Have success with the tweaking! Regards, Birgit Am 26.09.2016 um 14:24 schrieb Jonatan Malaver: Hi Birgit, thank you so much!! your code put me on the right track. I'm still tweaking it a bit since your code assumes only 1 line is attached to the endpoint. Ho

Re: [postgis-users] help with a query

2016-09-26 Thread Jonatan Malaver
Hi Birgit, thank you so much!! your code put me on the right track. I'm still tweaking it a bit since your code assumes only 1 line is attached to the endpoint. However, the endpoint of one line could break into 2 new starpoints. thanks, jon On Tue, Sep 20, 2016 at 5:38 AM Birgit Laggner wrote:

Re: [postgis-users] help with a query

2016-09-20 Thread Birgit Laggner
Hi Jonatan, based on the anonymous code block Leknín came up with, I tried to adapt it to your problem: DO $$ DECLARE c_line record; c_gid integer; c_geom geometry; line record; gid integer; geom geometry; i integer; n integer; BEGIN EXECUTE 'SELECT count(*) FROM electric_line' INTO n; --i

Re: [postgis-users] help with a query

2016-09-14 Thread Jonatan Malaver
Hello again, I do not have parent line id. All I have is a starting point from where the direction should reference. On Wed, Sep 14, 2016 at 9:09 AM Leknín Řepánek wrote: > On Wed, Sep 14, 2016 at 12:09:23PM +, Jonatan Malaver wrote: > > the reason being is that I do a network analysis by ru

Re: [postgis-users] help with a query

2016-09-14 Thread Leknín Řepánek
On Wed, Sep 14, 2016 at 12:09:23PM +, Jonatan Malaver wrote: > the reason being is that I do a network analysis by running the following > function: > WITH RECURSIVE flow(gid, geom) AS ( >     SELECT e.gid, e.geom FROM electric_line e, transformers t WHERE > ST_Distance > (t.geom,ST_StartPoint

Re: [postgis-users] help with a query

2016-09-14 Thread Jonatan Malaver
the reason being is that I do a network analysis by running the following function: WITH RECURSIVE flow(gid, geom) AS ( SELECT e.gid, e.geom FROM electric_line e, transformers t WHERE ST_Distance(t.geom,ST_StartPoint(e.geom)) <= 0.01 AND t.gid=$1 UNION ALL SELECT n.gid, n.geom FROM el

Re: [postgis-users] help with a query

2016-09-13 Thread James Keener
Depends on what you mean by direction. If you want to grab the start and end points (st_startpoint and st_endpoint) and check their x and y (st_x and st_y) for some condition (both less at the end?) Then update the record with the value of st_reverse. I guess my other question is why it matters

Re: [postgis-users] help with a query

2016-09-13 Thread Jonatan Malaver
This is the query I have so far: WITH RECURSIVE flow(gid, geom) AS ( SELECT e.gid, e.geom FROM electric_line e WHERE e.gid = 3312 UNION ALL SELECT n.gid, n.geom FROM electric_line n, flow f WHERE ST_DWithin(ST_EndPoint(f.geom),ST_StartPoint(n.geom),0.01) ) UPDATE electric_line S

Re: [postgis-users] help with a query

2016-09-13 Thread Leknín Řepánek
ST_EndPoint, ST_StartPoint, ST_Reverse. On Tue, Sep 13, 2016 at 12:31:07PM +, Jonatan Malaver wrote: > Hello, > >    I'm trying to come up with a query that would check the direction of a > line. > If the end point is not the start point of the next line to update the line by > reversing tha

[postgis-users] help with a query

2016-09-13 Thread Jonatan Malaver
Hello, I'm trying to come up with a query that would check the direction of a line. If the end point is not the start point of the next line to update the line by reversing that line. Can anyone give me pointers on how to do it? Thanks, Jon ___ postg