本文整理汇总了C#中OsmSharp.Routing.Vehicle类的典型用法代码示例。如果您正苦于以下问题:C# Vehicle类的具体用法?C# Vehicle怎么用?C# Vehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vehicle类属于OsmSharp.Routing命名空间,在下文中一共展示了Vehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RouterPoint
/// <summary>
/// Creates a new router point.
/// </summary>
/// <param name="id"></param>
/// <param name="vehicle"></param>
/// <param name="location"></param>
public RouterPoint(long id, Vehicle vehicle, GeoCoordinate location)
{
_id = id;
this.Location = location;
this.Vehicle = vehicle;
this.Tags = new List<KeyValuePair<string, string>>();
}
示例2: Calculate
/// <summary>
/// Calculcates the metrics.
/// </summary>
/// <param name="vehicle"></param>
/// <param name="p"></param>
/// <returns></returns>
public override Dictionary<string, double> Calculate(Vehicle vehicle, AggregatedPoint p)
{
Dictionary<string, double> result = new Dictionary<string, double>();
result.Add(DISTANCE_KEY, 0);
result.Add(TIME_KEY, 0);
Aggregated next = p;
while (next != null)
{
if (next is AggregatedPoint)
{
AggregatedPoint point = (next as AggregatedPoint);
this.CalculatePointMetrics(vehicle, result, point);
}
if (next is AggregatedArc)
{
AggregatedArc arc = (next as AggregatedArc);
this.CalculateArcMetrics(vehicle, result, arc);
}
next = next.GetNext();
}
return result;
}
示例3: CHEdgeGraphFileStreamTarget
/// <summary>
///
/// </summary>
/// <param name="stream"></param>
/// <param name="vehicle"></param>
public CHEdgeGraphFileStreamTarget(Stream stream, Vehicle vehicle)
{
_graphStream = stream;
var tagsIndex = new SimpleTagsIndex();
var interpreter = new OsmRoutingInterpreter();
_graph = new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);
_graphTarget = new CHEdgeGraphOsmStreamTarget(
_graph, interpreter, _graph.TagsIndex, vehicle);
}
示例4: TextProbableSpeed
/// <summary>
/// Tests the probable speed.
/// </summary>
/// <param name="vehicle"></param>
/// <param name="speed"></param>
/// <param name="tags"></param>
protected void TextProbableSpeed(Vehicle vehicle, double speed, params string[] tags)
{
// build tags collection.
SimpleTagsCollection tagsCollection = new SimpleTagsCollection();
for (int idx = 0; idx < tags.Length; idx = idx + 2)
{
tagsCollection.Add(tags[idx], tags[idx + 1]);
}
Assert.AreEqual(speed, vehicle.ProbableSpeed(tagsCollection).Value);
}
示例5: CheckConnectivityAndRemoveInvalid
/// <summary>
/// Checks connectivity of all given points and returns only those that are valid.
/// </summary>
/// <param name="router"></param>
/// <param name="vehicle"></param>
/// <param name="resolvedPoints"></param>
/// <param name="weight"></param>
/// <returns></returns>
public static RouterPoint[] CheckConnectivityAndRemoveInvalid(
this Router router, Vehicle vehicle, RouterPoint[] resolvedPoints, float weight)
{
var connectedPoints = new List<RouterPoint>();
for (int idx = 0; idx < resolvedPoints.Length; idx++)
{
RouterPoint resolvedPoint = resolvedPoints[idx];
if (resolvedPoint != null &&
router.CheckConnectivity(vehicle, resolvedPoint, weight))
{ // the point is connected.
connectedPoints.Add(resolvedPoint);
}
}
return connectedPoints.ToArray();
}
示例6: CalculateTSP
/// <summary>
/// Calculates the TSP.
/// </summary>
/// <param name="dataStream"></param>
/// <param name="csvStream"></param>
/// <param name="pbf"></param>
/// <param name="vehicleEnum"></param>
/// <returns></returns>
private Route CalculateTSP(Stream dataStream, Stream csvStream, bool pbf, Vehicle vehicleEnum)
{
// create the router.
OsmRoutingInterpreter interpreter = new OsmRoutingInterpreter();
Router router = Router.CreateLiveFrom(
new XmlOsmStreamSource(dataStream), interpreter);
// read the source files.
const int latitudeIdx = 2;
const int longitudeIdx = 3;
string[][] pointStrings = DelimitedFileHandler.ReadDelimitedFileFromStream(
csvStream,
DelimiterType.DotCommaSeperated);
var points = new List<RouterPoint>();
int cnt = 10;
foreach (string[] line in pointStrings)
{
if (points.Count >= cnt)
{
break;
}
var latitudeString = (string)line[latitudeIdx];
var longitudeString = (string)line[longitudeIdx];
//string route_ud = (string)line[1];
double longitude = 0;
double latitude = 0;
if (double.TryParse(longitudeString, System.Globalization.NumberStyles.Any,
System.Globalization.CultureInfo.InvariantCulture, out longitude) &&
double.TryParse(latitudeString, System.Globalization.NumberStyles.Any,
System.Globalization.CultureInfo.InvariantCulture, out latitude))
{
var point = new GeoCoordinate(latitude, longitude);
RouterPoint resolved = router.Resolve(Vehicle.Car, point);
if (resolved != null && router.CheckConnectivity(Vehicle.Car, resolved, 100))
{
points.Add(resolved);
}
}
}
var tspSolver = new RouterTSPWrapper<RouterTSP>(
new RouterTSPAEXGenetic(), router, interpreter);
return tspSolver.CalculateTSP(vehicleEnum, points.ToArray());
}
示例7: TestVehicleCanTranverse
/// <summary>
/// Tests the can traverse functionality.
/// </summary>
protected void TestVehicleCanTranverse(Vehicle vehicle, bool result, params string[] tags)
{
// build tags collection.
SimpleTagsCollection tagsCollection = new SimpleTagsCollection();
for (int idx = 0; idx < tags.Length; idx = idx + 2)
{
tagsCollection.Add(tags[idx], tags[idx + 1]);
}
if (result)
{ // assume the result is true.
Assert.IsTrue(vehicle.CanTraverse(tagsCollection));
}
else
{ // assume the result is false.
Assert.IsFalse(vehicle.CanTraverse(tagsCollection));
}
}
示例8: MatchWithEdge
/// <summary>
/// Returns true if the edge is a suitable candidate as a target for a point to be resolved on.
/// </summary>
/// <param name="vehicle"></param>
/// <param name="pointTags"></param>
/// <param name="edgeTags"></param>
/// <returns></returns>
public bool MatchWithEdge(Vehicle vehicle,
TagsCollectionBase pointTags, TagsCollectionBase edgeTags)
{
if (pointTags == null || pointTags.Count == 0)
{ // when the point has no tags it has no requirements.
return true;
}
if (edgeTags == null || edgeTags.Count == 0)
{ // when the edge has no tags, no way to verify.
return false;
}
string pointName, edgeName;
if (pointTags.TryGetValue("name", out pointName) &&
edgeTags.TryGetValue("name", out edgeName))
{ // both have names.
return (pointName == edgeName);
}
return false;
}
示例9: SupportsVehicle
/// <summary>
/// Returns true if the given vehicle type is supported.
/// </summary>
/// <param name="vehicle"></param>
/// <returns></returns>
public bool SupportsVehicle(Vehicle vehicle)
{
return _router.SupportsVehicle(vehicle);
}
示例10: Search
/// <summary>
/// Searches for a closeby link to the road network.
/// </summary>
/// <param name="vehicle">The vehicle profile.</param>
/// <param name="delta">The size of the box to search in.</param>
/// <param name="coordinate">The location of the point to search.</param>
/// <returns></returns>
/// <remarks>Similar to resolve except no resolved point is created.</remarks>
public GeoCoordinate Search(Vehicle vehicle, float delta, GeoCoordinate coordinate)
{
return _router.Search(vehicle, delta, coordinate);
}
示例11: Resolve
/// <summary>
/// Resolves all the given points.
/// </summary>
/// <param name="vehicle">The vehicle profile.</param>
/// <param name="delta">The size of the box to search in.</param>
/// <param name="coordinates">The location of the points to resolve.</param>
/// <param name="matcher">The matcher containing some matching algorithm.</param>
/// <param name="matchingTags">Extra matching data.</param>
/// <returns></returns>
public RouterPoint[] Resolve(Vehicle vehicle, float delta, GeoCoordinate[] coordinates,
IEdgeMatcher matcher, TagsCollection[] matchingTags)
{
return _router.Resolve(vehicle, delta, coordinates, matcher, matchingTags);
}
示例12: CheckConnectivity
/// <summary>
/// Returns true if the given point is connected for a radius of at least the given weight.
/// </summary>
/// <param name="vehicle">The vehicle profile.</param>
/// <param name="points"></param>
/// <param name="weight"></param>
/// <returns></returns>
public bool[] CheckConnectivity(Vehicle vehicle, RouterPoint[] points, float weight)
{
foreach (var point in points)
{
if (vehicle.UniqueName != point.Vehicle.UniqueName)
{ // vehicles are different.
throw new ArgumentException(string.Format("Given vehicle profile does not match resolved points, {0} and {1} are given, expecting identical profiles.",
vehicle.UniqueName, point.Vehicle.UniqueName));
}
}
return _router.CheckConnectivity(vehicle, points, weight);
}
示例13: CalculateManyToMany
/// <summary>
/// Calculates all routes between many sources/targets.
/// </summary>
/// <param name="vehicle">The vehicle profile.</param>
/// <param name="sources"></param>
/// <param name="targets"></param>
/// <returns></returns>
public Route[][] CalculateManyToMany(Vehicle vehicle, RouterPoint[] sources, RouterPoint[] targets)
{
return _router.CalculateManyToMany(vehicle, sources, targets);
}
示例14: TestResolveOnEdge
/// <summary>
/// Tests the edge matcher in combination with dykstra routing.
/// </summary>
/// <param name="name"></param>
/// <param name="highway"></param>
/// <param name="vehicle"></param>
/// <param name="matcher"></param>
/// <param name="found"></param>
private void TestResolveOnEdge(string name, string highway,
Vehicle vehicle, IEdgeMatcher matcher, bool found)
{
this.TestResolveOnEdgeSingle(name, highway, vehicle, null, null, !found);
this.TestResolveOnEdgeSingle(name, highway, vehicle, matcher, null, !found);
this.TestResolveOnEdgeSingle(name, highway, vehicle, matcher, name, !found);
}
示例15: CheckConnectivity
/// <summary>
/// Returns true if the given point is connected for a radius of at least the given weight.
/// </summary>
/// <param name="vehicle">The vehicle profile.</param>
/// <param name="point"></param>
/// <param name="weight"></param>
/// <returns></returns>
public bool[] CheckConnectivity(Vehicle vehicle, RouterPoint[] point, float weight)
{
return _router.CheckConnectivity(vehicle, point, weight);
}