use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class LocationIndexTreeTest method testSearchWithFilter_issue318.
@Test
public void testSearchWithFilter_issue318() {
CarFlagEncoder carEncoder = new CarFlagEncoder();
BikeFlagEncoder bikeEncoder = new BikeFlagEncoder();
EncodingManager tmpEM = new EncodingManager(carEncoder, bikeEncoder);
Graph graph = createGHStorage(new RAMDirectory(), tmpEM, false);
NodeAccess na = graph.getNodeAccess();
// distance from point to point is roughly 1 km
int MAX = 5;
for (int latIdx = 0; latIdx < MAX; latIdx++) {
for (int lonIdx = 0; lonIdx < MAX; lonIdx++) {
int index = lonIdx * 10 + latIdx;
na.setNode(index, 0.01 * latIdx, 0.01 * lonIdx);
if (latIdx < MAX - 1)
graph.edge(index, index + 1, 1000, true);
if (lonIdx < MAX - 1)
graph.edge(index, index + 10, 1000, true);
}
}
// reduce access for bike to two edges only
AllEdgesIterator iter = graph.getAllEdges();
while (iter.next()) {
iter.setFlags(bikeEncoder.setAccess(iter.getFlags(), false, false));
}
for (EdgeIteratorState edge : Arrays.asList(GHUtility.getEdge(graph, 0, 1), GHUtility.getEdge(graph, 1, 2))) {
edge.setFlags(bikeEncoder.setAccess(edge.getFlags(), true, true));
}
LocationIndexTree index = createIndexNoPrepare(graph, 500);
index.prepareIndex();
index.setMaxRegionSearch(8);
EdgeFilter carFilter = new DefaultEdgeFilter(carEncoder, true, true);
QueryResult qr = index.findClosest(0.03, 0.03, carFilter);
assertTrue(qr.isValid());
assertEquals(33, qr.getClosestNode());
EdgeFilter bikeFilter = new DefaultEdgeFilter(bikeEncoder, true, true);
qr = index.findClosest(0.03, 0.03, bikeFilter);
assertTrue(qr.isValid());
assertEquals(2, qr.getClosestNode());
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class Location2IDQuadtreeTest method testNormedDist.
@Test
public void testNormedDist() {
Location2IDQuadtree index = new Location2IDQuadtree(createGHStorage(new EncodingManager("car")), new RAMDirectory());
index.initAlgo(5, 6);
assertEquals(1, index.getNormedDist(0, 1), 1e-6);
assertEquals(2, index.getNormedDist(0, 7), 1e-6);
assertEquals(2, index.getNormedDist(7, 2), 1e-6);
assertEquals(1, index.getNormedDist(7, 1), 1e-6);
assertEquals(4, index.getNormedDist(13, 25), 1e-6);
assertEquals(8, index.getNormedDist(15, 25), 1e-6);
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class AbstractEdgeElevationInterpolatorTest method setUp.
@SuppressWarnings("resource")
@Before
public void setUp() {
dataFlagEncoder = new DataFlagEncoder();
graph = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(Arrays.asList(dataFlagEncoder, new FootFlagEncoder()), 8), true, new GraphExtension.NoOpExtension()).create(100);
edgeElevationInterpolator = createEdgeElevationInterpolator();
interpolatableWay = createInterpolatableWay();
normalWay = new ReaderWay(0);
normalWay.setTag("highway", "primary");
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class OSMIDMapTest method testUpdateOfLowerKeys.
@Test
public void testUpdateOfLowerKeys() {
OSMIDMap map = new OSMIDMap(new RAMDirectory());
map.put(9, 0);
map.put(10, 1);
map.put(11, 2);
map.put(9, 3);
assertEquals(2, map.get(11));
assertEquals(3, map.get(9));
}
use of com.graphhopper.storage.RAMDirectory in project graphhopper by graphhopper.
the class OSMIDMapTest method testGet2.
@Test
public void testGet2() {
OSMIDMap map = new OSMIDMap(new RAMDirectory());
map.put(9, 0);
map.put(10, 1);
map.put(11, 2);
map.put(12, 3);
map.put(13, 4);
map.put(14, 5);
map.put(16, 6);
map.put(18, 7);
map.put(19, 8);
assertEquals(9, map.getSize());
assertEquals(-1, map.get(8));
assertEquals(0, map.get(9));
assertEquals(1, map.get(10));
assertEquals(2, map.get(11));
assertEquals(3, map.get(12));
assertEquals(4, map.get(13));
assertEquals(5, map.get(14));
assertEquals(6, map.get(16));
assertEquals(-1, map.get(17));
assertEquals(7, map.get(18));
assertEquals(8, map.get(19));
}
Aggregations