[GraphHopper] How to consider traffic jam when route on road net
Alexander Cherepanov
lanmaster at hotmail.ru
Fri Jan 10 06:37:30 UTC 2014
Hello, Peter!
Thank you very much!
I was try and it is ok.
Let me show for others people some code for example:
// somewhere in main() method (for example)
CmdArgs args1 = CmdArgs.readFromConfig("Cfg/Graphhopper.cfg", "graphhopper.config");
GraphHopper gh = new GraphHopperJam().forServer().init(args1);
gh.setEncodingManager(new EncodingManager("CAR"));
gh.importOrLoad();
GHRequest request = new GHRequest(56.833703,60.687447,56.777473,60.623331);
// there is our own weighting method selection
request.setWeighting("fastestjam"); // look here
GHResponse response = gh.route(request);
double res = response.getDistance();
// GraphHopperJam.java
public class GraphHopperJam extends GraphHopper {
protected Weighting createWeighting( String weighting, FlagEncoder encoder )
{
// ignore case
weighting = weighting.toLowerCase();
if ("shortest".equals(weighting))
return new ShortestWeighting();
if ("fastestjam".equals(weighting)) // look here, it is added for selectable our weighting class
return new FastestJamWeighting(); // our weighting class
return new FastestWeighting(encoder);
}
}
// FastestJamWeighting.java
public class FastestJamWeighting implements Weighting {
@Override
public double getMinWeight(double distance) {
return distance;
}
@Override
public double calcWeight(EdgeIteratorState edgeIter) {
return edgeIter.getDistance(); // It will be changed for our weight algorithm
}
@Override
public double revertWeight(EdgeIteratorState iter, double weight) {
return weight;
}
@Override
public String toString() {
return "FASTESTJAM|";
}
}
Чтв 09 Янв 2014 16:23:52 +0600, Peter K написал:
Hey,
if you don't use maven you'll have to add the dependencies
explicitely. If you use maven it will download the dependencies
you need and include it automatically into your project. IntelliJ
and NetBeans are good in handling maven projects.
> but it would be very nice if we can use Graphhopper as
library and extends
> or implements some classes/methods for our purposes (instead
overwrite the Weighting)
with 'overwrite' I meant extending and 'overloading' the method.
No need to change the sources for this.
Regards,
Peter.
Hello again!
Also it is hard to reuse source code...
I get 0.2 version, unpack folder
"\graphhopper-0.2\core\src\main\java\com\graphhopper\" to my
IntelliJ IDEA's project folder \project\src\com\graphhopper\
and I get import error in "InstructionList.java":
import gnu.trove.list.TDoubleList;
Where to get that code?
Why don't you include that sources to your project?
Пнд 06 Янв 2014 18:22:46 +0600, Peter K
написал:
Hi,
indeed: if you are updating the edges in real time you won't
be able to use CH or you will have to prepare the graph again
which is not real-time but okayish for country-sized data like
Germany ( how to set this bitmask because I couldn't find any
documentation on to flags itself.
Yes, again as Nicolas said (thanks btw :) !) there is no
documentation but you can see the CarFlagEncoder class and its
unit tests. Mainly the first two bits specifies the access
(forward?, backward?) and then the speed as integer (but with
low resolution - only 5km/h). You should increase the
resolution if you have very precise real time data.
Regards,
Peter.
Hello,
It could work but I think that this will
get the routing algorithm even slower.
Add this to the drop of contraction your
performances would get really poor I’m afraid.
Nicolas
GILLET
Market-IP
–Creating
Mobile Intelligence
Phone :
+32 81 33 11 11
Fax :
+32 81 33 11 10
www.market-ip.com
– www.telefleet.com
–
www.geoplanning.net – www.drivexpert.net
De : lanmaster at hotmail.ru
[mailto:lanmaster at hotmail.ru]
Envoyé : lundi 6 janvier 2014 12:17
À : Nicolas Gillet
Cc : GraphHopper Java routing engine; Jrgen
Zornig
Objet : Re: Re: [GraphHopper] How to consider
traffic jam when route on road network
Hello, Nicolas,
Why do I need to change any edge's weight?
My thought is about
make no change in the graph data, but
parallel calculate my own weights and use that in
algorithm-place, where gets original Graph's weights.
May be my things was incorrect, please explain me.
Пнд 06 Янв 2014 16:05:06 +0500, Nicolas Gillet
написал:
Hello
guys,
That implementation won’t be efficient I
think.
First thing you must know about using
real time weighting is that you won’t be able to use
contractions hierarchies unless you re-contract the
whole graph any time you change any edge’s weight.
Without contraction you’ll have a serious
downgrade of performances.
If you still want to perform real time
weighting, the best option is to update the edge’s
weight with your live traffic info, so updating the
flags.
> 1.) Which flags are included
and which position they are set?
This depends on the flag encoders you
use, check the CarFlagEncoder class.
> 2.) Is there a convinient way
to get a single EdgeIteratorState Object directly by
poviding its ID?
If you know it’s GraphHopper’s ID, you
can do graph.getEdgeProps(edgeId, Integer.MIN_VALUE)
but you’ll have to maintain a way to link OSM ID’s
with GH’s ids.
Regards,
Nicolas
GILLET
Market-IP
–Creating
Mobile Intelligence
Phone :
+32 81 33 11 11
Fax :
+32 81 33 11 10
www.market-ip.com
– www.telefleet.com
–
www.geoplanning.net – www.drivexpert.net
De : lanmaster at hotmail.ru
[mailto:lanmaster at hotmail.ru]
Envoyé : lundi 6 janvier 2014 11:47
À : Jrgen Zornig
Cc : GraphHopper Java routing engine
Objet : Re: [GraphHopper] How to consider
traffic jam when route on road network?
Hello, Jrgen!
I think about this implementation:
1. We have in-memory arraylist, that contains infos
about traffic jam
2. We have function that can calculate weight of way by
two coordinate pairs (from node / to node)
3. We have modification on Graphhopper's route calculate
algorithm, that can request weight from our weight
function (2) and summarize it with original
Graphhopper's weight.
Can that implementation be useful, how do you think?
Пнд 06 Янв 2014 15:16:52 +0500, Jrgen Zornig
написал:
I am also trying to figure out how real time graph
modifications and short and temporary events should be
handled for the routing.
I assume you use to OSM graph? That makes things more
complicated I think,because I have not found a
function to retrieve a single Edge without iterating
over and over the whole graph. Even when you know the
Edge Id, you have to iterate over all Edges.
In our scenario, we use a different (our own) graph,
and while loading it, I build up a HashMap for all
EdgeIteratorState Objects I have generated during
loading. So I can easily find a corresponding Edge for
a given TrafficJam, either by directly referencing it
over our EdgeIds or by finding out the Id via the
LocationIndex (NodeIds and the referenced EdgeIds).
When having the corresponding EdgeIteratorState Object
it should be simple to deactivate the Edge by calling
setFlags(), but I also have no clue yet, how to set
this bitmask because I couldn't find any documentation
on to flags itself.
So I want to add to this question:
1.) Which flags are included and which position they
are set?
2.) Is there a convinient way to get a single
EdgeIteratorState Object directly by poviding its ID?
I am in need of these functions to handle real time
traffic data on the graph.
P.S. Perhaps we can figure it out by ourselves, so
Peter doesn't have to answer every single question ;)
Regards,
Juergen
Am 06.01.2014 09:54, schrieb lanmaster at hotmail.ru:
Graphhopper is a project for finding routes over a
road network. It also provides functionality for
weighting this routing like fastest
or shortest
path e.g. via the FastestWeighting class. Now, the
question is: how can we extend Graphhopper
to use the speed data we get from our traffic
provider in realtime?
As I can see:
We must create a function that gets
traffic jam data from our database. We must force use that modified
function (Encoder?) somewhere in Graphhopper
route()
function. Do I think right?
Please show me how we can do this by example.
_______________________________________________
GraphHopper mailing list
GraphHopper at openstreetmap.org
https://lists.openstreetmap.org/listinfo/graphhopper
_______________________________________________
GraphHopper mailing list
GraphHopper at openstreetmap.org
https://lists.openstreetmap.org/listinfo/graphhopper
--
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20140110/2ca2ab90/attachment.html>
More information about the GraphHopper
mailing list