Beispiel #1
0
 public StopManagement()
 {
     nowStop         = new StopFileBlockStruct();
     nearbyStops     = new HashSet <NearbyStopStructure>();
     supportingStops = new HashSet <string>();
     haveStopReader  = new BlockReader <StopFileBlockStruct>();
     stopReader      = new SeekReader <StopFileBlockStruct>();
 }
Beispiel #2
0
 public LineManagement()
 {
     nowLine         = new LineFileBlockStruct();
     supportingLines = new HashSet <string>();
     subwayReader    = new SeekReader <SubwayFileBlockStruct>();
     haveLineReader  = new BlockReader <HaveLineFileBlockStruct>();
     lineReader      = new SeekReader <LineFileBlockStruct>();
     nowSubwayStop   = new HashSet <SubwayFileBlockStruct>();
 }
Beispiel #3
0
        /// <summary>
        /// 以当前车次更新附近的站台
        /// </summary>
        /// <returns></returns>
        private Task UpdateNearbyStop()
        {
            return(Task.Run(() => {
                //=====================================获取数据
                var crossLinesList = nowStop.stopCrossLine.ToStringGroup();
                var cache = new List <bus_rode.Kernel.FileIO.FileOperation.seekIndexStruct>();
                //列表转换
                foreach (var item in crossLinesList)
                {
                    cache.Add(new FileIO.FileOperation.seekIndexStruct {
                        Head = item
                    });
                }
                //获取
                var reader = new SeekReader <LineFileBlockStruct>();
                var crossLinesData = reader.SeekRead(cache);

                //======================================循环所有车次查找
                foreach (var item in crossLinesData)
                {
                    //需要写入的站台列表
                    HashSet <string> neededWriteStops = new HashSet <string>();

                    //获取上下站台
                    var up = item.lineUpStop.ToList();
                    var down = item.lineDownStop.ToList();

                    //查找上下站
                    var upIndex = up.IndexOf(nowStop.stopName);
                    var downIndex = down.IndexOf(nowStop.stopName);

                    //分析首尾,直接加列表,因为重复的是加不进去的
                    if (upIndex < 0)
                    {
                    }                    //没有项目,不写
                    else if (upIndex == 0)
                    {
                        neededWriteStops.Add(up[upIndex + 1]);
                    }                                                                 //首项,只写下一项
                    else if (upIndex == up.Count - 1)
                    {
                        neededWriteStops.Add(up[upIndex - 1]);
                    }                                                                            //末项,只写前一项
                    else
                    {
                        neededWriteStops.Add(up[upIndex + 1]); neededWriteStops.Add(up[upIndex - 1]);
                    }                                                                                      //前后项都写

                    if (downIndex < 0)
                    {
                    }                      //没有项目,不写
                    else if (downIndex == 0)
                    {
                        neededWriteStops.Add(down[downIndex + 1]);
                    }                                                                       //首项,只写下一项
                    else if (downIndex == down.Count - 1)
                    {
                        neededWriteStops.Add(down[downIndex - 1]);
                    }                                                                                    //末项,只写前一项
                    else
                    {
                        neededWriteStops.Add(down[downIndex + 1]); neededWriteStops.Add(down[downIndex - 1]);
                    }                                                                                              //前后项都写

                    //==========================写入
                    foreach (var item2 in neededWriteStops)
                    {
                        //查找
                        var temp = from item3 in nearbyStops
                                   where item3.StopName == item2
                                   select item3;

                        if (temp.Any() == true)
                        {
                            //有元素,写入
                            foreach (var item4 in temp)
                            {
                                item4.crossLines.Add(item.lineName);
                            }
                        }
                        else
                        {
                            //无元素,添加项
                            var temp2 = new NearbyStopStructure();
                            temp2.StopName = item2;
                            temp2.crossLines.Add(item.lineName);

                            nearbyStops.Add(temp2);
                        }
                    }
                }
            }));
        }