/// <summary> /// Creates a new router db stream target. /// </summary> public RouterDbStreamTarget(RouterDb db, Vehicle[] vehicles, ITagNormalizer tagNormalizer, bool allCore = false, int minimumStages = 1, bool normalizeTags = true, IEnumerable <ITwoPassProcessor> processors = null, bool processRestrictions = false) { _db = db; _vehicles = vehicles; _vehicleTypes = new HashSet <string>(); foreach (var vehicle in _vehicles) { foreach (var vehicleType in vehicle.VehicleTypes) { _vehicleTypes.Add(vehicleType); } } _allNodesAreCore = allCore; _normalizeTags = normalizeTags; _tagNormalizer = tagNormalizer; _createNodeCoordinatesDictionary = () => { return(new NodeCoordinatesDictionary()); }; _stageCoordinates = _createNodeCoordinatesDictionary(); _allRoutingNodes = new SparseLongIndex(); _anyStageNodes = new SparseLongIndex(); _coreNodes = new SparseLongIndex(); _coreNodeIdMap = new CoreNodeIdMap(); _processedWays = new SparseLongIndex(); _minimumStages = minimumStages; foreach (var vehicle in vehicles) { foreach (var profiles in vehicle.GetProfiles()) { db.AddSupportedProfile(profiles); } } if (processors == null) { processors = new List <ITwoPassProcessor>(); } this.Processors = new List <ITwoPassProcessor>(processors); this.InitializeDefaultProcessors(processRestrictions); }
/// <summary> /// Loads a routing network created from OSM data. /// </summary> public static void LoadOsmData(this RouterDb db, IEnumerable <OsmGeo> source, bool allCore = false, bool processRestrictions = false, bool normalizeTags = true, ITagNormalizer tagNormalizer = null, IEnumerable <ITwoPassProcessor> processors = null, params Itinero.Osm.Vehicles.Vehicle[] vehicles) { if (!db.IsEmpty) { throw new ArgumentException("Can only load a new routing network into an empty router db."); } if (normalizeTags && tagNormalizer == null) { tagNormalizer = new DefaultTagNormalizer(); } // load the data. var target = new Streams.RouterDbStreamTarget(db, vehicles, tagNormalizer, allCore, processRestrictions: processRestrictions, normalizeTags: normalizeTags, processors: processors); target.RegisterSource(source); target.Pull(); // sort the network. db.Sort(); }