mirror of
https://github.com/KeymonSoft/Ruteador-NonUI.git
synced 2026-04-17 21:06:16 +00:00
- Se agregaron mas TRY/CATCH y se agregó el parametro "f", para especifiar un punto que debe ser el punto final (destino)
This commit is contained in:
3
Mapa.bas
3
Mapa.bas
@@ -89,6 +89,7 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
|||||||
Loop
|
Loop
|
||||||
Main.db.Close
|
Main.db.Close
|
||||||
StopMessageLoop
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
resp.ContentType = "text/html"
|
resp.ContentType = "text/html"
|
||||||
|
|
||||||
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
||||||
@@ -112,8 +113,8 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
|||||||
|
|
||||||
Log("Iniciamos ruteoCompleto")
|
Log("Iniciamos ruteoCompleto")
|
||||||
ruteoCompleto(r)
|
ruteoCompleto(r)
|
||||||
|
|
||||||
StopMessageLoop
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
resp.ContentType = "text/html"
|
resp.ContentType = "text/html"
|
||||||
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
||||||
Return 1
|
Return 1
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ Sub Process_Globals
|
|||||||
Dim inicio As String = "", final As String = ""
|
Dim inicio As String = "", final As String = ""
|
||||||
' Dim coords As List
|
' Dim coords As List
|
||||||
' Dim estePunto() As String
|
' Dim estePunto() As String
|
||||||
|
Dim error As String = ""
|
||||||
|
dim msg as string = ""
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub AppStart (Args() As String)
|
Sub AppStart (Args() As String)
|
||||||
@@ -153,38 +155,47 @@ Sub creaTablas(params As Map)
|
|||||||
Private estasCoords As String = params.Get("coords")
|
Private estasCoords As String = params.Get("coords")
|
||||||
Private hash As String = params.Get("hash")
|
Private hash As String = params.Get("hash")
|
||||||
Private ruta As String = $"${params.Get("ruta")}A${almacen}_${hash}"$
|
Private ruta As String = $"${params.Get("ruta")}A${almacen}_${hash}"$
|
||||||
|
db.BeginTransaction
|
||||||
Try
|
Try
|
||||||
' Log($"drop table if exists ${ruta}_matriz"$)
|
' Log($"drop table if exists ${ruta}_matriz"$
|
||||||
db.ExecNonQuery($"drop table if exists ${ruta}_matriz"$)
|
db.ExecNonQuery($"drop table if exists ${ruta}_matriz"$)
|
||||||
' Log($"drop table if exists ${ruta}_matrizOSRM"$)
|
' Log($"drop table if exists ${ruta}_matrizOSRM"$)
|
||||||
db.ExecNonQuery($"drop table if exists ${ruta}_matrizOSRM"$)
|
db.ExecNonQuery($"drop table if exists ${ruta}_matrizOSRM"$)
|
||||||
' Log($"drop table if exists ${ruta}_puntos"$)
|
' Log($"drop table if exists ${ruta}_puntos"$)
|
||||||
db.ExecNonQuery($"drop table if exists ${ruta}_puntos"$)
|
db.ExecNonQuery($"drop table if exists ${ruta}_puntos"$)
|
||||||
Catch
|
|
||||||
Log(LastException)
|
db.ExecNonQuery($"create table if not exists ${ruta}_puntos (id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
||||||
End Try
|
|
||||||
db.ExecNonQuery($"create table if not exists ${ruta}_puntos (id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
|
||||||
' Log($"create table if not exists ${ruta}_puntos (id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
' Log($"create table if not exists ${ruta}_puntos (id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
||||||
db.ExecNonQuery($"create table if not exists ${ruta}_punteo (pos TEXT, id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
db.ExecNonQuery($"create table if not exists ${ruta}_punteo (pos TEXT, id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
||||||
' Log($"create table if not exists ${ruta}_punteo (pos TEXT, id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
' Log($"create table if not exists ${ruta}_punteo (pos TEXT, id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
||||||
|
|
||||||
Private f() As String = Regex.Split(";", estasCoords)
|
Private f() As String = Regex.Split(";", estasCoords)
|
||||||
For i = 0 To f.Length - 1
|
For i = 0 To f.Length - 1
|
||||||
' Log(f(i))
|
' Log(f(i))
|
||||||
Private pars() As String = Regex.Split(",", f(i))
|
Private pars() As String = Regex.Split(",", f(i))
|
||||||
If pars.Length < 3 Then Log("####################" & CRLF & "Se necesita el id del cliente, la longitud y la latitud" & CRLF & "##############################")
|
If pars(2) > 0 Or pars(2) > 0 Then
|
||||||
' Log($"(${i}, ${pars(0)}, 'a', ${pars(2)}, ${pars(1)})"$)
|
If pars.Length < 3 Then Log("####################" & CRLF & "Se necesita el id del cliente, la longitud y la latitud" & CRLF & "##############################")
|
||||||
db.ExecNonQuery($"insert into ${ruta}_puntos (id, nombre, lat, lon) values ('CC${pars(0)}','a', ${pars(2)}, ${pars(1)})"$)
|
' Log($"(${i}, ${pars(0)}, 'a', ${pars(2)}, ${pars(1)})"$)
|
||||||
Next
|
db.ExecNonQuery($"insert into ${ruta}_puntos (id, nombre, lat, lon) values ('_${pars(0)}','a', ${pars(2)}, ${pars(1)})"$)
|
||||||
|
Else
|
||||||
|
msg = "Hay puntos con coordenadas en CERO, se eliminaron."
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
Private colsMatriz As String = "idT TEXT"
|
Private colsMatriz As String = "idT TEXT"
|
||||||
Private pp As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos"$)
|
Private pp As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos"$)
|
||||||
Do While pp.NextRow
|
Do While pp.NextRow
|
||||||
colsMatriz = $"${colsMatriz},'${pp.GetString("id")}' REAL"$
|
colsMatriz = $"${colsMatriz},'${pp.GetString("id")}' REAL"$
|
||||||
Loop
|
Loop
|
||||||
' Log(colsMatriz)
|
' Log(colsMatriz)
|
||||||
db.ExecNonQuery($"create table if not exists ${ruta}_matriz (${colsMatriz})"$)
|
db.ExecNonQuery($"create table if not exists ${ruta}_matriz (${colsMatriz})"$)
|
||||||
db.ExecNonQuery($"create table if not exists ${ruta}_matrizOSRM (${colsMatriz})"$)
|
db.ExecNonQuery($"create table if not exists ${ruta}_matrizOSRM (${colsMatriz})"$)
|
||||||
|
db.TransactionSuccessful
|
||||||
|
Catch
|
||||||
|
Log(LastException)
|
||||||
|
If error = "" Then error = LastException
|
||||||
|
db.Rollback
|
||||||
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub b_generaMatriz_Click
|
Private Sub b_generaMatriz_Click
|
||||||
@@ -231,6 +242,7 @@ Sub generaMatrizLocal(ruta As String) 'ignore
|
|||||||
Log("Matriz LOCAL generada")
|
Log("Matriz LOCAL generada")
|
||||||
Catch
|
Catch
|
||||||
Log(LastException)
|
Log(LastException)
|
||||||
|
If error = "" Then error = LastException
|
||||||
End Try
|
End Try
|
||||||
' generaMatrizOSRM
|
' generaMatrizOSRM
|
||||||
End Sub
|
End Sub
|
||||||
@@ -289,6 +301,7 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore
|
|||||||
Log("Matriz OSRM generada")
|
Log("Matriz OSRM generada")
|
||||||
Catch
|
Catch
|
||||||
Log(LastException)
|
Log(LastException)
|
||||||
|
If error = "" Then error = LastException
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -301,44 +314,46 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
|
|||||||
Log("#####################################################")
|
Log("#####################################################")
|
||||||
Log("############# Main/ruteo ####################")
|
Log("############# Main/ruteo ####################")
|
||||||
Log("#####################################################")
|
Log("#####################################################")
|
||||||
db.ExecNonQuery($"delete from ${ruta}_punteo"$)
|
If checkIfTableExists(ruta&"_puntos") Then
|
||||||
punteoLista.Initialize
|
db.ExecNonQuery($"delete from ${ruta}_punteo"$)
|
||||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos limit 1"$)
|
punteoLista.Initialize
|
||||||
Do While c.NextRow
|
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos limit 1"$)
|
||||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
|
||||||
punteoLista.Add(c.GetString("id")) 'Lista para ruteoNearestInsertion, ponemos el primer punto de la lista de coordenadas.
|
|
||||||
Loop
|
|
||||||
|
|
||||||
' Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = 'CCINCIO' limit 1"$)
|
|
||||||
' Do While c.NextRow
|
|
||||||
' db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
|
||||||
' Loop
|
|
||||||
' c.Close
|
|
||||||
' punteoLista.Add("CCINICIO")
|
|
||||||
|
|
||||||
If final <> "" Then ' Si en los parametros se especifica un punto de destino (punto final), se agrega aqui a la lista, se agrega como segundo punto, porque todos los demas puntos de la lista se van a agregar ENTRE estos dos puntos iniciales.
|
|
||||||
Log("Agregamos punto final.")
|
|
||||||
Private pf() As String = Regex.Split(",", final) ' Obtenemos id, lon y lat.
|
|
||||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = 'CC${pf(0)}' limit 1"$)
|
|
||||||
Do While c.NextRow
|
Do While c.NextRow
|
||||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
||||||
|
punteoLista.Add(c.GetString("id")) 'Lista para ruteoNearestInsertion, ponemos el primer punto de la lista de coordenadas.
|
||||||
Loop
|
Loop
|
||||||
punteoLista.Add("CC" & pf(0))
|
|
||||||
c.Close
|
|
||||||
End If
|
|
||||||
|
|
||||||
Private cualAlgoritmo As String = "" 'ignore
|
' Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = 'CCINCIO' limit 1"$)
|
||||||
Log($"Usamos matriz |${matriz}|"$)
|
' Do While c.NextRow
|
||||||
If algoritmo = 1 Then
|
' db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
||||||
ruteoNearestInsertion(ruta, matriz)
|
' Loop
|
||||||
cualAlgoritmo = " (NI)"
|
' c.Close
|
||||||
Else If algoritmo = 0 Then
|
' punteoLista.Add("CCINICIO")
|
||||||
Log(3)
|
|
||||||
ruteoNearestNeighbor(ruta, matriz)
|
If final <> "" Then ' Si en los parametros se especifica un punto de destino (punto final), se agrega aqui a la lista, se agrega como segundo punto, porque todos los demas puntos de la lista se van a agregar ENTRE estos dos puntos iniciales.
|
||||||
cualAlgoritmo = " (NN)"
|
Log("Agregamos punto final.")
|
||||||
Else
|
Private pf() As String = Regex.Split(",", final) ' Obtenemos id, lon y lat.
|
||||||
ruteoNearestInsertion2
|
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = '_${pf(0)}' limit 1"$)
|
||||||
cualAlgoritmo = " (NI2)"
|
Do While c.NextRow
|
||||||
|
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
||||||
|
Loop
|
||||||
|
punteoLista.Add("_" & pf(0))
|
||||||
|
c.Close
|
||||||
|
End If
|
||||||
|
|
||||||
|
Private cualAlgoritmo As String = "" 'ignore
|
||||||
|
Log($"Usamos matriz |${matriz}|"$)
|
||||||
|
If algoritmo = 1 Then
|
||||||
|
ruteoNearestInsertion(ruta, matriz)
|
||||||
|
cualAlgoritmo = " (NI)"
|
||||||
|
Else If algoritmo = 0 Then
|
||||||
|
Log(3)
|
||||||
|
ruteoNearestNeighbor(ruta, matriz)
|
||||||
|
cualAlgoritmo = " (NN)"
|
||||||
|
Else
|
||||||
|
ruteoNearestInsertion2
|
||||||
|
cualAlgoritmo = " (NI2)"
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -385,57 +400,59 @@ Sub tiempos(ruta As String) As ResumableSub 'ignore
|
|||||||
Log("############# Main/tiempos ####################")
|
Log("############# Main/tiempos ####################")
|
||||||
Log("#######################################################")
|
Log("#######################################################")
|
||||||
' Log("Tiempos: " & ruta)
|
' Log("Tiempos: " & ruta)
|
||||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_punteo"$)
|
If checkIfTableExists(ruta&"_punteo") Then
|
||||||
Private estasCoords As String = ""
|
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_punteo"$)
|
||||||
Do While c.NextRow
|
Private estasCoords As String = ""
|
||||||
If estasCoords = "" Then
|
Do While c.NextRow
|
||||||
estasCoords = $"${c.GetString("lon")},${c.GetString("lat")}"$
|
If estasCoords = "" Then
|
||||||
Else
|
estasCoords = $"${c.GetString("lon")},${c.GetString("lat")}"$
|
||||||
estasCoords = $"${estasCoords};${c.GetString("lon")},${c.GetString("lat")}"$
|
Else
|
||||||
|
estasCoords = $"${estasCoords};${c.GetString("lon")},${c.GetString("lat")}"$
|
||||||
|
End If
|
||||||
|
Loop
|
||||||
|
Private d() As String
|
||||||
|
d = Regex.Split(";", estasCoords)
|
||||||
|
' Log("$$$$$$ " & d.Length)
|
||||||
|
Log($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
|
||||||
|
Dim j As HttpJob
|
||||||
|
j.Initialize("", Me)
|
||||||
|
j.Download($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
|
||||||
|
Wait For (j) JobDone(j As HttpJob)
|
||||||
|
If j.Success Then
|
||||||
|
Log("RESPONSE:")
|
||||||
|
Log(j.GetString)
|
||||||
|
Private j0 As String = j.GetString
|
||||||
End If
|
End If
|
||||||
Loop
|
j.Release
|
||||||
' fx.ShowExternalDocument($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
|
' StopMessageLoop
|
||||||
Private d() As String
|
Private js As JSONParser
|
||||||
d = Regex.Split(";", estasCoords)
|
js.Initialize(j0)
|
||||||
' Log("$$$$$$ " & d.Length)
|
Log(j0)
|
||||||
Log($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
|
' Log("*****************************************")
|
||||||
Dim j As HttpJob
|
' Log(js)
|
||||||
j.Initialize("", Me)
|
'' For Each colroot As Map In js
|
||||||
j.Download($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
|
'' Log(colroot)
|
||||||
Wait For (j) JobDone(j As HttpJob)
|
'' Next
|
||||||
If j.Success Then
|
' Log("*****************************************")
|
||||||
Log("RESPONSE:")
|
ts.Put(ruta, CreateMap("code":"KO", "duration":0, "distance":0, "puntos":0))
|
||||||
Log(j.GetString)
|
Try
|
||||||
Private j0 As String = j.GetString
|
Private m As Map = js.NextObject
|
||||||
|
Log(m)
|
||||||
|
Private estatus As String = m.Get("code")
|
||||||
|
Private rutas As Map = m.Get("routes").as(List).Get(0)
|
||||||
|
Private waypoints As List = m.Get("waypoints")
|
||||||
|
Log("Response: " & estatus)
|
||||||
|
' Log("Duration: " & rutas.Get("duration"))
|
||||||
|
' Log("Distance: " & rutas.Get("distance"))
|
||||||
|
' Log("Legs: " & rutas.Get("legs").As(List).Size)
|
||||||
|
' Log("Waypoints: " & waypoints.Size)
|
||||||
|
ts.Put(ruta, CreateMap("code":"OK", "duration":rutas.Get("duration"), "distance":rutas.Get("distance"), "puntos":rutas.Get("legs").As(List).Size))
|
||||||
|
' Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>" & ts)
|
||||||
|
Catch
|
||||||
|
Log(LastException)
|
||||||
|
If error = "" Then error = LastException
|
||||||
|
End Try
|
||||||
End If
|
End If
|
||||||
j.Release
|
|
||||||
' StopMessageLoop
|
|
||||||
Private js As JSONParser
|
|
||||||
js.Initialize(j0)
|
|
||||||
' Log(j0)
|
|
||||||
' Log("*****************************************")
|
|
||||||
' Log(js)
|
|
||||||
'' For Each colroot As Map In js
|
|
||||||
'' Log(colroot)
|
|
||||||
'' Next
|
|
||||||
' Log("*****************************************")
|
|
||||||
ts.Put(ruta, CreateMap("code":"KO", "duration":0, "distance":0, "puntos":0))
|
|
||||||
Try
|
|
||||||
Private m As Map = js.NextObject
|
|
||||||
Log(m)
|
|
||||||
Private estatus As String = m.Get("code")
|
|
||||||
Private rutas As Map = m.Get("routes").as(List).Get(0)
|
|
||||||
Private waypoints As List = m.Get("waypoints")
|
|
||||||
Log("Response: " & estatus)
|
|
||||||
' Log("Duration: " & rutas.Get("duration"))
|
|
||||||
' Log("Distance: " & rutas.Get("distance"))
|
|
||||||
' Log("Legs: " & rutas.Get("legs").As(List).Size)
|
|
||||||
' Log("Waypoints: " & waypoints.Size)
|
|
||||||
ts.Put(ruta, CreateMap("code":"OK", "duration":rutas.Get("duration"), "distance":rutas.Get("distance"), "puntos":rutas.Get("legs").As(List).Size))
|
|
||||||
' Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>" & ts)
|
|
||||||
Catch
|
|
||||||
Log(LastException)
|
|
||||||
End Try
|
|
||||||
Return 1
|
Return 1
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -616,6 +633,7 @@ Public Sub calculateDistance3(lat1 As Double, lon1 As Double, lat2 As Double, lo
|
|||||||
Return Round(Yards)
|
Return Round(Yards)
|
||||||
Catch
|
Catch
|
||||||
Log("CalcDistance " & LastException)
|
Log("CalcDistance " & LastException)
|
||||||
|
if error = "" then error = LastException
|
||||||
Return -1
|
Return -1
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
@@ -641,3 +659,17 @@ Private Sub cb_api_SelectedIndexChanged(Index As Int, Value As Object)
|
|||||||
' api = Index
|
' api = Index
|
||||||
' If Index = 0 Then matriz = "" Else matriz = "OSRM"
|
' If Index = 0 Then matriz = "" Else matriz = "OSRM"
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
'Revisamos que la tabla exista.
|
||||||
|
Sub checkIfTableExists(table As String) As Boolean
|
||||||
|
' B4XPages.MainPage.db.InitializeSQLite(File.DirApp, "kmt.db", True)
|
||||||
|
Private r As ResultSet = db.ExecQuery($"Select name FROM sqlite_master WHERE Type='table' AND name='${table}'"$)
|
||||||
|
If r.NextRow Then
|
||||||
|
' B4XPages.MainPage.db.close
|
||||||
|
' Log($"NAME: ${r.GetString("name")}"$)
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
' B4XPages.MainPage.db.close
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
@@ -10,12 +10,12 @@ ModuleBreakpoints2=
|
|||||||
ModuleBreakpoints3=
|
ModuleBreakpoints3=
|
||||||
ModuleBreakpoints4=
|
ModuleBreakpoints4=
|
||||||
ModuleBreakpoints5=
|
ModuleBreakpoints5=
|
||||||
ModuleClosedNodes0=3,4,5,6,8,10,11,14,17,19,21,22,23,24,25
|
ModuleClosedNodes0=3,4,5,6,8,11,14,17,19,21,24
|
||||||
ModuleClosedNodes1=
|
ModuleClosedNodes1=
|
||||||
ModuleClosedNodes2=
|
ModuleClosedNodes2=
|
||||||
ModuleClosedNodes3=
|
ModuleClosedNodes3=
|
||||||
ModuleClosedNodes4=
|
ModuleClosedNodes4=
|
||||||
ModuleClosedNodes5=
|
ModuleClosedNodes5=
|
||||||
NavigationStack=Main,ruteo,283,6,Mapa,Handle,54,0,Main,creaTablas,132,0,Main,generaMatrizLocal,204,1,Main,generaMatrizOSRM,214,1,Main,tiempos,410,3,Ruteador,generaMatrizRuteoTiempos,95,6,Ruteador,tiempos,136,1,Mapa,ruteoCompleto,166,3,rutaCompleta,ruteoCompleto,167,2
|
NavigationStack=Main,generaMatrizOSRM,275,0,Main,tiempos,424,5,Mapa,generaMatrizRuteoTiempos,85,0,Mapa,tiempos,108,0,rutaCompleta,generaMatrizRuteoTiempos,85,0,rutaCompleta,tiempos,105,0,Main,calculateDistance3,607,0,Ruteador,tiempos,166,0,Ruteador,generaMatrizRuteoTiempos,103,6,Main,creaTablas,155,6,Main,ruteo,308,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=5,3,4,1,2
|
VisibleModules=5,3,4,1,2
|
||||||
|
|||||||
76
Ruteador.bas
76
Ruteador.bas
@@ -88,31 +88,54 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
|||||||
Log(ts)
|
Log(ts)
|
||||||
Private tempMap As Map
|
Private tempMap As Map
|
||||||
tempMap.Initialize
|
tempMap.Initialize
|
||||||
Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)
|
If checkIfTableExists(r&"_punteo") Then
|
||||||
Private listCoords As List
|
Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)
|
||||||
listCoords.Initialize
|
Private listCoords As List
|
||||||
'Ponemos el id de la tienda y las coordenadas en una lista para regresarla en un JSON.
|
listCoords.Initialize
|
||||||
Do While p.NextRow
|
'Ponemos el id de la tienda y las coordenadas en una lista para regresarla en un JSON.
|
||||||
listCoords.Add(CreateMap("pos":p.GetString("pos"), "id":p.GetString("id"), "lat":p.GetString("lat"), "lon":p.GetString("lon")))
|
Do While p.NextRow
|
||||||
Loop
|
listCoords.Add(CreateMap("pos":p.GetString("pos"), "id":p.GetString("id"), "lat":p.GetString("lat"), "lon":p.GetString("lon")))
|
||||||
Main.db.Close
|
Loop
|
||||||
tempMap.Put("api", matriz)
|
Main.db.Close
|
||||||
If matriz = "" Then tempMap.Put("api", "Local")
|
tempMap.Put("api", matriz)
|
||||||
'Ponemos la ruta, almacen, tiempos, distancias y la lista de las coordenadas en un mapa para regresarla en un JSON.
|
If matriz = "" Then tempMap.Put("api", "Local")
|
||||||
tempMap.Put("code", "OK")
|
'Ponemos la ruta, almacen, tiempos, distancias y la lista de las coordenadas en un mapa para regresarla en un JSON.
|
||||||
tempMap.Put("ruta", ruta)
|
tempMap.Put("code", "OK")
|
||||||
tempMap.Put("almacen", almacen)
|
tempMap.Put("ruta", ruta)
|
||||||
tempMap.Put("duration", ts.Get("duration"))
|
tempMap.Put("almacen", almacen)
|
||||||
tempMap.Put("distance", ts.Get("distance"))
|
tempMap.Put("duration", ts.Get("duration"))
|
||||||
tempMap.Put("puntos", ts.Get("puntos"))
|
tempMap.Put("distance", ts.Get("distance"))
|
||||||
tempMap.Put("coords", listCoords)
|
tempMap.Put("puntos", ts.Get("puntos"))
|
||||||
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
tempMap.Put("coords", listCoords)
|
||||||
' Log(tempMap)
|
tempMap.Put("mensaje", Main.msg)
|
||||||
js.Initialize(tempMap)
|
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
||||||
StopMessageLoop
|
' Log(tempMap)
|
||||||
'Regresamos en un JSON la info del ruteo.
|
js.Initialize(tempMap)
|
||||||
resp.ContentType = "text/html"
|
StopMessageLoop
|
||||||
resp.Write(js.ToString)
|
Main.error = ""
|
||||||
|
Main.msg = ""
|
||||||
|
'Regresamos en un JSON la info del ruteo.
|
||||||
|
resp.ContentType = "text/html"
|
||||||
|
resp.Write(js.ToString)
|
||||||
|
Else
|
||||||
|
tempMap.Put("api", "")
|
||||||
|
tempMap.Put("code", "KO")
|
||||||
|
tempMap.Put("error", Main.error)
|
||||||
|
tempMap.Put("ruta", ruta)
|
||||||
|
tempMap.Put("almacen", almacen)
|
||||||
|
tempMap.Put("duration", 0)
|
||||||
|
tempMap.Put("distance", 0)
|
||||||
|
tempMap.Put("puntos", 0)
|
||||||
|
tempMap.Put("coords", "")
|
||||||
|
tempMap.Put("mensaje", Main.msg)
|
||||||
|
' Log(tempMap)
|
||||||
|
js.Initialize(tempMap)
|
||||||
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
|
Main.msg = ""
|
||||||
|
resp.ContentType = "text/html"
|
||||||
|
resp.Write(js.ToString)
|
||||||
|
End If
|
||||||
Return 1
|
Return 1
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -147,10 +170,13 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
|||||||
tempMap.Put("distance", ts.Get("distance"))
|
tempMap.Put("distance", ts.Get("distance"))
|
||||||
tempMap.Put("puntos", ts.Get("puntos"))
|
tempMap.Put("puntos", ts.Get("puntos"))
|
||||||
tempMap.Put("coords", listCoords)
|
tempMap.Put("coords", listCoords)
|
||||||
|
tempMap.Put("mensaje", Main.msg)
|
||||||
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
If tempMap.get("puntos") = 0 Then tempMap.Put("code", "KO")
|
||||||
' Log(tempMap)
|
' Log(tempMap)
|
||||||
js.Initialize(tempMap)
|
js.Initialize(tempMap)
|
||||||
StopMessageLoop
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
|
Main.msg = ""
|
||||||
resp.ContentType = "text/html"
|
resp.ContentType = "text/html"
|
||||||
resp.Write(js.ToString)
|
resp.Write(js.ToString)
|
||||||
Log("###################################################################" & CRLF)
|
Log("###################################################################" & CRLF)
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
|
|||||||
Loop
|
Loop
|
||||||
Main.db.Close
|
Main.db.Close
|
||||||
StopMessageLoop
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
resp.ContentType = "text/html"
|
resp.ContentType = "text/html"
|
||||||
|
|
||||||
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
||||||
Return 1
|
Return 1
|
||||||
End Sub
|
End Sub
|
||||||
@@ -110,11 +110,10 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
|
|||||||
End If
|
End If
|
||||||
Loop
|
Loop
|
||||||
Main.db.Close
|
Main.db.Close
|
||||||
|
|
||||||
' Log("Iniciamos ruteoCompleto")
|
' Log("Iniciamos ruteoCompleto")
|
||||||
' ruteoCompleto(r)
|
' ruteoCompleto(r)
|
||||||
|
|
||||||
StopMessageLoop
|
StopMessageLoop
|
||||||
|
Main.error = ""
|
||||||
resp.ContentType = "text/html"
|
resp.ContentType = "text/html"
|
||||||
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
resp.Write($"<a href="https://osm.quelltextlich.at/viewer-js.html?kml_url=https://pi.famguerra.com/kmz.php?c=${listCoords}">Mapa</a>"$)
|
||||||
Return 1
|
Return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user