3

I am using pgRouting to get shortest route. Now I want to get point that comes in buffer of 5km along router. Point is other shapefile. Route is using road shape so any one give me idea for same.

nmtoken
  • 13,355
  • 5
  • 38
  • 87
Pari
  • 61
  • 1
  • 3
  • 1
    Are you asking how to get a buffer around the LINESTRING from the result of your shortest route query? Please consider clarifying your question. – Steve Horn Mar 09 '12 at 16:24
  • NO i am asking how to get all places(i.e point shapefile in postgres) that comes in buffer of road(which is other shape file. So i wnat postgres query for same – Pari Mar 10 '12 at 06:57
  • @ Steve Horn may I know the answer for your words in the comment? because I am in stuck with that problem. – Karthik Jun 12 '19 at 08:18

1 Answers1

1

Pseudocode:

SELECT * 
FROM points_table pt
WHERE ST_Intersects(pt.the_geom, SELECT ST_Buffer(ST_Union(w.the_geom), 5000)
                    FROM shortest_path('
                        SELECT gid as id,
                             source::integer,
                             target::integer,
                             length::double precision as cost
                            FROM ways',
                        5700, 6733, false, false) sp
                    INNER JOIN ways w
                        ON w.gid = sp.edge_id);
  • Use PostGIS ST_Union to get a LINESTRING which represents each of the line segments combined to get your route.
  • ST_Buffer will buffer the linestring 5km.
  • ST_Intersects retrieves all the points within the buffered zone.
Steve Horn
  • 728
  • 2
  • 7
  • 12