예제 #1
0
        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();
        }
예제 #2
0
        public static MapMatchState InitialState()
        {
            var result = new MapMatchState();

            result.Probabilities    = new ProbabilityVector <DirectedRoad>();
            result.TransitionMemory = new List <Dictionary <DirectedRoad, DirectedRoad> >();
            return(result);
        }