[GraphHopper] Geoposition of an edge
Philipp Kraus
philipp.kraus at tu-clausthal.de
Thu May 1 12:35:54 UTC 2014
Am 01.05.2014 um 13:47 schrieb Peter K <peathal at yahoo.de>:
> I have really no idea - what is l_position.intValue() - is this the
> edgeId?
Yes
> Also probably use fetchWayGeometry(2) which will include the
> junction nodes of the edge.
I have used 1 in fetchWayGeometry, with 2 it works better, but at the moment I get "back jumps" in driving
my car.
The problem is, that the orientation of the edge is different than I expect. For example I get a route like
o the nodes and - the samples (the samples depends on the length.
1 2 3 4
o---o---------o-----------o
I iterate over the route edges and so in this case I iterate from 1 to 4 and the samples from [0,samples).
Depend on this structure my cells are numerated with
o---o---------o-----------o
o 0 1 2 o 0 1 2 3 4 5 6 7 8 o 0 1 2 3 4 5 6 7 8 9 10 o
but on some edges the numbering is inverse to the orientation e.g.
o 0 1 2 o 8 7 6 5 4 3 2 1 0 o 0 1 2 3 4 5 6 7 8 9 10 o
so this structure creates an "back jump" on simulation.
To create the sampling of an edge I run these lines of code:
public CCellCarLinkage(int p_id, double p_length) {
m_edgeid = p_id;
m_edgelength = p_length;
m_cells = new ICar[(int) Math.floor(m_edgelength / CConfiguration.getInstance().get().CellSampling)];
// create geopositions of the cells
m_cellgeoposition = new GeoPosition[m_cells.length];
EdgeIteratorState l_state = CGraphHopper.getInstance().getEdgeIterator(m_edgeid);
PointList l_points = l_state.fetchWayGeometry(2);
double l_latitudesize = (l_points.getLatitude(l_points.size()-1) - l_points.getLatitude(0)) / m_cellgeoposition.length;
double l_longitutesize = (l_points.getLongitude(l_points.size()-1) - l_points.getLongitude(0)) / m_cellgeoposition.length;
for(int i=0; i < m_cellgeoposition.length; i++)
m_cellgeoposition[i] = new GeoPosition(l_latitudesize*i + l_points.getLatitude(0), l_longitutesize*i + l_points.getLongitude(0));
}
So I need to swap the PointList based on the driving orientation on the route. Did you have any idea to create a correct orientation?
Thx
Phil
More information about the GraphHopper
mailing list