mirror of
https://github.com/KeymonSoft/Ruteador-NonUI.git
synced 2026-04-20 22:29:18 +00:00
-VERSION 5.07.31
- Se corrigió un error cuando no se mandaba el parametro "f" (final)
This commit is contained in:
@@ -1,51 +1,31 @@
|
||||
AppType=StandardJava
|
||||
Build1=Default,b4j.example
|
||||
File1=config.js
|
||||
File2=cover.png
|
||||
File3=genetic-algorithm.js
|
||||
File4=index.html
|
||||
File5=LICENSE
|
||||
File6=map.js
|
||||
File7=README.md
|
||||
File8=result.html
|
||||
File9=style.css
|
||||
FileGroup1=Default Group
|
||||
FileGroup2=Default Group
|
||||
FileGroup3=Default Group
|
||||
FileGroup4=Default Group
|
||||
FileGroup5=Default Group
|
||||
FileGroup6=Default Group
|
||||
FileGroup7=Default Group
|
||||
FileGroup8=Default Group
|
||||
FileGroup9=Default Group
|
||||
Group=Default Group
|
||||
Library1=byteconverter
|
||||
Library10=nhcalculatehash
|
||||
Library11=javaobject
|
||||
Library2=compressstrings
|
||||
Library3=jcore
|
||||
Library4=jfx
|
||||
Library5=jokhttputils2
|
||||
Library6=jrandomaccessfile
|
||||
Library7=jserver
|
||||
Library8=json
|
||||
Library9=jsql
|
||||
Module1=Ayuda
|
||||
Module2=DBRequestManager
|
||||
Module3=delDB
|
||||
Module4=Genetic_Algorithm
|
||||
Module5=Mapa
|
||||
Module6=rutaCompleta
|
||||
Module7=Ruteador
|
||||
NumberOfFiles=9
|
||||
NumberOfLibraries=11
|
||||
NumberOfModules=7
|
||||
Version=10
|
||||
Library1=compressstrings
|
||||
Library10=byteconverter
|
||||
Library2=jcore
|
||||
Library3=jfx
|
||||
Library4=jokhttputils2
|
||||
Library5=jrandomaccessfile
|
||||
Library6=jserver
|
||||
Library7=json
|
||||
Library8=jsql
|
||||
Library9=nhcalculatehash
|
||||
Module1=DBRequestManager
|
||||
Module2=delDB
|
||||
Module3=Mapa
|
||||
Module4=rutaCompleta
|
||||
Module5=Ruteador
|
||||
NumberOfFiles=0
|
||||
NumberOfLibraries=10
|
||||
NumberOfModules=5
|
||||
Version=10.3
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#CommandLineArgs:
|
||||
#MergeLibraries: True
|
||||
#AdditionalJar: sqlite-jdbc-3.7.2.jar
|
||||
' VERSION 5.07.31
|
||||
'###########################################################################################################
|
||||
'###################### PULL #############################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||
@@ -59,7 +39,7 @@ Version=10
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Dim srvr As Server
|
||||
Private srvr As Server
|
||||
Dim db As SQL
|
||||
' Dim fx As JFX
|
||||
Dim punteoLista As List
|
||||
@@ -73,7 +53,6 @@ Sub Process_Globals
|
||||
' Dim estePunto() As String
|
||||
Dim error As String = ""
|
||||
Dim msg As String = ""
|
||||
Dim hash As String = ""
|
||||
End Sub
|
||||
|
||||
Sub AppStart (Args() As String)
|
||||
@@ -94,7 +73,9 @@ Sub AppStart (Args() As String)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
|
||||
' Log($"ARGS=${DBRIp}:${DBRPort}"$)
|
||||
Log("Server Port=" & srvr.Port)
|
||||
ts.Initialize
|
||||
@@ -105,20 +86,12 @@ Sub AppStart (Args() As String)
|
||||
srvr.AddHandler("/mapa", "Mapa", False)
|
||||
srvr.AddHandler("/rutacompleta", "rutaCompleta", False)
|
||||
srvr.AddHandler("/borrar", "delDB", False)
|
||||
srvr.AddHandler("/ayuda", "Ayuda", False)
|
||||
srvr.AddHandler("/help", "Ayuda", False)
|
||||
srvr.AddHandler("/h", "Ayuda", False)
|
||||
srvr.AddHandler("/ga", "Genetic_Algorithm", False)
|
||||
|
||||
|
||||
Log(File.ListFiles(File.DirApp))
|
||||
Dim jo As JavaObject = srvr
|
||||
jo.GetFieldJO("context").RunMethodJO("getMimeTypes", Null).RunMethod("addMimeMapping", Array("kml", "text/xml"))
|
||||
|
||||
srvr.Start
|
||||
StartMessageLoop
|
||||
'open browser and navigate to: http://127.0.0.1:51042/
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
#Region Shared Files
|
||||
@@ -181,7 +154,7 @@ Sub creaTablas(params As Map)
|
||||
Log(params)
|
||||
Private almacen As String = params.Get("almacen")
|
||||
Private estasCoords As String = params.Get("coords")
|
||||
hash = params.Get("hash")
|
||||
Private hash As String = params.Get("hash")
|
||||
Private ruta As String = $"${params.Get("ruta")}A${almacen}_${hash}"$
|
||||
db.BeginTransaction
|
||||
Try
|
||||
@@ -191,7 +164,6 @@ Sub creaTablas(params As Map)
|
||||
db.ExecNonQuery($"drop table if exists ${ruta}_matrizOSRM"$)
|
||||
' Log($"drop table if exists ${ruta}_puntos"$)
|
||||
db.ExecNonQuery($"drop table if exists ${ruta}_puntos"$)
|
||||
|
||||
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)"$)
|
||||
db.ExecNonQuery($"create table if not exists ${ruta}_punteo (pos TEXT, id TEXT, nombre TEXT, lat TEXT, lon TEXT)"$)
|
||||
@@ -250,7 +222,10 @@ Sub generaMatrizLocal(ruta As String) 'ignore
|
||||
Private lasCols, losVals As String
|
||||
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")})"$)
|
||||
If algoritmo <> 0 Then
|
||||
Log($">>> insertamos el almacen en PUNTEO"$)
|
||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values ('0', '${c.GetString("id")}', 'Almacen', ${c.Getdouble("lat")}, ${c.Getdouble("lon")})"$)
|
||||
End If
|
||||
' Log($"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).
|
||||
Do While c.NextRow
|
||||
@@ -286,6 +261,7 @@ Sub generaMatrizOSRM(ruta As String) As ResumableSub 'ignore
|
||||
' matriz = "OSRM"
|
||||
punteoLista.Initialize
|
||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos"$)
|
||||
Log($">>> insertamos el almacen en PUNTEO"$)
|
||||
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).
|
||||
Private lasCoords = "", lasCols = "idT", losIds = c.GetString("id") As String 'ignore
|
||||
@@ -350,12 +326,14 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
|
||||
If checkIfTableExists(ruta&"_puntos") Then
|
||||
db.ExecNonQuery($"delete from ${ruta}_punteo"$)
|
||||
punteoLista.Initialize
|
||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos 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")})"$)
|
||||
punteoLista.Add(c.GetString("id")) 'Lista para ruteoNearestInsertion, ponemos el primer punto de la lista de coordenadas.
|
||||
Loop
|
||||
|
||||
If algoritmo <> 0 Then
|
||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos limit 1"$)
|
||||
Do While c.NextRow
|
||||
Log($">>> insertamos el almacen en PUNTEO"$)
|
||||
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
|
||||
End If
|
||||
' 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")})"$)
|
||||
@@ -368,6 +346,7 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
|
||||
Private pf() As String = Regex.Split(",", final) ' Obtenemos id, lon y lat.
|
||||
Private c As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = '_${pf(0)}' limit 1"$)
|
||||
Do While c.NextRow
|
||||
Log($">>> insertamos el almacen en PUNTEO"$)
|
||||
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))
|
||||
@@ -379,13 +358,15 @@ Sub ruteo(ruta As String, matriz As String) 'ignore
|
||||
If algoritmo = 1 Then
|
||||
ruteoNearestInsertion(ruta, matriz)
|
||||
cualAlgoritmo = " (NI)"
|
||||
Log(">>>>>>>>>> (NI)")
|
||||
Else If algoritmo = 0 Then
|
||||
Log(3)
|
||||
Log(">>>>>>>>>> (NN)")
|
||||
ruteoNearestNeighbor(ruta, matriz)
|
||||
cualAlgoritmo = " (NN)"
|
||||
Else
|
||||
ruteoNearestInsertion2
|
||||
cualAlgoritmo = " (NI2)"
|
||||
Log(">>>>>>>>>> (NI2)")
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
@@ -427,7 +408,7 @@ Private Sub b_tiempos_Click
|
||||
' tiempos("R1")
|
||||
End Sub
|
||||
|
||||
'Regresa El tiempo y distancia de la ruta especificada desde el API de OSRM.
|
||||
'Regresa El tiempo y distancia de la ruta especificada.
|
||||
Sub tiempos(ruta As String) As ResumableSub 'ignore
|
||||
Log("#######################################################")
|
||||
Log("############# Main/tiempos ####################")
|
||||
@@ -446,21 +427,26 @@ Sub tiempos(ruta As String) As ResumableSub 'ignore
|
||||
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
|
||||
Try
|
||||
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
|
||||
Else
|
||||
Log($"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ${CRLF} ${j.ErrorMessage}"$)
|
||||
If error = "" Then error = j.ErrorMessage
|
||||
Log($"######################### ${error}"$)
|
||||
End If
|
||||
j.Release
|
||||
Private j0 As String = j.GetString
|
||||
Else
|
||||
Log($"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ${CRLF} ${j.ErrorMessage}"$)
|
||||
If error = "" Then error = j.ErrorMessage
|
||||
Log($"######################### ${error}"$)
|
||||
End If
|
||||
j.Release
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
|
||||
' StopMessageLoop
|
||||
Private js As JSONParser
|
||||
js.Initialize(j0)
|
||||
@@ -483,7 +469,7 @@ Sub tiempos(ruta As String) As ResumableSub 'ignore
|
||||
' Log("Distance: " & rutas.Get("distance"))
|
||||
' Log("Legs: " & rutas.Get("legs").As(List).Size)
|
||||
' Log("Waypoints: " & waypoints.Size)
|
||||
ts.Put(ruta, CreateMap("code":"OK", "hash":hash, "duration":rutas.Get("duration"), "distance":rutas.Get("distance"), "puntos":rutas.Get("legs").As(List).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)
|
||||
@@ -505,16 +491,33 @@ Sub ruteoNearestNeighbor(ruta As String, matriz As String) 'ignore
|
||||
Log("####################################################################")
|
||||
Dim g As ResultSet
|
||||
Private x As ResultSet = db.ExecQuery($"select id from ${ruta}_puntos"$)
|
||||
Private cont As Int = 0
|
||||
Private sqlWhere As String = ""
|
||||
Do While x.NextRow 'Ejecutamos el siguiente codigo la cantidad de veces que hay puntos.
|
||||
Private punto As ResultSet = db.ExecQuery($"select id, count(id) as regs from ${ruta}_punteo order by pos DESC limit 1"$)
|
||||
Do While punto.NextRow
|
||||
' Log($"Select idt, '${punto.GetString("id")}', nombre, lat, lon from R1_matriz join R1_puntos on idT = id where idT Not in (Select id from r1_punteo) order by '${punto.GetString("id")}' Asc limit 1"$)
|
||||
g = db.ExecQuery($"Select idt, '${punto.GetString("id")}', nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where idT Not in (Select id from ${ruta}_punteo) order by '${punto.GetString("id")}' Asc limit 1"$)
|
||||
Do While g.NextRow
|
||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values (${punto.GetString("regs")}, '${g.GetString("idT")}', '${g.GetString("nombre")}', '${g.GetString("lat")}', '${g.GetString("lon")}')"$)
|
||||
' Log(cont)
|
||||
If cont = 0 Then
|
||||
sqlWhere = $" idt = '_ACTUAL' and "$
|
||||
Private rs As ResultSet = db.ExecQuery($"select * from ${ruta}_puntos where id = '_ACTUAL'"$)
|
||||
Do While rs.NextRow
|
||||
Log(">>> Insertamos pos ACTUAL")
|
||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values (0, '${rs.GetString("id")}', '${rs.GetString("nombre")}', '${rs.GetString("lat")}', '${rs.GetString("lon")}')"$)
|
||||
Loop
|
||||
Else
|
||||
sqlWhere = ""
|
||||
End If
|
||||
Private punto As ResultSet = db.ExecQuery($"select id, count(id) as regs from ${ruta}_punteo order by pos DESC limit 1"$)
|
||||
' Do While punto.NextRow
|
||||
' Log(punto.GetString("id"))
|
||||
g = db.ExecQuery($"Select idt, "${punto.GetString("id")}", nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where ${sqlWhere} idT Not in (Select id from ${ruta}_punteo) order by "${punto.GetString("id")}" Asc limit 1"$)
|
||||
Log($"Select idt, "${punto.GetString("id")}", nombre, lat, lon from ${ruta}_matriz${matriz} join ${ruta}_puntos on idT = id where ${sqlWhere} idT Not in (Select id from ${ruta}_punteo) order by "${punto.GetString("id")}" Asc limit 1"$)
|
||||
Do While g.NextRow
|
||||
Log($">>>> insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values (${punto.GetString("regs")}, '${g.GetString("idT")}', '${g.GetString("nombre")}', '${g.GetString("lat")}', '${g.GetString("lon")}')"$)
|
||||
db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values (${punto.GetString("regs")}, '${g.GetString("idT")}', '${g.GetString("nombre")}', '${g.GetString("lat")}', '${g.GetString("lon")}')"$)
|
||||
Loop
|
||||
' Loop
|
||||
cont = cont + 1
|
||||
Loop
|
||||
' db.ExecNonQuery($"insert into ${ruta}_punteo (pos, id, nombre, lat, lon) values (${punto.GetString("regs")}, '${g.GetString("idT")}', '${g.GetString("nombre")}', '${g.GetString("lat")}', '${g.GetString("lon")}')"$)
|
||||
End Sub
|
||||
|
||||
'Nearest Insertion
|
||||
@@ -673,7 +676,7 @@ Public Sub calculateDistance3(lat1 As Double, lon1 As Double, lat2 As Double, lo
|
||||
Return Round(Yards)
|
||||
Catch
|
||||
Log("CalcDistance " & LastException)
|
||||
If error = "" Then error = LastException
|
||||
if error = "" then error = LastException
|
||||
Return -1
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user