Exemple #1
0
    public List <RouteResult> ZhiDa(String Startid, String Endid, List <RouteInfo> RtInfoColl)
    {
        List <RouteResult> RtRsColl = new List <RouteResult>();

        for (int i = 0; i < RtInfoColl.Count; i++)
        {
            String   NodeStr  = RtInfoColl[i].getNode();
            String[] NodeArr  = NodeStr.Split(';');
            String   Rtid     = RtInfoColl[i].getId();
            int      StartInt = -1;
            int      EndInt   = -1;
            for (int j = 0; j < NodeArr.Length; j++)
            {
                if (Startid == NodeArr[j])
                {
                    StartInt = j;
                }
                if (Endid == NodeArr[j])
                {
                    EndInt = j;
                }
            }

            if ((StartInt > -1) && (EndInt > -1) && (EndInt > StartInt))
            {
                RouteResult RtRs    = new RouteResult();
                String      RtNodes = GetIdsFromRt(Startid, Endid, NodeStr);
                RtRs.setNodesJiao(Startid + ";" + Endid);
                RtRs.setRoutesStr(Rtid);
                RtRs.setAllRtName(GetAllRtName(Rtid));
                RtRs.setLength(GetAlllen(RtNodes, Rtid));
                RtRs.setPrice(RtInfoColl[i].getPrice());
                RtRs.setAllCoords(GetAllCoords(RtNodes, Rtid));
                RtRs.setNodesCoords(QueryStationByid(Startid + "," + Endid));
                RtRs.setAllNodesName(GetAllStaName(Startid + ";" + Endid));
                RtRsColl.Add(RtRs);
            }
        }

        return(RtRsColl);
    }
Exemple #2
0
    public List <RouteResult> Twochange(String Startid, String Endid, List <RouteInfo> RtInfoColl)
    {
        List <RouteResult> RtRsColl    = new List <RouteResult>();
        List <RouteInfo>   StartidLine = new List <RouteInfo>();
        List <RouteInfo>   EndidLine   = new List <RouteInfo>();

        //首先将经过起点和终点的路线全部加入内存
        for (int i = 0; i < RtInfoColl.Count; i++)
        {
            String StrLine = RtInfoColl[i].getNode();

            if (IsNodeInLine(Startid, StrLine))
            {
                StartidLine.Add(RtInfoColl[i]);
            }

            if (IsNodeInLine(Endid, StrLine))
            {
                EndidLine.Add(RtInfoColl[i]);
            }
        }

        for (int l = 0; l < RtInfoColl.Count; l++)
        {
            RouteInfo pAllRoute       = RtInfoColl[l];
            String    pAllLineNodeStr = pAllRoute.getNode();

            for (int j = 0; j < StartidLine.Count; j++)
            {
                RouteInfo StartRt          = StartidLine[j];
                String    StartLineNodeStr = StartRt.getNode();
                String    pStJiaodian      = IsLineIntersect(StartLineNodeStr,
                                                             pAllLineNodeStr);

                if ((pStJiaodian.Length != 0) &&
                    (pStJiaodian != Startid) &&
                    (pStJiaodian != Endid))
                {
                    String RtNodes1 = GetIdsFromRt(Startid, pStJiaodian,
                                                   StartLineNodeStr);
                    if (RtNodes1.Length > 0)
                    {
                        for (int k = 0; k < EndidLine.Count; k++)
                        {
                            RouteInfo EndRt           = EndidLine[k];
                            String    pEndLineNodeStr = EndRt.getNode();
                            String    pEndJiaodian    = IsLineIntersect(
                                pAllLineNodeStr, pEndLineNodeStr);
                            if ((pEndJiaodian.Length > 0) &&
                                (pEndJiaodian != Startid) &&
                                (pEndJiaodian != Endid))
                            {
                                String RtNodes3 = GetIdsFromRt(pEndJiaodian,
                                                               Endid, pEndLineNodeStr);
                                if (RtNodes3.Length > 0)
                                {
                                    String RtNodes2 = GetIdsFromRt(pStJiaodian,
                                                                   pEndJiaodian, pAllLineNodeStr);
                                    if (RtNodes2.Length > 0)
                                    {
                                        String      RouteStartid = StartRt.getId();
                                        String      RouteEndid   = EndRt.getId();
                                        String      RouteAllid   = pAllRoute.getId();
                                        RouteResult RtRs         = new RouteResult();
                                        RtRs.setNodesJiao(Startid + ";"
                                                          + pStJiaodian + ";"
                                                          + pEndJiaodian + ";" + Endid);
                                        RtRs.setRoutesStr(RouteStartid
                                                          + ";" + RouteAllid
                                                          + ";" + RouteEndid);
                                        RtRs.setAllRtName(GetAllRtName(RouteStartid
                                                                       + ";"
                                                                       + RouteAllid
                                                                       + ";" + RouteEndid));
                                        RtRs.setLength(GetAlllen(RtNodes1 + "&"
                                                                 + RtNodes2 + "&" + RtNodes3,
                                                                 RouteStartid + ";" + RouteAllid
                                                                 + ";" + RouteEndid));
                                        RtRs.setPrice(pAllRoute.getPrice()
                                                      + StartRt.getPrice()
                                                      + EndRt.getPrice());
                                        RtRs.setAllCoords(GetAllCoords(
                                                              RtNodes1 + "&"
                                                              + RtNodes2
                                                              + "&"
                                                              + RtNodes3,
                                                              RouteStartid + ";"
                                                              + RouteAllid
                                                              + ";"
                                                              + RouteEndid));
                                        RtRs.setNodesCoords(QueryStationByid(Startid
                                                                             + ","
                                                                             + pStJiaodian
                                                                             + ","
                                                                             + pEndJiaodian
                                                                             + "," + Endid));

                                        RtRs.setAllNodesName(GetAllStaName(Startid
                                                                           + ";"
                                                                           + pStJiaodian
                                                                           + ";"
                                                                           + pEndJiaodian
                                                                           + ";" + Endid));

                                        RtRsColl.Add(RtRs);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return(RtRsColl);
    }