/// <summary> /// Creates a new stream target. /// </summary> public CHEdgeFlatfileStreamTarget(Stream stream, ITagsIndex tagsIndex, Vehicle vehicle, MemoryMappedStream memoryMappedStream) : base(new RouterDataSource<CHEdgeData>(new DirectedGraph<CHEdgeData>(memoryMappedStream, 1000, CHEdgeData.MapFromDelegate, CHEdgeData.MapToDelegate, CHEdgeData.SizeUints), tagsIndex), new OsmRoutingInterpreter(), tagsIndex, vehicle) { _stream = stream; _memoryMappedStream = memoryMappedStream; }
/// <summary> /// Creates the target. /// </summary> /// <returns></returns> public static CHEdgeFlatfileStreamTarget CreateTarget(Stream stream, Vehicle vehicle, MemoryMappedStream memoryMappedStream) { if(memoryMappedStream == null) { return new CHEdgeFlatfileStreamTarget(stream, new TagsIndex(new MemoryMappedStream()), vehicle); } return new CHEdgeFlatfileStreamTarget(stream, new TagsIndex(memoryMappedStream), vehicle, memoryMappedStream); }
/// <summary> /// Returns true if the edge with given tags can be traversed by the given vehicle. /// </summary> /// <param name="tags"></param> /// <param name="vehicle"></param> /// <returns></returns> public bool CanBeTraversedBy(TagsCollectionBase tags, Vehicle vehicle) { return vehicle.CanTraverse(tags); }
/// <summary> /// Tries to the the vehicle given it's unique name. /// </summary> /// <param name="uniqueName"></param> /// <param name="vehicle"></param> /// <returns></returns> public static bool TryGetByUniqueName(string uniqueName, out Vehicle vehicle) { if (uniqueName == null) { throw new ArgumentNullException("uniqueName"); } if (VehiclesByName == null) { // no vehicles have been registered. Vehicle.RegisterVehicles(); } uniqueName = uniqueName.ToLowerInvariant(); if (!VehiclesByName.TryGetValue(uniqueName, out vehicle)) { // vehicle name not registered. return false; } return true; }
/// <summary> /// Creates a new stream target. /// </summary> public CHEdgeFlatfileStreamTarget(Stream stream, ITagsIndex tagsIndex, Vehicle vehicle) : base(new RouterDataSource<CHEdgeData>(new DirectedGraph<CHEdgeData>(), tagsIndex), new OsmRoutingInterpreter(), tagsIndex, vehicle) { _stream = stream; }
/// <summary> /// Does the metric calculations. /// </summary> /// <param name="vehicle"></param> /// <param name="p"></param> /// <returns></returns> public abstract Dictionary<string, double> Calculate(Vehicle vehicle, AggregatedPoint p);