Exemple #1
0
        /// <summary>
        /// Initialize OsmSnapper, which allows you to snap GPS tracks to on-road geometries
        /// </summary>
        /// <param name="overpassApi"></param>
        /// <param name="boundingBox"></param>
        /// <param name="parameters"></param>
        /// <param name="printConsoleUpdates"></param>
        public OsmSnapper(OverpassApi overpassApi, BoundingBox boundingBox = null, MapMatcherParameters parameters = null, bool printConsoleUpdates = false, bool useSearchGrid = true)
        {
            _printConsoleUpdates = printConsoleUpdates;
            _useSearchGrid       = useSearchGrid;
            if (parameters == null)
            {
                parameters = MapMatcherParameters.Default;
            }
            Parameters = parameters;

            if (overpassApi == OverpassApi.DeloreanGray)
            {
                _overpassApi = Config.Urls.DeloreanGray;
            }
            else if (overpassApi == OverpassApi.MainOverpass)
            {
                _overpassApi = Config.Urls.MainOverpassApi;
            }
            else
            {
                throw new ArgumentException("Invalid overpass enum");
            }

            if (boundingBox != null)
            {
                SnappingArea = boundingBox;
                // Build graph in bounding box and initialize map matcher (involves computing search grid data structure)
                var graph = OsmGraphBuilder.BuildInRegion(_overpassApi, boundingBox);
                MapMatcher = new OsmMapMatcher(graph, parameters, _useSearchGrid);
            }
        }
Exemple #2
0
 public OsmMapMatcher(RoadGraph graph, MapMatcherParameters parameters = null, bool useSearchGrid = true)
 {
     if (parameters == null)
     {
         parameters = MapMatcherParameters.Default;
     }
     Parameters = parameters;
     if (useSearchGrid)
     {
         SearchGrid = SearchGridFactory.ComputeSearchGrid(graph, DefaultValues.Nearby_Road_Radius_In_Meters);
     }
     Graph = graph;
     State = MapMatchState.InitialState();
 }