/// <summary> /// Gets a feature collection representing the given route based on the given aggregation type. /// </summary> /// <param name="route"></param> /// <param name="aggregationType"></param> /// <returns></returns> public override FeatureCollection GetFeatures(Route route, RouteAggregationType aggregationType) { if (route == null) { throw new ArgumentNullException("route"); } if (aggregationType == RouteAggregationType.All) { // one LineString. var featureCollection = new FeatureCollection(); var coordinates = route.GetPoints(); if (coordinates.Count > 1) { var lineString = new LineString(coordinates.ToArray()); var attributes = new SimpleGeometryAttributeCollection(); attributes.Add("osmsharp:total_time", route.TotalTime.ToInvariantString()); attributes.Add("osmsharp:total_distance", route.TotalDistance.ToInvariantString()); var feature = new Feature(lineString, attributes); featureCollection.Add(feature); } return(featureCollection); } else if (aggregationType == RouteAggregationType.Modal) { // modal. // aggregate. var aggregator = new ModalAggregator(new OsmRoutingInterpreter()); var microPlanner = new ModalMicroPlanner(new ModalLanguageGenerator(), new OsmRoutingInterpreter()); var aggregated = aggregator.Aggregate(route); var instructions = InstructionGenerator.Generate(microPlanner, route, aggregated); return(this.GetFeatures(route, instructions)); } else // modal and instructions. { // instructions. var instructions = this.GetInstructions(route); return(this.GetFeatures(route, instructions)); } }
/// <summary> /// Gets a feature collection representing the given route based on the given aggregation type. /// </summary> /// <param name="route"></param> /// <param name="aggregationType"></param> /// <returns></returns> public override FeatureCollection GetFeatures(Route route, RouteAggregationType aggregationType) { if (route == null) { throw new ArgumentNullException("route"); } if (aggregationType == RouteAggregationType.All) { // one LineString. var featureCollection = new FeatureCollection(); var coordinates = route.GetPoints(); if (coordinates.Count > 1) { var lineString = new LineString(coordinates.ToArray()); var attributes = new SimpleGeometryAttributeCollection(); attributes.Add("osmsharp:total_time", route.TotalTime.ToInvariantString()); attributes.Add("osmsharp:total_distance", route.TotalDistance.ToInvariantString()); var feature = new Feature(lineString, attributes); featureCollection.Add(feature); } return featureCollection; } else if(aggregationType == RouteAggregationType.Modal) { // modal. // aggregate. var aggregator = new ModalAggregator(new OsmRoutingInterpreter()); var microPlanner = new ModalMicroPlanner(new ModalLanguageGenerator(), new OsmRoutingInterpreter()); var aggregated = aggregator.Aggregate(route); var instructions = InstructionGenerator.Generate(microPlanner, route, aggregated); return this.GetFeatures(route, instructions); } else // modal and instructions. { // instructions. var instructions = this.GetInstructions(route); return this.GetFeatures(route, instructions); } }