public MapMatcher(List <T> data, Func <T, DirectedRoad> dataToRoad, MapMatcherParameters parameters, bool useSearchGrid = true, BoundingBox boundingBox = null) { // Initialize parameters Parameters = parameters; //Build graph _dataByRoadId = new Dictionary <string, T>(); var graph = new RoadGraph(); foreach (var datum in data) { var road = dataToRoad(datum); graph.AddRoad(road); _dataByRoadId[road.Squid] = datum; } Graph = graph; // Compute search grid (for accessing nearby roads) if (useSearchGrid) { // Compute bounding box if not given if (boundingBox == null) { boundingBox = graph.Nodes.Values.GetBoundingBox(); } SearchGrid = SearchGridFactory.ComputeSearchGrid(graph, parameters.NearbyRoadsThreshold, boundingBox); } // Initialize state State = MapMatchState.InitialState(); }
public static MapMatchState InitialState() { var result = new MapMatchState(); result.Probabilities = new ProbabilityVector <DirectedRoad>(); result.TransitionMemory = new List <Dictionary <DirectedRoad, DirectedRoad> >(); return(result); }