- Se agregó un TRY/CATCH en generaMatrizRuteoTiempos, porque a veces en modo Release manda error.

This commit is contained in:
2024-05-03 00:17:35 -06:00
parent 769eeec5b4
commit 433fc32b9a
3 changed files with 26 additions and 22 deletions

View File

@@ -273,7 +273,7 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore
lasCols = $"${lasCols},'${c.GetString("Id")}'"$ lasCols = $"${lasCols},'${c.GetString("Id")}'"$
End If End If
Loop Loop
Log(">>>>>>>>>>>> " & lasCols & CRLF & lasCoords) ' Log(">>>>>>>>>>>> " & lasCols & CRLF & lasCoords)
Dim j As HttpJob Dim j As HttpJob
j.Initialize("", Me) j.Initialize("", Me)
j.Download($"http://router.project-osrm.org/table/v1/driving/${lasCoords}"$) j.Download($"http://router.project-osrm.org/table/v1/driving/${lasCoords}"$)
@@ -286,13 +286,13 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore
' StopMessageLoop ' StopMessageLoop
Private durs As String = j0.SubString2(j0.IndexOf($""durations""$)+12, j0.IndexOf($""sources""$)).Replace("[","") Private durs As String = j0.SubString2(j0.IndexOf($""durations""$)+12, j0.IndexOf($""sources""$)).Replace("[","")
Private dur1() As String = Regex.Split("]", durs) Private dur1() As String = Regex.Split("]", durs)
Log(durs) ' Log(durs)
For i = 0 To dur1.Length - 1 For i = 0 To dur1.Length - 1
Private estosVals As String = dur1(i) Private estosVals As String = dur1(i)
If estosVals.StartsWith(",") Then estosVals = $"${estosVals.SubString(1)}"$ If estosVals.StartsWith(",") Then estosVals = $"${estosVals.SubString(1)}"$
If estosVals.Length > 0 Then If estosVals.Length > 0 Then
estosVals = $"'${listLasCols.get(i)}',${estosVals}"$ estosVals = $"'${listLasCols.get(i)}',${estosVals}"$
Log(estosVals) ' Log(estosVals)
' Log($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$) ' Log($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$)
db.ExecNonQuery($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$) db.ExecNonQuery($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$)
End If End If
@@ -419,15 +419,15 @@ Sub tiempos(ruta As String) As ResumableSub 'ignore
j.Download($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$) j.Download($"http://router.project-osrm.org/route/v1/driving/${estasCoords}"$)
Wait For (j) JobDone(j As HttpJob) Wait For (j) JobDone(j As HttpJob)
If j.Success Then If j.Success Then
Log("RESPONSE:") ' Log("RESPONSE:")
Log(j.GetString) ' Log(j.GetString)
Private j0 As String = j.GetString Private j0 As String = j.GetString
End If End If
j.Release j.Release
' StopMessageLoop ' StopMessageLoop
Private js As JSONParser Private js As JSONParser
js.Initialize(j0) js.Initialize(j0)
Log(j0) ' Log(j0)
' Log("*****************************************") ' Log("*****************************************")
' Log(js) ' Log(js)
'' For Each colroot As Map In js '' For Each colroot As Map In js
@@ -437,11 +437,11 @@ Sub tiempos(ruta As String) As ResumableSub 'ignore
ts.Put(ruta, CreateMap("code":"KO", "duration":0, "distance":0, "puntos":0)) ts.Put(ruta, CreateMap("code":"KO", "duration":0, "distance":0, "puntos":0))
Try Try
Private m As Map = js.NextObject Private m As Map = js.NextObject
Log(m) ' Log(m)
Private estatus As String = m.Get("code") Private estatus As String = m.Get("code")
Private rutas As Map = m.Get("routes").as(List).Get(0) Private rutas As Map = m.Get("routes").as(List).Get(0)
Private waypoints As List = m.Get("waypoints") Private waypoints As List = m.Get("waypoints")
Log("Response: " & estatus) ' Log("Response: " & estatus)
' Log("Duration: " & rutas.Get("duration")) ' Log("Duration: " & rutas.Get("duration"))
' Log("Distance: " & rutas.Get("distance")) ' Log("Distance: " & rutas.Get("distance"))
' Log("Legs: " & rutas.Get("legs").As(List).Size) ' Log("Legs: " & rutas.Get("legs").As(List).Size)
@@ -494,7 +494,7 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
If final = "" Then 'Si no esta especificado un destino final, se toman las coordenadas del punto mas cercano al punto de inicio. If final = "" Then 'Si no esta especificado un destino final, se toman las coordenadas del punto mas cercano al punto de inicio.
Private a As ResultSet = db.ExecQuery($"Select idt, ${punteoLista.Get(0)} as laCol, nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where idT <> '${punteoLista.Get(0)}' order by ${punteoLista.Get(0)} asc limit 1"$) Private a As ResultSet = db.ExecQuery($"Select idt, ${punteoLista.Get(0)} as laCol, nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where idT <> '${punteoLista.Get(0)}' order by ${punteoLista.Get(0)} asc limit 1"$)
Log($"Select idt, ${punteoLista.Get(0)} as laCol, nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where idT <> '${punteoLista.Get(0)}' order by ${punteoLista.Get(0)} asc limit 1"$) ' Log($"Select idt, ${punteoLista.Get(0)} as laCol, nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where idT <> '${punteoLista.Get(0)}' order by ${punteoLista.Get(0)} asc limit 1"$)
' Log(a.GetString("idt")) ' Log(a.GetString("idt"))
Do While a.NextRow Do While a.NextRow
If punteoLista.IndexOf(a.GetString("idt")) = -1 Then If punteoLista.IndexOf(a.GetString("idt")) = -1 Then

View File

@@ -10,12 +10,12 @@ ModuleBreakpoints2=
ModuleBreakpoints3= ModuleBreakpoints3=
ModuleBreakpoints4= ModuleBreakpoints4=
ModuleBreakpoints5= ModuleBreakpoints5=
ModuleClosedNodes0=3,4,5,6,8,11,14,17,19,21,24 ModuleClosedNodes0=
ModuleClosedNodes1= ModuleClosedNodes1=
ModuleClosedNodes2= ModuleClosedNodes2=
ModuleClosedNodes3= ModuleClosedNodes3=
ModuleClosedNodes4= ModuleClosedNodes4=
ModuleClosedNodes5= ModuleClosedNodes5=3
NavigationStack=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,ruteo,308,0,Ruteador,Handle,38,0,Main,creaTablas,162,6,Main,generaMatrizLocal,217,0,Main,ruteoNearestInsertion,480,4 NavigationStack=rutaCompleta,generaMatrizRuteoTiempos,85,0,rutaCompleta,tiempos,105,0,Main,calculateDistance3,607,0,Ruteador,tiempos,166,0,Main,ruteo,308,0,Ruteador,Handle,38,0,Main,creaTablas,162,6,Main,generaMatrizLocal,217,0,Ruteador,generaMatrizRuteoTiempos,67,6,Main,ruteoNearestInsertion,479,4
SelectedBuild=0 SelectedBuild=0
VisibleModules=5,3,4,1,2 VisibleModules=5,3,4,1,2

View File

@@ -29,7 +29,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
Log("############# Ruteador/Handle ########################") Log("############# Ruteador/Handle ########################")
Log("##############################################################") Log("##############################################################")
' Log("q='"&req.GetParameter("q")&"'") ' Log("q='"&req.GetParameter("q")&"'")
Log($"REQ: ${req.FullRequestURI}"$) ' Log($"REQ: ${req.FullRequestURI}"$)
Private elHash As String = getHash.CalculateTheHash(req.FullRequestURI) Private elHash As String = getHash.CalculateTheHash(req.FullRequestURI)
' Log(elHash) ' Log(elHash)
Private ruta As String = req.GetParameter("r") Private ruta As String = req.GetParameter("r")
@@ -39,7 +39,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
Main.inicio = req.GetParameter("i") Main.inicio = req.GetParameter("i")
Main.final = req.GetParameter("f") Main.final = req.GetParameter("f")
If matriz <> "" And matriz <> "OSRM" Then matriz = "" If matriz <> "" And matriz <> "OSRM" Then matriz = ""
Log($"r: ${ruta}, a: ${almacen}, Coords: ${coords}"$) ' Log($"r: ${ruta}, a: ${almacen}, Coords: ${coords}"$)
Private urlParams As Map Private urlParams As Map
If ruta <> "" And almacen <> "" And coords <> "" Then If ruta <> "" And almacen <> "" And coords <> "" Then
If Main.final <> "" Then coords = coords & ";" & Main.final If Main.final <> "" Then coords = coords & ";" & Main.final
@@ -75,17 +75,21 @@ Sub generaMatrizRuteoTiempos(r As String, resp As ServletResponse, ruta As Strin
Log("############################################################################") Log("############################################################################")
Log("############# Ruteador/generaMatrizRuteoTiempos ####################") Log("############# Ruteador/generaMatrizRuteoTiempos ####################")
Log("############################################################################") Log("############################################################################")
'Generamos la matriz Try
If matriz = "OSRM" Then 'Generamos la matriz
Wait for(Main.generaMatrizOSRM(r)) Complete (Result As Int) If matriz = "OSRM" Then
Else Wait for(Main.generaMatrizOSRM(r)) Complete (Result As Int)
Main.generaMatrizLocal(r) Else
End If Main.generaMatrizLocal(r)
End If
Catch
Log(LastException)
End Try
'Generamos el ruteo 'Generamos el ruteo
Main.ruteo($"${r}"$, matriz) Main.ruteo($"${r}"$, matriz)
Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int) Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int)
Private ts As Map = Main.ts.Get($"${r}"$) Private ts As Map = Main.ts.Get($"${r}"$)
Log(ts) ' Log(ts)
Private tempMap As Map Private tempMap As Map
tempMap.Initialize tempMap.Initialize
If checkIfTableExists(r&"_punteo") Then If checkIfTableExists(r&"_punteo") Then
@@ -145,7 +149,7 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str
Log("############################################################") Log("############################################################")
Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int) Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int)
Private ts As Map = Main.ts.Get($"${r}"$) Private ts As Map = Main.ts.Get($"${r}"$)
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"$) Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)