diff --git a/Mapa.bas b/Mapa.bas
index e54a899..8ab3ee6 100644
--- a/Mapa.bas
+++ b/Mapa.bas
@@ -58,7 +58,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If
Else
resp.ContentType = "text/html"
- resp.Write("Hay un error en la solicitud, son necesarios los parametros:
* r - La ruta
* a - El almacen
* c - id_cliente,lon,lat separadas por punto y coma.
* 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:
* r - La ruta
* a - El almacen
* 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.
* m - La matriz a usar LOCAL u OSRM (Opcional, default local
* 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 Sub
diff --git a/Ruteador-NonUI.b4j b/Ruteador-NonUI.b4j
index c2ada0d..cb34cd8 100644
--- a/Ruteador-NonUI.b4j
+++ b/Ruteador-NonUI.b4j
@@ -47,6 +47,7 @@ Sub Process_Globals
' Dim matriz As String = ""
' Dim urlParams As Map
Dim ts As Map
+ Dim inicio As String = "", final As String = ""
' Dim coords As List
' Dim estePunto() As String
End Sub
@@ -295,9 +296,27 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
db.ExecNonQuery($"delete from ${ruta}_punteo"$)
punteoLista.Initialize
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")})"$)
- 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
Log($"Usamos matriz |${matriz}|"$)
If algoritmo = 1 Then
@@ -439,16 +458,20 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
Log("#####################################################################")
Log("############# Main/ruteoNearestInsertion ####################")
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($"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(a.GetString("idt"))
- 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.
+ Log(punteoLista)
+
+ 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(a.GetString("idt"))
+ 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
+
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
' Log(d.GetInt("regs"))
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"))
Private cuantosPuntos As Int = d.GetInt("regs")
' cuantosPuntos = 21
-' Log(punteoLista)
+ Log(punteoLista)
If punteoLista.Size < cuantosPuntos Then 'Si hay puntos fuera de la ruta ...
For j = 0 To punteoLista.Size - 2
' Log(">>>>>>>>>>>>>>>>>>>>>> ${j} | ${j-2}")
@@ -483,11 +506,11 @@ Sub ruteoNearestInsertion(ruta As String, matriz As String) 'ignore
Next
End If
If elMasCercano <> "" Then
-' Log($"${elMasCercano}, ${estePar}"$)
+ Log($"${elMasCercano}, ${estePar}"$)
punteoLista.InsertAt(punteoLista.IndexOf(elAnterior)+1, elMasCercano)
End If
Next
-' Log(punteoLista)
+ Log(punteoLista)
db.ExecNonQuery($"delete from ${ruta}_punteo"$)
For h = 0 To punteoLista.Size - 1
e = db.ExecQuery($"select * from ${ruta}_puntos where id = '${punteoLista.Get(h)}'"$)
diff --git a/Ruteador-NonUI.b4j.meta b/Ruteador-NonUI.b4j.meta
index 4449f42..6b11138 100644
--- a/Ruteador-NonUI.b4j.meta
+++ b/Ruteador-NonUI.b4j.meta
@@ -10,12 +10,12 @@ ModuleBreakpoints2=
ModuleBreakpoints3=
ModuleBreakpoints4=
ModuleBreakpoints5=
-ModuleClosedNodes0=
+ModuleClosedNodes0=3,4,5,6,7,8,10,11,14,16,17,19,21,22,23,24,25
ModuleClosedNodes1=
ModuleClosedNodes2=
ModuleClosedNodes3=
ModuleClosedNodes4=
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
VisibleModules=5,3,4,1,2
diff --git a/Ruteador.bas b/Ruteador.bas
index 9c5f2bc..c64e543 100644
--- a/Ruteador.bas
+++ b/Ruteador.bas
@@ -36,6 +36,9 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
Private almacen As String = req.GetParameter("a")
Private coords As String = req.GetParameter("c")
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 = ""
Log($"r: ${ruta}, a: ${almacen}, Coords: ${coords}"$)
Private urlParams As Map
@@ -64,7 +67,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If
Else
resp.ContentType = "text/html"
- resp.Write("Hay un error en la solicitud, son necesarios los parametros:
* r - La ruta
* a - El almacen
* c - id_cliente,lon,lat separadas por punto y coma.
* 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:
* r - La ruta
* a - El almacen
* 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.
* m - La matriz a usar LOCAL u OSRM (Opcional, default local
* 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 Sub
diff --git a/delDB.bas b/delDB.bas
index 1773db6..99728eb 100644
--- a/delDB.bas
+++ b/delDB.bas
@@ -49,7 +49,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End Try
Else
resp.ContentType = "text/html"
- resp.Write("Hay un error en la solicitud, son necesarios los parametros:
* r - La ruta
* a - El almacen
* c - id_cliente,lon,lat separadas por punto y coma.
* 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:
* b - 1") 'this file will be loaded from the www folder
End If
End Sub
diff --git a/rutaCompleta.bas b/rutaCompleta.bas
index 8def770..8b45faf 100644
--- a/rutaCompleta.bas
+++ b/rutaCompleta.bas
@@ -59,7 +59,7 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
End If
Else
resp.ContentType = "text/html"
- resp.Write("Hay un error en la solicitud, son necesarios los parametros:
* r - La ruta
* a - El almacen
* c - id_cliente,lon,lat separadas por punto y coma.
* 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:
* r - La ruta
* a - El almacen
* 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.
* m - La matriz a usar LOCAL u OSRM (Opcional, default local
* 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 Sub