[pgrouting-users] SQL Code for Barriers in Routing

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Mon Feb 10 07:12:10 PST 2020


On 2/10/2020 9:53 AM, Feranmi Jeremiah Olowe wrote:
>
> Dear Sir,
>
> I hope this mail meets you well. My name is Jeremiah, a master’s 
> student in Universidade NOVA de Lisboa, Information Management 
> School(IMS) currently enrolled in Geospatial Technologies.  I came 
> across your guidance on PGrouting for barriers, which has led me to 
> seek your assistance and tutelage on how to solve this kind of problem 
> for my project.
>
> We are trying to find a way on how we can generate an SQL code to make 
> our routing network recognize barriers based on the fact that we have 
> uploaded the network with source, target, cost , reverse cost, 
> coordinate field or column. We are hoping you can give us ideas on the 
> algorithm that can help us make the network recognize barriers. Thank 
> you Sir for your time and anticipated response.
>
> Best Regards,
>
> Jeremiah.
>
Hi Jeremiah,

I recommend you contacting the

pgrouting-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users

for questions on prgrouting as there are lots of experts there and 
responses will help other users with same or similar issues.

To your question, barriers are just breaks in the network if you have 
two road segments like AA and BB and a barrier (B):

o-----AA------o(B)o-----BB-------o

So if you remove the segments touching AA and BB then that effectively 
prevents routing though the barriers.

If you have a network in say a "roads" table and your barriers in a 
"barriers" then the sql would be something like:

Select r.*
  from roads r, barriers b
where not r.geom && st_expand(b.geom, tol);

set the value of tol to a small number relative to the size of the road 
segments to enlarge the bbox of the barrier point in intersect with the 
road segments.

Other people might have other ideas. For example if each barrier point 
coincides with an edge vertex, you could assign vertex id to the barrier 
point and then use a where statements like:

where b.vertexid not in (r.source, r.target)

-Steve


More information about the Pgrouting-users mailing list