- Se agregó la opcion de especifiar un punto como destino final (parametro f en el URL)

This commit is contained in:
2024-04-23 03:42:10 -06:00
parent 133b34606e
commit 758916a1da
6 changed files with 45 additions and 19 deletions

View File

@@ -58,7 +58,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If End If
Else Else
resp.ContentType = "text/html" resp.ContentType = "text/html"
resp.Write("Hay un error en la solicitud, son necesarios los parametros:<br>* r - La ruta<br>* a - El almacen<br>* c - id_cliente,lon,lat separadas por punto y coma.<br>* m - La matriz a usar LOCAL u OSRM (Opcional, default local)") 'this file will be loaded from the www folder resp.Write("Hay un error en la solicitud, 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)") 'this file will be loaded from the www folder
End If End If
End Sub End Sub

View File

@@ -47,6 +47,7 @@ Sub Process_Globals
' Dim matriz As String = "" ' Dim matriz As String = ""
' Dim urlParams As Map ' Dim urlParams As Map
Dim ts As Map Dim ts As Map
Dim inicio As String = "", final As String = ""
' Dim coords As List ' Dim coords As List
' Dim estePunto() As String ' Dim estePunto() As String
End Sub End Sub
@@ -295,9 +296,27 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
db.ExecNonQuery($"delete from ${ruta}_punteo"$) db.ExecNonQuery($"delete from ${ruta}_punteo"$)
punteoLista.Initialize punteoLista.Initialize
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos"$) Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos"$)
' Dim h As String = c.GetString("id")
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 (almacen). punteoLista.Add(c.GetString("id")) 'Lista para ruteoNearestInsertion, ponemos el primer punto de la lista de coordenadas.
' 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
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("CC" & pf(0))
c.Close
End If
Private cualAlgoritmo As String = "" 'ignore Private cualAlgoritmo As String = "" 'ignore
Log($"Usamos matriz |${matriz}|"$) Log($"Usamos matriz |${matriz}|"$)
If algoritmo = 1 Then If algoritmo = 1 Then
@@ -439,16 +458,20 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
Log("#####################################################################") Log("#####################################################################")
Log("############# Main/ruteoNearestInsertion ####################") Log("############# Main/ruteoNearestInsertion ####################")
Log("#####################################################################") Log("#####################################################################")
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(punteoLista)
' 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(punteoLista) If final = "" Then 'Si no esta especificado un destino final, se toman las coordenadas del punto mas cercano al punto de inicio.
' Log(a.GetString("idt")) 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"$)
If punteoLista.IndexOf(a.GetString("idt")) = -1 Then 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($"Agregamos ${a.GetString("idt")}"$) Log(a.GetString("idt"))
punteoLista.Add(a.GetString("idt")) 'Agregamos el punto mas cercano al almacen. If punteoLista.IndexOf(a.GetString("idt")) = -1 Then
Log($"Agregamos ${a.GetString("idt")}"$)
punteoLista.Add(a.GetString("idt")) 'Agregamos el punto mas cercano al almacen.
End If
End If End If
Private d As ResultSet = db.ExecQuery($"select count(id) as regs from ${ruta}_puntos"$) 'Obtenemos el total de puntos. Private d As ResultSet = db.ExecQuery($"select count(id) as regs from ${ruta}_puntos"$) 'Obtenemos el total de puntos.
' Log(lis2string(punteoLista)) Log(lis2string(punteoLista))
Private b, c, e As ResultSet 'ignore Private b, c, e As ResultSet 'ignore
' Log(d.GetInt("regs")) ' Log(d.GetInt("regs"))
For k = 0 To d.GetInt("regs") - 1 'Bucle por el total de puntos en la ruta. For k = 0 To d.GetInt("regs") - 1 'Bucle por el total de puntos en la ruta.
@@ -457,7 +480,7 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
' Log(punteoLista.Size &"|"&d.GetInt("regs")) ' Log(punteoLista.Size &"|"&d.GetInt("regs"))
Private cuantosPuntos As Int = d.GetInt("regs") Private cuantosPuntos As Int = d.GetInt("regs")
' cuantosPuntos = 21 ' cuantosPuntos = 21
' Log(punteoLista) Log(punteoLista)
If punteoLista.Size < cuantosPuntos Then 'Si hay puntos fuera de la ruta ... If punteoLista.Size < cuantosPuntos Then 'Si hay puntos fuera de la ruta ...
For j = 0 To punteoLista.Size - 2 For j = 0 To punteoLista.Size - 2
' Log(">>>>>>>>>>>>>>>>>>>>>> ${j} | ${j-2}") ' Log(">>>>>>>>>>>>>>>>>>>>>> ${j} | ${j-2}")
@@ -483,11 +506,11 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
Next Next
End If End If
If elMasCercano <> "" Then If elMasCercano <> "" Then
' Log($"${elMasCercano}, ${estePar}"$) Log($"${elMasCercano}, ${estePar}"$)
punteoLista.InsertAt(punteoLista.IndexOf(elAnterior)+1, elMasCercano) punteoLista.InsertAt(punteoLista.IndexOf(elAnterior)+1, elMasCercano)
End If End If
Next Next
' Log(punteoLista) Log(punteoLista)
db.ExecNonQuery($"delete from ${ruta}_punteo"$) db.ExecNonQuery($"delete from ${ruta}_punteo"$)
For h = 0 To punteoLista.Size - 1 For h = 0 To punteoLista.Size - 1
e = db.ExecQuery($"select * from ${ruta}_puntos where id = '${punteoLista.Get(h)}'"$) e = db.ExecQuery($"select * from ${ruta}_puntos where id = '${punteoLista.Get(h)}'"$)

View File

@@ -10,12 +10,12 @@ ModuleBreakpoints2=
ModuleBreakpoints3= ModuleBreakpoints3=
ModuleBreakpoints4= ModuleBreakpoints4=
ModuleBreakpoints5= ModuleBreakpoints5=
ModuleClosedNodes0= ModuleClosedNodes0=3,4,5,6,7,8,10,11,14,16,17,19,21,22,23,24,25
ModuleClosedNodes1= ModuleClosedNodes1=
ModuleClosedNodes2= ModuleClosedNodes2=
ModuleClosedNodes3= ModuleClosedNodes3=
ModuleClosedNodes4= ModuleClosedNodes4=
ModuleClosedNodes5= ModuleClosedNodes5=
NavigationStack=delDB,Class_Globals,7,0,Main,b_tiempos_Click,302,0,Main,ruteoNearestInsertion,387,0,Main,AppStart,22,0,Ruteador,generaMatrizRuteoTiempos,86,4,Mapa,ruteoCompleto,152,6,rutaCompleta,ruteoCompleto,153,0,Ruteador,tiempos,125,6,delDB,Handle,31,6,Main,tiempos,331,6,Main,Process_Globals,18,0 NavigationStack=Main,Process_Globals,26,6,Main,ruteoNearestInsertion,491,6,Main,generaMatrizOSRM,210,0,Main,generaMatrizLocal,182,0,Main,creaTablas,122,0,rutaCompleta,Initialize,12,0,Mapa,Handle,54,0,Ruteador,Handle,63,6,rutaCompleta,Handle,55,6,Main,ruteo,285,6
SelectedBuild=0 SelectedBuild=0
VisibleModules=5,3,4,1,2 VisibleModules=5,3,4,1,2

View File

@@ -36,6 +36,9 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
Private almacen As String = req.GetParameter("a") Private almacen As String = req.GetParameter("a")
Private coords As String = req.GetParameter("c") Private coords As String = req.GetParameter("c")
Private matriz As String = req.GetParameter("m") Private matriz As String = req.GetParameter("m")
Main.inicio = req.GetParameter("i")
Main.final = req.GetParameter("f")
If Main.final <> "" Then coords = coords & ";" & Main.final
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
@@ -64,7 +67,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If End If
Else Else
resp.ContentType = "text/html" resp.ContentType = "text/html"
resp.Write("Hay un error en la solicitud, son necesarios los parametros:<br>* r - La ruta<br>* a - El almacen<br>* c - id_cliente,lon,lat separadas por punto y coma.<br>* m - La matriz a usar LOCAL u OSRM (Opcional, default local)") 'this file will be loaded from the www folder resp.Write("Hay un error en la solicitud, 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)") 'this file will be loaded from the www folder
End If End If
End Sub End Sub

View File

@@ -49,7 +49,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End Try End Try
Else Else
resp.ContentType = "text/html" resp.ContentType = "text/html"
resp.Write("Hay un error en la solicitud, son necesarios los parametros:<br>* r - La ruta<br>* a - El almacen<br>* c - id_cliente,lon,lat separadas por punto y coma.<br>* m - La matriz a usar LOCAL u OSRM (Opcional, default local)") 'this file will be loaded from the www folder resp.Write("Hay un error en la solicitud, es necesario el parametro:<br>* b - 1") 'this file will be loaded from the www folder
End If End If
End Sub End Sub

View File

@@ -59,7 +59,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If End If
Else Else
resp.ContentType = "text/html" resp.ContentType = "text/html"
resp.Write("Hay un error en la solicitud, son necesarios los parametros:<br>* r - La ruta<br>* a - El almacen<br>* c - id_cliente,lon,lat separadas por punto y coma.<br>* m - La matriz a usar LOCAL u OSRM (Opcional, default local)") 'this file will be loaded from the www folder resp.Write("Hay un error en la solicitud, 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)") 'this file will be loaded from the www folder
End If End If
End Sub End Sub