Exemplo n.º 1
0
        /// <summary>
        /// Finds path passing by all checkpoints in specified order
        /// </summary>
        /// <param name="stopAreas"></param>
        /// <param name="bufferAroundPoints">Distance around point to minimize network analysis</param>
        internal List <Troncon> FindPath(IEnumerable <int> stopAreas, CommercialMode commercialMode, int bufferAroundPoints = 5000)
        {
            // get only stop area nodes
            Dictionary <int, Noeud> stopAreasIgnNodes = FilterNodesById(Nodes, new HashSet <int>(stopAreas));

            // get subnetwork convering only all stop areas
            SqlGeometry geom = GetNodesGeometryAggregate(stopAreasIgnNodes.Values, 30);

            geom = geom.STEnvelope().STBuffer(bufferAroundPoints).STEnvelope();
            var tronconsInRoute = FilterTronconsByGeometry(Troncons, geom);

            tronconsInRoute = FilterTronconsByCommercialMode(tronconsInRoute, commercialMode);
            var nodesInRoute = FilterNodesByGeometry(Nodes, geom).ToList();

            // Generate topology
            var topology = Topology.Compute(tronconsInRoute.ToList(), nodesInRoute);

            // Launch path finding
            var troncons = FindPath_GraphCollection(topology, stopAreasIgnNodes);

            return(troncons);
        }
Exemplo n.º 2
0
 private IEnumerable <Troncon> FilterTronconsByCommercialMode(IEnumerable <Troncon> troncons, CommercialMode commercialMode)
 {
     if (commercialMode.Name != "TGV")
     {
         return(troncons.Where(kvp => kvp.Nature != "LGV"));
     }
     else
     {
         return(troncons);
     }
 }