示例#1
0
        private List <StopAreaIGN> MatchStopAreasWithIGNNodes_2ndPass(List <StopAreaIGN> stopAreasIgn, Dictionary <int, Troncon> allTroncons, Dictionary <int, Noeud> allNoeuds)
        {
            // Work in L93 proj : use of more funcs on geometry types, and distance calculations done in meters

            if (stopAreasIgn != null)
            {
                #region 2nd pass : for non matched, match within 30000 meters (CPU intensive)

                var stopAreasIgn_NonMatched = stopAreasIgn.Where(s => s.HasIGNMatch == false);
                Parallel.ForEach(stopAreasIgn_NonMatched, stopAreaIgn =>
                                 //foreach (var stopAreaIgn in stopAreasIgn_NonMatched)
                {
                    StopArea area = _sncfRepo.StopAreas.Where(s => s.Id == stopAreaIgn.StopAreaId).Single();

                    var area2154 = FromCoordToGeometry2154(area.Coord);

                    var closestIgnPoints                       = from noeud in allNoeuds
                                                      let dist = noeud.Value.Geometry.STDistance(area2154).Value
                                                                 where dist < 30000
                                                                 orderby dist
                                                                 select new { Distance = dist, StopArea = area, CoordL93 = area2154, IGNObject = noeud.Value };

                    if (closestIgnPoints.Any())
                    {
                        var res = closestIgnPoints.First();
                        if (allNoeuds[res.IGNObject.Id].Toponyme.ToUpper().Trim() == area.Name.ToUpper().Trim())
                        {
                            //Trace.TraceInformation($"{area.Name}: point {DBgeomNoeuds2154NAme[res.IGNObject.Key]} at {(int)Math.Round(res.Distance, 0)}");
                            stopAreaIgn.IdNoeud       = res.IGNObject.Id;
                            stopAreaIgn.NomNoeud      = res.IGNObject.Toponyme;
                            stopAreaIgn.DistanceNoeud = res.Distance;
                        }
                        else
                        {
                            Debug.Fail($"WARN : {area.Name} name does not match with point {res.IGNObject.Toponyme} name. Distance : {(int)Math.Round(res.Distance, 0)}", "");
                        }
                    }
                    else
                    {
                        // Trace.TraceInformation($"{area.Name}: not point found.");
                    }
                }
                                 );

                #endregion
            }

            return(stopAreasIgn);
        }
示例#2
0
 private int GetStopAreaIndexWithoutSchedule(StopArea sa, StopArea origin, StopArea dest)
 {
     return(sa.Id == origin.Id ? 0
         : sa.Id == dest.Id ? 2
         : 1);
 }