?? bus_show.asp
字號:
<!-- #include file="inc/config.asp" -->
<%
if request.QueryString.count>0 then
station1=request.QueryString("q")
station2=request.QueryString("q1")
end if
if station1="" or station2="" then
call ShowErr("請輸入站點!","1")
end if
response.Write("<title>"& station1 &"--"& station2 &"</title>")
%>
<!-- #include file="top.asp" -->
<%
response.Write("<div id='div_1'>所有與公交換乘""<span style='color:#FF0000'>"& station1 &"--"& station2 &"</span>""有關(guān)的信息</div>")
'下面通過數(shù)據(jù)庫找到過station1這個站點的所有公交線路
sqlstr="select * from [Station] where qmstation_name='"& station1 &"'"
rs.open sqlstr,conn,1,3
if not rs.eof then
qmroute_ahead_old=rs("qmstation_bus")
'拆封qmroute_ahead_old.
qmroute_ahead_first_1=split(qmroute_ahead_old,"-")
Num_ahead_1=ubound(qmroute_ahead_first_1)
else
response.Redirect("bus_suggestion.asp?q="&station1&"&q1="&station2&"")
response.End()
end if
rs.close
'下面通過數(shù)據(jù)庫找到過station2這個站點的所有公交線路
sql="select * from [Station] where qmstation_name='"& station2 &"'"
rs.open sql,conn,1,3
if not rs.eof then
qmroute_end_old=rs("qmstation_bus")
'拆封qmroute_end_old.
qmroute_end_first_1=split(qmroute_end_old,"-")
Num_end_1=ubound(qmroute_end_first_1)
else
response.Redirect("bus_suggestion.asp?q="&station1&"&q1="&station2&"")
response.End()
end if
rs.close
response.Write("<div id='div_3'>")
response.Write("本系統(tǒng)查找從<a href='station_show.asp?q="&station1&"'><font color='#FF0000'>"&station1&"</font></a>到<a href='station_show.asp?q="&station2&"'><font color='#FF0000'>"&station2&"</font></a>的線路有:<br>")
'判斷是否有重復的線路,有則說明可以直達
Check_1=""
for i=0 to Num_ahead_1
for j=0 to Num_end_1
if qmroute_ahead_first_1(i)=qmroute_end_first_1(j) then
response.Write("<li>可坐 <a href='qmroute_show.asp?q="&qmroute_ahead_first_1(i)&"'><font color='#FF0000'>"& qmroute_ahead_first_1(i) &"</font></a> 直達!"&"</li>")
call SearchRate1(qmroute_ahead_first_1(i))
Check_1="qm"
end if
next
next
'---------------------------------------------------------------------------------
'通過判斷Check_1的值來知道是否有直達車,有則停止,反之繼續(xù)
if Check_1="qm" then
response.Write("<br>這是本系統(tǒng)查到可以直達的車!")
response.Write("</div>")
%>
<!-- #include file="bottom.asp" -->
<%
response.End()
end if
'---------------------------------------------------------------------------------
'能夠執(zhí)行到這里說明沒有直達的車,則需進一步搜索相交的站點來找到一次換乘方案
'---------------------------------------------------------------------------------
'這里組合出sqlstr字符串,再通過各條件生成sqlstr語句,查過station1的所有車經(jīng)過的所有站點
'-----------------------------------
sqlstr=""
if Num_ahead_1=0 then
sqlstr="select * from [Route] where qmroute_name='"& qmroute_ahead_old &"'"
else
sqlstr="select * from [Route] where qmroute_name='"& qmroute_ahead_first_1(0) &"'"
for i=1 to Num_ahead_1
sqlstr=sqlstr&" or qmroute_name='"& qmroute_ahead_first_1(i) &"'"
next
end if
dim qmroute_ahead_name,station_ahead_second_1,station_ahead_second_2
redim qmroute_ahead_name(i)
redim station_ahead_second_1(i)
station_ahead_second_2="@#$%&"
rs.open sqlstr,conn,1,3
if not rs.eof then
p=0
while not rs.eof
qmroute_ahead_name(p)=rs("qmroute_name")
station_ahead_second_1(p)=rs("qmroute_address")
station_ahead_second_2=station_ahead_second_2&"-"&rs("qmroute_address")
p=p+1
rs.movenext
wend
else
response.Write("數(shù)據(jù)庫數(shù)據(jù)出錯1!")
response.End()
end if
rs.close
'-----------------------------------
'這里組合出sql字符串,再通過各條件生成sql語句,查過station2的所有車經(jīng)過的所有站點
'-----------------------------------
sql=""
if Num_end_1=0 then
sql="select * from [Route] where qmroute_name='"& qmroute_end_old &"'"
else
sql="select * from [Route] where qmroute_name='"& qmroute_end_first_1(0) &"'"
for i=1 to Num_end_1
sql=sql&" or qmroute_name='"& qmroute_end_first_1(i) &"'"
next
end if
dim qmroute_end_name,station_end_second_1,station_end_second_2
redim qmroute_end_name(i)
redim station_end_second_1(i)
station_end_second_2="&%$#@"
rs.open sql,conn,1,3
if not rs.eof then
q=0
while not rs.eof
qmroute_end_name(q)=rs("qmroute_name")
station_end_second_1(q)=rs("qmroute_address")
station_end_second_2=station_end_second_2&"-"&rs("qmroute_address")
q=q+1
rs.movenext
wend
else
response.Write("數(shù)據(jù)庫數(shù)據(jù)出錯2!")
response.End()
end if
rs.close
'------------------------------------------------------------------------------------------------
'這里來個小程序進行賦值,這些數(shù)據(jù)之后查詢二次換乘的時候能夠用到
i=100
dim qmroute_ahead_info,qmroute_end_info
dim NumAheadFirstMax,NumAheadSecondMax,NumEndFirstMax,NumEndSecondMax
redim qmroute_ahead_info(i),qmroute_end_info(i),NumAheadSecondMax(i),NumEndSecondMax(i)
NumAheadFirstMax=p-1
NumEndFirstMax=q-1
for i=0 to NumAheadFirstMax
qmroute_ahead_info(i)=split(station_ahead_second_1(i),"-")
NumAheadSecondMax(i)=ubound(qmroute_ahead_info(i))
next
for i=0 to NumEndFirstMax
qmroute_end_info(i)=split(station_end_second_1(i),"-")
NumEndSecondMax(i)=ubound(qmroute_end_info(i))
next
'下面進行循環(huán)對比,如有相同的站點這說明兩輛公交車可在這個站點上連接上
'-----------------------------------
i=100
dim station_ahead_second_3,Num_ahead_2,station_end_second_3,Num_end_2
redim station_ahead_second_3(i),Num_ahead_2(i),station_end_second_3(i),Num_end_2(i)
for i=0 to p-1
station_ahead_second_3(i)=split(station_ahead_second_1(i),"-")
Num_ahead_2(i)=ubound(station_ahead_second_3(i))
next
for i=0 to q-1
station_end_second_3(i)=split(station_end_second_1(i),"-")
Num_end_2(i)=ubound(station_end_second_3(i))
next
Check_2=""
for i=0 to p-1
for m=0 to q-1
station_change=""
for j=0 to Num_ahead_2(i)
for n=0 to Num_end_2(m)
if station_ahead_second_3(i)(j)=station_end_second_3(m)(n) then
station_change=station_change&"/"&station_ahead_second_3(i)(j)
Check_2="qm"
end if
next
next
if station_change<>"" then
station_change_new=split(station_change,"/")
if ubound(station_change_new)=1 then
station_change="<a href=station_show.asp?q="&station_change_new(1)&">"&station_change_new(1)&"</a>"
else
station_change="<a href=station_show.asp?q="&station_change_new(1)&">"&station_change_new(1)&"</a>"
for k=2 to ubound(station_change_new)
station_change=station_change&"<font color='#FF0000'>/</font><a href=station_show.asp?q="&station_change_new(k)&">"&station_change_new(k)&"</a>"
next
end if
response.Write("<br><li>可坐 <a href='qmroute_show.asp?q="&qmroute_ahead_name(i)&"'><font color='#FF0000'>"&qmroute_ahead_name(i)&"</font></a> 到 ("&station_change&") 再坐 <a href='qmroute_show.asp?q="&qmroute_end_name(m)&"'><font color='#FF0000'>"&qmroute_end_name(m)&"</font></a> 便可到達!</li><br>")
call SearchRate2(qmroute_ahead_name(i),qmroute_end_name(m))
end if
next
next
'---------------------------------------------------------------------------------
'通過判斷Check_2的值來知道是否有一次換乘方案,有則停止,反之繼續(xù)
if Check_2="qm" then
response.Write("<br>由于沒有查到有直達的車,所以本系統(tǒng)給出一次換乘的乘車方案!")
response.Write("</div>")
%>
<!-- #include file="bottom.asp" -->
<%
response.End()
end if
'---------------------------------------------------------------------------------
'能夠執(zhí)行到這里說明沒有一次換乘方案,則需進一步搜索相交的站點來找到二次換乘方案
'---------------------------------------------------------------------------------
'進行數(shù)據(jù)的優(yōu)化,把相同的站點去掉
'-------------------
'前面數(shù)據(jù)優(yōu)化
station_ahead_second_4=split(station_ahead_second_2,"-")
Num_ahead_3=ubound(station_ahead_second_4)
station_ahead_second_5=station_ahead_second_4(1) '前面可知station_ahead_second_4(0)是為了連接方便加上去的一段字符串,故不需要
for i=2 to Num_ahead_3
Check_3=""
station_ahead_second_6=split(station_ahead_second_5,"-")
Num_ahead_4=ubound(station_ahead_second_6)
for k=0 to Num_ahead_4
if station_ahead_second_6(k)=station_ahead_second_4(i) then '有相同的數(shù)據(jù)則刪掉
Check_3="qm"
end if
next
if Check_3="" then
station_ahead_second_5=station_ahead_second_5&"-"&station_ahead_second_4(i)
end if
next
'-------------------
'后面數(shù)據(jù)優(yōu)化
station_end_second_4=split(station_end_second_2,"-")
Num_end_3=ubound(station_end_second_4)
station_end_second_5=station_end_second_4(1) '前面可知station_end_second_4(0)是為了連接方便加上去的一段字符串,故不需要
for i=2 to Num_end_3
Check_4=""
station_end_second_6=split(station_end_second_5,"-")
Num_end_4=ubound(station_end_second_6)
for k=0 to Num_end_4
if station_end_second_6(k)=station_end_second_4(i) then '有相同的數(shù)據(jù)則刪掉
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -