Calculo de Latitude e Longitude erro ao buscar informacao do form
Senhores, bom dia...
Estou com um grande problema com este script para calcular distancia entre coordenadas, o erro se dá quando eu uso a informacao do formulario, ele nao le a coordenada correta, mas quando insiro de maneira estatica, funciona normal... preciso de muita a ajuda de todos.
<%@ Language=VBScript %>
<!--#include file="cnx_map.asp"-->
<%
'set rs = Conn.Execute("SELECT * FROM ctos ORDER by codigo")
Function DegRad(x)
'Degrees to Radians
DegRad = x ((4 Atn(1)) / 180)
End Function
Function GetGeodesicDistance(Lat1,Lon1,Lat2,Lon2,rScale)
Dim er,pr,fl,F,G,L,S,C,W,R,D,H1,H2
er = 6378.1370000
pr = 6356.7523142
fl = (er - pr) / er
F = (DegRad(Lat1) + DegRad(Lat2)) / 2
G = (DegRad(Lat1) - DegRad(Lat2)) / 2
L = (DegRad(Lon1) - DegRad(Lon2)) / 2
S = Sin(G)^2 Cos(L)^2 + Cos(F)^2 Sin(L)^2
C = Cos(G)^2 Cos(L)^2 + Sin(F)^2 Sin(L)^2
W = Atn(Sqr(S / C))
R = Sqr(S * C) / W
D = 2 W er
H1 = (3 R - 1) / (2 C)
H2 = (3 R + 1) / (2 S)
Select Case rScale
Case "statute" dScale = 1.60934
Case "nautical" dScale = 1.85200
Case "metric" dScale = 1.00000
Case Else dScale = 1.60934
End Select
GetGeodesicDistance = (D * (1 + fl * H1 * Sin(F)^2 * Cos(G)^2 - fl * H2 * Cos(F)^2 * Sin(G)^2)) / dScaleEnd Function
%>
<div align="center">
<form name="frm" method="post" action="mapa_v.asp">
<label>Posição do cliente
<input name="latitude" type="text" id="latitude" value=-28.401684>
<input name="longitude" type="text" id="longitude" value=-49.389643>
</label>
<label>
<input type="submit" name="Submit" value="Enviar">
</label>
</form>
</div><%
dim Lati0, Long0, Lati1, Long1
lati0 = request.form("latitude")
long0 = request.form("longitude")
response.write GetGeodesicDistance(-28.401684,-49.389643,-28.394418,-49.395537, "metric") & " RESULTADO CORRETO<br><br><br>"
Lati1 = "-28.394418"
Long1 = "-49.395537"
response.Write(lati0) & ","
response.Write(Long0) & ","
response.Write(lati1) & ","
response.Write(Long1) & "<br><br><br>"
'Display calc
response.write GetGeodesicDistance(Lati0,Long0,Lati1,Long1, "metric") & " RESULTADO DO CALCULO<br>"
%>
[Click e arraste para mover]
Discussão (0)
Carregando comentários...