diff --git a/Ruteador-NonUI.b4j b/Ruteador-NonUI.b4j index 956ba4b..e46fd30 100644 --- a/Ruteador-NonUI.b4j +++ b/Ruteador-NonUI.b4j @@ -273,7 +273,7 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore lasCols = $"${lasCols},'${c.GetString("Id")}'"$ End If Loop - Log(">>>>>>>>>>>> " & lasCols & CRLF & lasCoords) +' Log(">>>>>>>>>>>> " & lasCols & CRLF & lasCoords) Dim j As HttpJob j.Initialize("", Me) j.Download($"http://router.project-osrm.org/table/v1/driving/${lasCoords}"$) @@ -286,13 +286,13 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore ' StopMessageLoop Private durs As String = j0.SubString2(j0.IndexOf($""durations""$)+12, j0.IndexOf($""sources""$)).Replace("[","") Private dur1() As String = Regex.Split("]", durs) - Log(durs) +' Log(durs) For i = 0 To dur1.Length - 1 Private estosVals As String = dur1(i) If estosVals.StartsWith(",") Then estosVals = $"${estosVals.SubString(1)}"$ If estosVals.Length > 0 Then estosVals = $"'${listLasCols.get(i)}',${estosVals}"$ - Log(estosVals) +' Log(estosVals) ' Log($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$) db.ExecNonQuery($"insert into ${ruta}_matrizOSRM (${lasCols}) values (${estosVals})"$) 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}"$) Wait For (j) JobDone(j As HttpJob) If j.Success Then - Log("RESPONSE:") - Log(j.GetString) +' Log("RESPONSE:") +' Log(j.GetString) Private j0 As String = j.GetString End If j.Release ' StopMessageLoop Private js As JSONParser js.Initialize(j0) - Log(j0) +' Log(j0) ' Log("*****************************************") ' Log(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)) Try Private m As Map = js.NextObject - Log(m) +' 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("Response: " & estatus) ' Log("Duration: " & rutas.Get("duration")) ' Log("Distance: " & rutas.Get("distance")) ' 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. 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")) Do While a.NextRow If punteoLista.IndexOf(a.GetString("idt")) = -1 Then diff --git a/Ruteador-NonUI.b4j.meta b/Ruteador-NonUI.b4j.meta index b08cf62..f871eaf 100644 --- a/Ruteador-NonUI.b4j.meta +++ b/Ruteador-NonUI.b4j.meta @@ -10,12 +10,12 @@ ModuleBreakpoints2= ModuleBreakpoints3= ModuleBreakpoints4= ModuleBreakpoints5= -ModuleClosedNodes0=3,4,5,6,8,11,14,17,19,21,24 +ModuleClosedNodes0= ModuleClosedNodes1= ModuleClosedNodes2= ModuleClosedNodes3= ModuleClosedNodes4= -ModuleClosedNodes5= -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 +ModuleClosedNodes5=3 +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 VisibleModules=5,3,4,1,2 diff --git a/Ruteador.bas b/Ruteador.bas index 931a1f9..c820927 100644 --- a/Ruteador.bas +++ b/Ruteador.bas @@ -29,7 +29,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse) Log("############# Ruteador/Handle ########################") Log("##############################################################") ' Log("q='"&req.GetParameter("q")&"'") - Log($"REQ: ${req.FullRequestURI}"$) +' Log($"REQ: ${req.FullRequestURI}"$) Private elHash As String = getHash.CalculateTheHash(req.FullRequestURI) ' Log(elHash) 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.final = req.GetParameter("f") 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 If ruta <> "" And almacen <> "" And coords <> "" Then 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("############# Ruteador/generaMatrizRuteoTiempos ####################") Log("############################################################################") - 'Generamos la matriz - If matriz = "OSRM" Then - Wait for(Main.generaMatrizOSRM(r)) Complete (Result As Int) - Else - Main.generaMatrizLocal(r) - End If + Try + 'Generamos la matriz + If matriz = "OSRM" Then + Wait for(Main.generaMatrizOSRM(r)) Complete (Result As Int) + Else + Main.generaMatrizLocal(r) + End If + Catch + Log(LastException) + End Try 'Generamos el ruteo Main.ruteo($"${r}"$, matriz) Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int) Private ts As Map = Main.ts.Get($"${r}"$) - Log(ts) +' Log(ts) Private tempMap As Map tempMap.Initialize If checkIfTableExists(r&"_punteo") Then @@ -145,7 +149,7 @@ Sub tiempos(r As String, resp As ServletResponse, ruta As String, almacen As Str Log("############################################################") Wait for(Main.tiempos($"${r}"$)) Complete (Result As Int) Private ts As Map = Main.ts.Get($"${r}"$) - Log(ts) +' Log(ts) Private tempMap As Map tempMap.Initialize Private p As ResultSet = Main.db.ExecQuery($"select * from ${r}_punteo"$)