mirror of
https://github.com/KeymonSoft/Ruteador-NonUI.git
synced 2026-04-20 14:19:23 +00:00
-VERSION 5.07.31
- Se corrigió un error cuando no se mandaba el parametro "f" (final)
This commit is contained in:
37
Ruteador.bas
37
Ruteador.bas
@@ -14,7 +14,6 @@ Sub Class_Globals
|
||||
Dim getHash As CalculateHash
|
||||
Dim js As JSONGenerator
|
||||
Dim cuantosPuntos As Int = 0
|
||||
Dim elHash As String
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
@@ -32,32 +31,23 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
||||
Log("##############################################################")
|
||||
' Log("q='"&req.GetParameter("q")&"'")
|
||||
' Log($"REQ: ${req.FullRequestURI}"$)
|
||||
elHash = getHash.CalculateTheHash(req.FullRequestURI)
|
||||
Private elHash As String = getHash.CalculateTheHash(req.FullRequestURI)
|
||||
' Log(elHash)
|
||||
Private ruta As String = req.GetParameter("r")
|
||||
Private almacen As String = req.GetParameter("a")
|
||||
Private coords As String = req.GetParameter("c")
|
||||
Private matriz As String = req.GetParameter("m")
|
||||
Private ayuda As String
|
||||
If req.GetParameter("h") <> "" Then ayuda = req.GetParameter("h")
|
||||
If req.GetParameter("h") <> "" Then ayuda = req.GetParameter("help")
|
||||
If req.GetParameter("h") <> "" Then ayuda = req.GetParameter("ayuda")
|
||||
Main.algoritmo = 1
|
||||
If req.GetParameter("algoritmo") = "0" Or req.GetParameter("algoritmo") = "NN" Then
|
||||
Main.algoritmo = 0 ' Algoritmo = Nearest Neighbor.
|
||||
End If
|
||||
Main.inicio = req.GetParameter("i")
|
||||
Main.final = req.GetParameter("f")
|
||||
If matriz <> "" And matriz <> "OSRM" Then matriz = ""
|
||||
' Log($"r: ${ruta}, a: ${almacen}, Coords: ${coords}"$)
|
||||
Private urlParams As Map
|
||||
Log("|"&ayuda&"|"& req.GetParameter("h") & "|" )
|
||||
If ayuda <> "" Then
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write($"Son necesarios los siguientes parametros:<br>
|
||||
* r - La ruta<br>
|
||||
* a - El almacen<br>
|
||||
* c - Lista de puntos (id_cliente,lon,lat) separadas por punto y coma, el primer punto de la lista, se considera el punto de INICIO de la ruta.<br>
|
||||
* m - La matriz a usar LOCAL u OSRM (Opcional, default local<br>
|
||||
* f - El destino final (id_cliente,lon,lat) de donde termina la ruta (Opcional)"$)
|
||||
else If ruta <> "" And almacen <> "" And coords <> "" Then
|
||||
If Main.final <> "" Then coords = coords & ";" & Main.final
|
||||
If ruta <> "" And almacen <> "" And coords <> "" Then
|
||||
If Main.final <> "" And Main.algoritmo <> 0 Then coords = coords & ";" & Main.final
|
||||
ruta = "R" & ruta
|
||||
urlParams.Initialize
|
||||
urlParams.Put("almacen", almacen)
|
||||
@@ -111,6 +101,10 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
||||
End Try
|
||||
'Generamos el ruteo
|
||||
Main.ruteo($"${r}"$, matriz)
|
||||
If Main.algoritmo <> 0 And Main.final <> "" Then
|
||||
Private t() As String = Regex.Split(",", Main.final)
|
||||
Main.db.ExecNonQuery($"insert into ${r}_punteo (pos, id, nombre, lat, lon) values (${cuantosPuntos + 1}, '${t(0)}', 'almacen', '${t(2)}', '${t(1)}')"$)
|
||||
End If
|
||||
Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int)
|
||||
Private ts As Map = Main.ts.Get($"${r}"$)
|
||||
' Log(ts)
|
||||
@@ -129,7 +123,6 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
||||
If matriz = "" Then tempMap.Put("api", "Local")
|
||||
'Ponemos la ruta, almacen, tiempos, distancias y la lista de las coordenadas en un mapa para regresarla en un JSON.
|
||||
tempMap.Put("code", "OK")
|
||||
tempMap.Put("hash", elHash)
|
||||
tempMap.Put("ruta", ruta)
|
||||
tempMap.Put("almacen", almacen)
|
||||
tempMap.Put("duration", ts.Get("duration"))
|
||||
@@ -183,22 +176,18 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
||||
Private listCoords As List
|
||||
listCoords.Initialize
|
||||
Private coords2 As String = ""
|
||||
Private coords3 As String = ""
|
||||
Do While p.NextRow
|
||||
listCoords.Add(CreateMap("pos":p.GetString("pos"), "id":p.GetString("id"), "lat":p.GetString("lat"), "lon":p.GetString("lon")))
|
||||
If coords2 = "" Then
|
||||
coords2 = $"${p.GetString("lon")},${p.GetString("lat")}"$
|
||||
coords3 = $"${p.GetString("id")},${p.GetString("lon")},${p.GetString("lat")}"$
|
||||
Else
|
||||
coords2 = $"${coords2}:${p.GetString("lon")},${p.GetString("lat")}"$
|
||||
coords3 = $"${coords3};${p.GetString("id")},${p.GetString("lon")},${p.GetString("lat")}"$
|
||||
End If
|
||||
Loop
|
||||
Main.db.Close
|
||||
tempMap.Put("api", matriz)
|
||||
If matriz = "" Then tempMap.Put("api", "Local")
|
||||
tempMap.Put("code", "OK")
|
||||
tempMap.Put("hash", elHash)
|
||||
tempMap.Put("ruta", ruta)
|
||||
tempMap.Put("almacen", almacen)
|
||||
tempMap.Put("duration", ts.Get("duration"))
|
||||
@@ -216,9 +205,7 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
||||
resp.ContentType = "text/html"
|
||||
resp.Write(js.ToString)
|
||||
Log("###################################################################" & CRLF)
|
||||
Log($"http://keymon.lat:${Main.srvr.port}/ga?c=${coords3}"$)
|
||||
Log("###################################################################" & CRLF)
|
||||
Log($"http://keymon.lat:${Main.srvr.port}/kmz.php?a=1&c=${coords2}"$)
|
||||
Log($"http://keymon.lat:9001/kmz.php?a=1&c=${coords2}"$)
|
||||
Log("###################################################################" & CRLF)
|
||||
Log("Liga para ver la ruta en mapa:" & CRLF)
|
||||
Log($"https://osm.quelltextlich.at/viewer-js.html?kml_url=http://keymon.lat:9001/kmz.php?c=${coords2}"$)
|
||||
|
||||
Reference in New Issue
Block a user