[pgrouting-users] SQL Code for Barriers in Routing

Vicky Vergara vicky at georepublic.de
Tue Feb 11 06:22:34 PST 2020


Hello Jeremiah
suppose the following line segment where 2 is a barrier
+------+------+
1        2       3
Add an extra node
+------<>------+
1        2       3
          4

s= source
t = target
c = cost
rc = reverse cost
b = barrier

The table needed when barrier is open is
s t   c  rc b
1 2  1 1   f
2 4  0 0   t
4 3  1 1   f

The table needed when barrier is close is
s t   c  rc b
1 2  1  1  f
4 3  1  1  f
so you need an if statement (pseudocode of what the edges would be)
if  barrier is open then
SELECT * FROM edge_table
else
SELECT * FROM edge_table WHERE  b = false

Note that, for (most) pgRouting algorithms the geometries are irrelevant.
The process "add extra node" might require geometry operations, that is
done with PostGIS.

regards




On Mon, Feb 10, 2020 at 9:12 AM Stephen Woodbridge <
stephenwoodbridge37 at gmail.com> wrote:

> 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
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/pgrouting-users



-- 

Georepublic UG (haftungsbeschränkt)
Salzmannstraße 44,
81739 München, Germany

Vicky Vergara
Operations Research

eMail: vicky at georepublic.de
Web: https://georepublic.info

Tel: +49 (089) 4161 7698-1
Fax: +49 (089) 4161 7698-9

Commercial register: Amtsgericht München, HRB 181428
CEO: Daniel Kastl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20200211/f08466f2/attachment.html>


More information about the Pgrouting-users mailing list