Open juliusfriedman opened 4 years ago
You mean the vertex of the edge?
Perhaps I do mean Vertex, but RouterPoint
exposes EdgeId
so I used that terminology.
Thanks for the quick response. I will take a look.
What I am trying to achieve is the ability to prevent side switching e.g. (N/S or E/W) tracks which run adjacent to each other, sometimes GPS resolves on the opposite side and we know based on the heading that it's on the adjacent track, rather than manipulate GPS I would like to find the next vertex which connects to the last known good point using something like GetNextLocation(edgeId)
which would provide me the next location along the same edge of the first RouterPoint
so I can use that instead of the point which was resolved on the adjacent side.
Thank you
I am going to give this a try, was wondering if this was the correct approach:
var edge = Router.Db.Network.GetEdge(lastPoint.EdgeId);
var edge = routingClient.Router.Db.Network.GetEdge(lastPoint.EdgeId)
resolved = Router.TryResolve(new[] { LocomotiveProfileShortest }, (float)ll.Latitude, (float)ll.Longitude, (r)=> r == edge, (float)50, new Itinero.Algorithms.Search.ResolveSettings() { }, System.Threading.CancellationToken.None);
if (resolved.IsError)
{
System.Console.WriteLine($"Discarding non matching edgeID from previous {lastPoint.EdgeId} to {resolved.Value.EdgeId}");
continue;
}
System.Console.WriteLine($"Re-Routed non matching edgeID from previous {oldEdge} to {resolved.Value.EdgeId}");
Was hoping to have a way to directly get the RouterPoint
without having to call resolve as I already know the EdgeId
It seems that this is mostly working, there are some instances where points are resolving on adjacent tracks but I think that has something to do with the PBF or how it's converted into a graph network e.g. the EdgeId is the same for both sets of tracks which are close together...
More succinctly, Is there a direct way to go from a RouterPoint
to the next forward or backward RouterPoint
along the same exact Edge
? E.g. the next Vertex
which would correspond to a RouterPoint
I think...
Thank you for your time and assistance!
I think that I got the hang of GetVertex
as it seems to take values in terms of EdgeId
.
var edge = Router.Db.Network.GetEdge(lastPoint.EdgeId);
var vertex = Router.Db.Network.GetVertex(edge.To);
uint oldEdge = resolved.Value.EdgeId;
I would then call TryResolve
using the lat and lng from the vertex
.
I am going to also give this a try and analyze and let you know what I find.
@xivk , Is there an easy way one can get a RoutPoint after they have a PositionAfter/PostionNext from a Route? or must one manually resolve the point obtained from PostionAfter/PositionNext and if so why is that?
@xivk still waiting for a quick way to get a RoutePosition
or RouterPoint
from PositionAfter etc.
Manually resolving seems unnecessary yet I don't see another obvious way besides manually building a Route
with those manually built RoutePositions
...
Given an
EdgeId
of aRouterPoint
and theEdgeId
of anotherRouterPoint
, if they do not match I would like to take the firstEdgeId
from the firstRouterPoint
and determine the next point in theDb.Network
along the same edge.Looking through the code I didn't see an easy way to accomplish this, if this something which is not possible would it be difficult to add? I would be able to take a shot at adding if you could provide some direction.
Thank you