Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: nogo areas #19

Closed
alecava58 opened this issue Sep 5, 2016 · 24 comments
Closed

Enhancement: nogo areas #19

alecava58 opened this issue Sep 5, 2016 · 24 comments
Assignees

Comments

@alecava58
Copy link

The project is very good but is missing a feature I need (I think):
I'm planning to add a new routing constraint called "nogo areas" to the routing engine, like "brouter.de" does.
One "nogo" area has the following properties:
a center (lat, lon)
a radius in meters
a vale of cost (penalty)
The logic is that the routing engine should avoid, if possible, those areas.
When a calculated path goes through one ore more "nogo" areas the value of cost (penalty) must be added to the cost function.
This means that if there is an alternative, even much longer, the alternative must be preferred.
If the target is inside one "nogo" area the solution is still possible (in this case even if the cost is high there isn't alternative), unless the cost value is a particular value (let say 100000), in this case the "nogo" area is strictly forbidden and the calculation fails.

There is something like that already?
if no
Are you planned to implement something like that?
if no
Do you think that I could implement it?
if yes
Can you give me some info on how could be implemented?

If I decided to proceed are you interested if I make a branch and after you decide if can be merged with the main?

Regards,
Alessandro

@xivk
Copy link
Contributor

xivk commented Sep 8, 2016

Implementation is not planned but it's also not going to be very difficult...

What's the usecase? What are you using this for?

@alecava58
Copy link
Author

alecava58 commented Sep 9, 2016

I'm trying to explain using a simple example.

Take into account that I'm using a routing with heavy vehicle (hgv)
carrying hazardous material
.

Looking at the picture below suppose you have to go from one point to the
other traversing Rome center. The usual track will be as picture (all the
routing engines in the world do this). This is theoretically done (there is
no legal restrictions doing this) but no one driver will do this (unless he
has a bicycle or he is crazy) even by car.

image1

The right path must be as follows

image2

I realize this goal defining a sort of nogo area where traversing should be
avoided.

image3

If the destination point is inside the nogo area than the right path is as
follow:

image4

You should avoid as much as nogo area is possible.

Defining the nogo area as circle is simpler but the best should be having
the nogo area as polygon because this is a simple example but I have many
much complex.

I know that there is a RestrictionsDb but I haven't understood well the
purpose and how to set up.

Do you have some directions on how to achieve this goal.

If you need further info don't hesitate to ask.

Thanks in advance,
Alessandro

2016-09-08 15:55 GMT+02:00 Ben Abelshausen notifications@github.com:

Implementation is not planned but it's also not going to be very
difficult...

What's the usecase? What are you using this for?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtMQeZggYGFSNHuZp2Ou6DSYbvOgqCsks5qoBPigaJpZM4J03O7
.

Alessandro Cavalieri

@xivk
Copy link
Contributor

xivk commented Sep 9, 2016

Normally the routing prioritize large roads over smaller ones just because of the speed profiles. You could build a new profile that does this more aggresively but I have done this already for another project myself. I just add this profile.

If you use (Vehicle).Classified() instead of .Fastest() things should be better already.

@alecava58
Copy link
Author

alecava58 commented Sep 9, 2016 via email

@xivk
Copy link
Contributor

xivk commented Sep 9, 2016

Ok, then I would advise to include this in a separate preprocessing step. Let's say you take polygons of residential areas and for the edges in those areas you add an extra attribute to the edgeprofile (=edge attributes).

Next you adjust your vehicle profile to penalize these edges.

For the winter/summer issue, there are tags for this in OSM:

https://help.openstreetmap.org/questions/23468/how-to-tag-access-restriction-on-snow-and-ice
http://wiki.openstreetmap.org/wiki/Key:access

Itinero doesn't support these by default, but it's possible to do so.

@xivk
Copy link
Contributor

xivk commented Sep 9, 2016

Oh, and I would be open to including this by default now... I can see other usecases for this feature too.

@alecava58
Copy link
Author

"Ok, then I would advise to include this in a separate preprocessing step.
Let's say you take polygons of residential areas and for the edges in those
areas you add an extra attribute to the edgeprofile (=edge attributes)."

this means that when I add or change those areas I need to rebuild the
RouterDB?

2016-09-09 13:24 GMT+02:00 Ben Abelshausen notifications@github.com:

Ok, then I would advise to include this in a separate preprocessing step.
Let's say you take polygons of residential areas and for the edges in those
areas you add an extra attribute to the edgeprofile (=edge attributes).

Next you adjust your vehicle profile to penalize these edges.

For the winter/summer issue, there are tags for this in OSM:

https://help.openstreetmap.org/questions/23468/how-to-
tag-access-restriction-on-snow-and-ice
http://wiki.openstreetmap.org/wiki/Key:access

Itinero doesn't support these by default, but it's possible to do so.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtMQWM3jVqCf1vSjo7iUsgSwVDfdLEcks5qoUHQgaJpZM4J03O7
.

Alessandro Cavalieri

@alecava58
Copy link
Author

You told me to use edge attributes but at first sight RestrictionDb seems to be the for this purpose, am I wrong?

@xivk
Copy link
Contributor

xivk commented Sep 12, 2016

I would get all edges within the area and mark them with an extra attribute, then build a vehicle profile that can handle this. This way you can use all the existing optimizations for fast routing.

The restrictions db is for turn-restrictions.

@alecava58
Copy link
Author

Ok. I agree.

I'll study how to collect all the adges within an area, and what is the processing step where I can insert this logic.

@xivk
Copy link
Contributor

xivk commented Sep 12, 2016

You can use this to get all vertices in a boundingbox for example:

https://github.com/itinero/routing/blob/develop/src/Itinero/Algorithms/Search/Hilbert/HilbertExtensions.cs#L165

A GeometricGraph is found by using RouterDb.Network.GeometricGraph if I'm right.

@alecava58
Copy link
Author

Ok. thanks for the suggestion.

I'm taking a look at the CycleNetworkProcessor function as an example.

2016-09-12 17:27 GMT+02:00 Ben Abelshausen notifications@github.com:

You can use this to get all vertices in a boundingbox for example:

https://github.com/itinero/routing/blob/develop/src/
Itinero/Algorithms/Search/Hilbert/HilbertExtensions.cs#L165

A GeometricGraph is found by using RouterDb.Network.GeometricGraph if I'm
right.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtMQXqU7860qGSunZJXtWe2URZBa6eiks5qpW9hgaJpZM4J03O7
.

Alessandro Cavalieri

@xivk
Copy link
Contributor

xivk commented Sep 12, 2016

Ah that's a good option also... I did not consider doing this during OSM preprocessing...

Only a good option if you are sure you will only use OSM-data.

@alecava58
Copy link
Author

Yes I use only OSM-data.

I'm trying to figure out if is better to add the extra tag to nodes or
ways. If I would measly know (during my custom ITwoPassProcessor) if a way
is inside my nogo area bounding box (even partially) I think it would be
better to add the extra tag to the way.

2016-09-12 18:09 GMT+02:00 Ben Abelshausen notifications@github.com:

Ah that's a good option also... I did not consider doing this during OSM
preprocessing...

Only a good option if you are sure you will only use OSM-data.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtMQYOIy9vPtZF4QP8cGjBlDijPO4Ghks5qpXktgaJpZM4J03O7
.

Alessandro Cavalieri

@xivk
Copy link
Contributor

xivk commented Sep 14, 2016

Just to let you know, I'm putting this on the roadmap as one of the first features to be implemented for Itinero 2.0 once Itinero 1.0 is released (for 1.0, there is a feature stop, otherwise there will never be a release) but more in the line of speed restrictions based on areas:

  • Specifiy polygons describing speed limited areas.
  • Add this data to an already existing routerdb (independent of the source data being OSM or something else).
  • Document options to take this into account in the vehicle profiles.
  • Implement this by default in the existing OSM-based profiles.

@xivk xivk self-assigned this Sep 14, 2016
@alecava58
Copy link
Author

This is a good news, but I have to find a solution asap.
I think I'll try to do something with ITwoPassProcessor.

@alecava58
Copy link
Author

I'm try to implement the TwoPassProcessor class for my nogo area problem.
I took CycleNetworkProcessor as example. But when I try to build a routerdb with this processor, and a vehicle contracted db, I always have an out of memory error.
I use a EC2 r3_2xl machine that is a 8 core 64gb ram.
If I don't use a processor averything is fine.

@alecava58
Copy link
Author

Hi Ben,
If you can I'd need a little help writing the TwoPassProcessor.
Starting from The CycleNetworkProcessor I'm trying to write the following functions, but I don't know how to:

  • get the Node Latitute and Longitude having the NodeId
  • write the function _isInside
  • pass the nogo Cost to the function AddTags

A little help is appreciate

I have a list of:

   public class Nogo
    {
        public float Latitude;
        public float Longitude;
        public float Radius; //meters
        public float Cost;
    }

    IList<Nogo> nogos;


  private static Func<Way, bool> IsRelevant = (w) =>
    {
        foreach (var n in w.Nodes)
            foreach (var nogo in nogos)
                // if one of the Node of the Way is inside one nogo area  I must add the tag to that way with the cost
                // of the nogo area
                if (_isInside(n, nogo.Latitude, nogo.Longitude, nogo.Radius)) // how to calculate?
                    return true;
        return false;
    };

    private static Action<Way, TagsCollectionBase> AddTags = (w, t) =>
    {
        w.Tags.AddOrReplace("nogo", nogo.Cost.ToInvariantString());  // how to pass the nogo Cost?
    };

@xivk
Copy link
Contributor

xivk commented Nov 9, 2016

@alecava58 Can you give a bit more context around this code... Are you trying to add extra tags to ways inside the nogo areas?

@alecava58
Copy link
Author

Yes. Right. The extra tag should be used in a custom profile.
This is the easiest way I found but if you have a better idea........

-- Alessandro

Il 09 nov 2016 2:12 PM, "Ben Abelshausen" notifications@github.com ha
scritto:

@alecava58 https://github.com/alecava58 Can you give a bit more context
around this code... Are you trying to add extra tags to ways inside the
nogo areas?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtMQafELK8KtEe75VCoaaJ_MhZ-j2Laks5q8cXggaJpZM4J03O7
.

@alecava58
Copy link
Author

This is what I'm trying to do:
first pass select the node that are inside a nogo, second pass attach a new tag to the way that contains one ore more node.
DbManagement.zip

is that right?

@alecava58
Copy link
Author

It works. It seems to be ok.

I have to disable tags normalization and add the following to the vehicle profile:

`

     /// <summary>
    /// Returns true if the given key is relevant.
    /// </summary>
    public override bool IsRelevant(string key)
    {
        if (base.IsRelevant(key))
        {
            return true;
        }

        if (key.StartsWith("hazmat") || key.StartsWith("nogo"))
        { // include hazmat and nogo tags.
            return true;
        }
        return false;
    }

`

Is there a better way to achieve this without disable tag normalization?
could I add a relevant tag to the vehicle profile?

Thanks in advance.

@xivk
Copy link
Contributor

xivk commented Dec 19, 2016

In the latest version, with the lua profiles you can do this by adding the tags to the profile-whitelist. They shouldn't be deleted, even when using normalization...

Closing this issue, the no-go area feature in now on the roadmap and I consider the any new issue as issues related to the vehicle profiles and lua.

Feel free to reopen, or file a new issue about the lua profiles... 👍

@xivk xivk closed this as completed Dec 19, 2016
@alecava58
Copy link
Author

alecava58 commented Dec 19, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants