-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated the project dependencies. - Added the required tools for the compilation of FlatBuffers schema files. - Cleaned up the test classes. - Added *empty* README files. - Cleaned up the .idea folder. - Reformatted and rearranged code. - Optimized imports. - Updated copyright.
- Loading branch information
1 parent
e1f6d07
commit f66f1d6
Showing
13 changed files
with
151 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 41 additions & 15 deletions
56
app/src/test/java/com/dimitrismantas/torch/UnitTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,61 @@ | ||
/* | ||
* Torch is an Android application for the optimal routing of offline | ||
* mobile devices. | ||
* Torch is a model open-source Android application for optimal routing | ||
* in offline mobile devices. | ||
* Copyright (C) 2021-2022 DIMITRIS(.)MANTAS(@outlook.com) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.dimitrismantas.torch; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import com.dimitrismantas.torch.core.main.Path; | ||
import com.dimitrismantas.torch.core.main.engine.AStar; | ||
import com.dimitrismantas.torch.core.main.utils.NearestNeighborSearch; | ||
import com.dimitrismantas.torch.core.utils.serialization.DeserializedGraph; | ||
import com.dimitrismantas.torch.core.utils.serialization.DeserializedVertex; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.RandomAccessFile; | ||
import java.nio.MappedByteBuffer; | ||
import java.nio.channels.FileChannel; | ||
|
||
public class UnitTests { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
public void routingTest() { | ||
final File serializedGraphPath = new File("C:\\Documents\\Torch\\app\\src\\main\\assets\\bin\\grc.bin"); | ||
|
||
MappedByteBuffer bb = null; | ||
try (final FileChannel fChannel = new RandomAccessFile(serializedGraphPath, "rw").getChannel()) { | ||
bb = fChannel.map(FileChannel.MapMode.PRIVATE, 0, fChannel.size()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
final DeserializedGraph graph = DeserializedGraph.getRootAsDeserializedGraph(bb); | ||
|
||
final double[] origin = {37.9838, 23.7275}; | ||
final double[] destination = {40.6401, 22.9444}; | ||
|
||
final NearestNeighborSearch nns = new NearestNeighborSearch(graph); | ||
final DeserializedVertex s = nns.run(origin[0], origin[1]); | ||
final DeserializedVertex t = nns.run(destination[0], destination[1]); | ||
|
||
final AStar aStar = new AStar(graph); | ||
final long t0 = System.nanoTime(); | ||
final Path route = aStar.run(s, t, AStar.OptimizationMode.MINIMIZE_DISTANCE); | ||
System.out.println((System.nanoTime() - t0) * 1e-6); | ||
System.out.println(route.getEndpoints().size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This is the eventual destination package of the compiled class. | ||
namespace com.dimitrismantas.torch.core.utils.serialization; | ||
|
||
// A table is roughly equivalent to a class in that it has fields of various types with both default and optional values. | ||
table DeserializedEdge { | ||
end_vertex_label:int; | ||
length:short; | ||
travel_time:short; | ||
} | ||
|
||
// This is the name of the top-level table in the schema. | ||
root_type DeserializedEdge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
include "DeserializedVertex.fbs"; | ||
|
||
// This is the eventual destination package of the compiled class. | ||
namespace com.dimitrismantas.torch.core.utils.serialization; | ||
|
||
// A table is roughly equivalent to a class in that it has fields of various types with both default and optional values. | ||
|
||
table DeserializedGraph { | ||
vertices:[DeserializedVertex]; | ||
} | ||
|
||
// This is the name of the top-level table in the schema. | ||
root_type DeserializedGraph; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include "DeserializedEdge.fbs"; | ||
|
||
// This is the eventual destination package of the compiled class. | ||
namespace com.dimitrismantas.torch.core.utils.serialization; | ||
|
||
// A table is roughly equivalent to a class in that it has fields of various types with both default and optional values. | ||
table DeserializedVertex { | ||
lbl:int; | ||
lat:float; | ||
lon:float; | ||
num_initialized:short = 0; | ||
actual_cost_from_source:int = 0; | ||
predecessor_label:int = -1; | ||
outgoing_edges:[DeserializedEdge]; | ||
} | ||
|
||
// This is the name of the top-level table in the schema. | ||
root_type DeserializedVertex; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flatc --java DeserializedEdge.fbs | ||
flatc --java --gen-mutable DeserializedVertex.fbs | ||
flatc --java DeserializedGraph.fbs | ||
PAUSE | ||
EXIT |
Empty file.