Skip to content

Commit

Permalink
reduce deprecation warnings when compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed May 13, 2016
1 parent 45b58bd commit f703618
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ConditionalTagsInspector( List<String> tagsToCheck, Set<String> restricti
public ConditionalTagsInspector( Calendar cal, List<String> tagsToCheck, Set<String> restrictiveValues, Set<String> permittedValues )
{
this.calendar = cal;
this.tagsToCheck = new ArrayList(tagsToCheck.size());
this.tagsToCheck = new ArrayList<>(tagsToCheck.size());
for (String tagToCheck : tagsToCheck)
{
this.tagsToCheck.add(tagToCheck + ":conditional");
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/java/com/graphhopper/GraphHopperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ public void testMultipleCHPreparationsInParallel()
GraphHopper tmpGH = new GraphHopper().setStoreOnFlush(false).
setEncodingManager(em).
setGraphHopperLocation(ghLoc).
setOSMFile(testOsm).setCHPrepareThreads(threadCount);
setOSMFile(testOsm);
tmpGH.getCHFactoryDecorator().setPreparationThreads(threadCount);

tmpGH.importOrLoad();

Expand Down
32 changes: 18 additions & 14 deletions core/src/test/java/com/graphhopper/reader/OSMReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.After;
import org.junit.Before;
Expand All @@ -40,9 +39,9 @@
import com.graphhopper.GHResponse;
import com.graphhopper.reader.dem.ElevationProvider;
import com.graphhopper.reader.dem.SRTMProvider;
import com.graphhopper.routing.DijkstraBidirectionRef;
import com.graphhopper.routing.util.*;
import com.graphhopper.storage.*;
import com.graphhopper.storage.index.LocationIndex;
import com.graphhopper.storage.index.QueryResult;
import com.graphhopper.util.EdgeExplorer;
import com.graphhopper.util.EdgeIterator;
Expand Down Expand Up @@ -210,21 +209,26 @@ public void testMain()
assertEquals(93146.888, iter.getDistance(), 1);

NodeAccess na = graph.getNodeAccess();
assertEquals(9.4, na.getLongitude(hopper.getLocationIndex().findID(51.2, 9.4)), 1e-3);
assertEquals(10, na.getLongitude(hopper.getLocationIndex().findID(49, 10)), 1e-3);
assertEquals(51.249, na.getLatitude(hopper.getLocationIndex().findID(51.2492152, 9.4317166)), 1e-3);
assertEquals(9.4, na.getLongitude(findID(hopper.getLocationIndex(), 51.2, 9.4)), 1e-3);
assertEquals(10, na.getLongitude(findID(hopper.getLocationIndex(), 49, 10)), 1e-3);
assertEquals(51.249, na.getLatitude(findID(hopper.getLocationIndex(), 51.2492152, 9.4317166)), 1e-3);

// node 40 is on the way between 30 and 50 => 9.0
assertEquals(9, na.getLongitude(hopper.getLocationIndex().findID(51.25, 9.43)), 1e-3);
assertEquals(9, na.getLongitude(findID(hopper.getLocationIndex(), 51.25, 9.43)), 1e-3);
}

protected int findID( LocationIndex index, double lat, double lon )
{
return index.findClosest(lat, lon, EdgeFilter.ALL_EDGES).getClosestNode();
}

@Test
public void testSort()
{
GraphHopper hopper = new GraphHopperTest(file1).setSortGraph(true).importOrLoad();
NodeAccess na = hopper.getGraphHopperStorage().getNodeAccess();
assertEquals(10, na.getLongitude(hopper.getLocationIndex().findID(49, 10)), 1e-3);
assertEquals(51.249, na.getLatitude(hopper.getLocationIndex().findID(51.2492152, 9.4317166)), 1e-3);
assertEquals(10, na.getLongitude(findID(hopper.getLocationIndex(), 49, 10)), 1e-3);
assertEquals(51.249, na.getLatitude(findID(hopper.getLocationIndex(), 51.2492152, 9.4317166)), 1e-3);
}

@Test
Expand Down Expand Up @@ -459,7 +463,7 @@ public void testBarriers()
assertEquals(na.getLatitude(n20), na.getLatitude(new20), 1e-5);
assertEquals(na.getLongitude(n20), na.getLongitude(new20), 1e-5);

assertEquals(n20, hopper.getLocationIndex().findID(52, 9.4));
assertEquals(n20, findID(hopper.getLocationIndex(), 52, 9.4));

assertEquals(GHUtility.asSet(n20, n30), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n10)));
assertEquals(GHUtility.asSet(new20, n10, n50), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n30)));
Expand Down Expand Up @@ -861,11 +865,11 @@ public void testCrossBoundary_issue667()

public void testRoutingRequestFails_issue665()
{
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("src/test/resources/com/graphhopper/reader/" + file7);
hopper.setEncodingManager(new EncodingManager("car,motorcycle"));
hopper.setCHEnable(false);
hopper.setGraphHopperLocation(dir);
GraphHopper hopper = new GraphHopper()
.setOSMFile("src/test/resources/com/graphhopper/reader/" + file7)
.setEncodingManager(new EncodingManager("car,motorcycle"))
.setGraphHopperLocation(dir);
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.importOrLoad();
GHRequest req = new GHRequest(48.97725592769741, 8.256896138191223, 48.978875552977684, 8.25486302375793).
setWeighting("curvature").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
*/
package com.graphhopper.storage.index;

import com.graphhopper.routing.util.CarFlagEncoder;
import com.graphhopper.routing.util.DefaultEdgeFilter;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.routing.util.FootFlagEncoder;
import com.graphhopper.routing.util.*;
import com.graphhopper.storage.*;
import com.graphhopper.util.DistanceCalc;
import com.graphhopper.util.DistanceCalcEarth;
Expand Down Expand Up @@ -58,6 +55,10 @@ GraphHopperStorage createGHStorage( Directory dir, EncodingManager encodingManag
return new GraphHopperStorage(dir, encodingManager, is3D, new GraphExtension.NoOpExtension()).create(100);
}

protected int findID(LocationIndex index, double lat, double lon) {
return index.findClosest(lat, lon, EdgeFilter.ALL_EDGES).getClosestNode();
}

public boolean hasEdgeSupport()
{
return false;
Expand All @@ -84,17 +85,17 @@ public void testSimpleGraph()
initSimpleGraph(g);

idx = createIndex(g, -1);
assertEquals(4, idx.findID(5, 2));
assertEquals(3, idx.findID(1.5, 2));
assertEquals(0, idx.findID(-1, -1));
assertEquals(4, findID(idx, 5, 2));
assertEquals(3, findID(idx, 1.5, 2));
assertEquals(0, findID(idx, -1, -1));

if (hasEdgeSupport())
// now get the edge 1-4 and not node 6
{
assertEquals(4, idx.findID(4, 0));
assertEquals(4, findID(idx, 4, 0));
} else
{
assertEquals(6, idx.findID(4, 0));
assertEquals(6, findID(idx, 4, 0));
}
Helper.close((Closeable) g);
}
Expand Down Expand Up @@ -138,21 +139,21 @@ public void testSimpleGraph2()
initSimpleGraph(g);

idx = createIndex(g, -1);
assertEquals(4, idx.findID(5, 2));
assertEquals(3, idx.findID(1.5, 2));
assertEquals(0, idx.findID(-1, -1));
assertEquals(6, idx.findID(4.5, -0.5));
assertEquals(4, findID(idx, 5, 2));
assertEquals(3, findID(idx, 1.5, 2));
assertEquals(0, findID(idx, -1, -1));
assertEquals(6, findID(idx, 4.5, -0.5));
if (hasEdgeSupport())
{
assertEquals(4, idx.findID(4, 1));
assertEquals(4, idx.findID(4, 0));
assertEquals(4, findID(idx, 4, 1));
assertEquals(4, findID(idx, 4, 0));
} else
{
assertEquals(6, idx.findID(4, 1));
assertEquals(6, idx.findID(4, 0));
assertEquals(6, findID(idx, 4, 1));
assertEquals(6, findID(idx, 4, 0));
}
assertEquals(6, idx.findID(4, -2));
assertEquals(5, idx.findID(3, 3));
assertEquals(6, findID(idx, 4, -2));
assertEquals(5, findID(idx, 3, 3));
Helper.close((Closeable) g);
}

Expand All @@ -171,7 +172,7 @@ public void testGrid()
{
double lat = na.getLatitude(i);
double lon = na.getLongitude(i);
assertEquals("nodeId:" + i + " " + (float) lat + "," + (float) lon, i, idx.findID(lat, lon));
assertEquals("nodeId:" + i + " " + (float) lat + "," + (float) lon, i, findID(idx, lat, lon));
}

// hit random lat,lon and compare result to full index
Expand All @@ -187,11 +188,11 @@ public void testGrid()
{
double lat = rand.nextDouble() * 5;
double lon = rand.nextDouble() * 5;
int fullId = fullIndex.findID(lat, lon);
int fullId = findID(fullIndex, lat, lon);
double fullLat = na.getLatitude(fullId);
double fullLon = na.getLongitude(fullId);
float fullDist = (float) dist.calcDist(lat, lon, fullLat, fullLon);
int newId = idx.findID(lat, lon);
int newId = findID(idx, lat, lon);
double newLat = na.getLatitude(newId);
double newLon = na.getLongitude(newId);
float newDist = (float) dist.calcDist(lat, lon, newLat, newLon);
Expand Down Expand Up @@ -222,13 +223,13 @@ public void testSinglePoints120()
Graph g = createSampleGraph(new EncodingManager("CAR"));
idx = createIndex(g, -1);

assertEquals(1, idx.findID(1.637, 2.23));
assertEquals(10, idx.findID(3.649, 1.375));
assertEquals(9, idx.findID(3.3, 2.2));
assertEquals(6, idx.findID(3.0, 1.5));
assertEquals(1, findID(idx, 1.637, 2.23));
assertEquals(10, findID(idx, 3.649, 1.375));
assertEquals(9, findID(idx, 3.3, 2.2));
assertEquals(6, findID(idx, 3.0, 1.5));

assertEquals(10, idx.findID(3.8, 0));
assertEquals(10, idx.findID(3.8466, 0.021));
assertEquals(10, findID(idx, 3.8, 0));
assertEquals(10, findID(idx, 3.8466, 0.021));
Helper.close((Closeable) g);
}

Expand All @@ -239,16 +240,16 @@ public void testSinglePoints32()
idx = createIndex(g, -1);

// 10 or 6
assertEquals(10, idx.findID(3.649, 1.375));
assertEquals(10, idx.findID(3.8465748, 0.021762699));
assertEquals(10, findID(idx, 3.649, 1.375));
assertEquals(10, findID(idx, 3.8465748, 0.021762699));
if (hasEdgeSupport())
{
assertEquals(4, idx.findID(2.485, 1.373));
assertEquals(4, findID(idx, 2.485, 1.373));
} else
{
assertEquals(6, idx.findID(2.485, 1.373));
assertEquals(6, findID(idx, 2.485, 1.373));
}
assertEquals(0, idx.findID(0.64628404, 0.53006625));
assertEquals(0, findID(idx, 0.64628404, 0.53006625));
Helper.close((Closeable) g);
}

Expand Down Expand Up @@ -355,7 +356,7 @@ public void testDifferentVehicles()
Graph g = AbstractLocationIndexTester.this.createGHStorage(encodingManager);
initSimpleGraph(g);
idx = createIndex(g, -1);
assertEquals(1, idx.findID(1, -1));
assertEquals(1, findID(idx, 1, -1));

// now make all edges from node 1 accessible for CAR only
EdgeIterator iter = g.createEdgeExplorer().setBaseNode(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public void testGrid()
@Test
public void testFullIndex()
{
LocationIndex idx = new Location2IDFullIndex(createSampleGraph(new EncodingManager("CAR")));
assertEquals(5, idx.findID(2, 3));
assertEquals(10, idx.findID(4, 1));
assertEquals(10, idx.findID(3.6, 1.4));
LocationIndex tmpIdx = new Location2IDFullIndex(createSampleGraph(new EncodingManager("CAR")));
assertEquals(5, findID(tmpIdx, 2, 3));
assertEquals(10, findID(tmpIdx, 4, 1));
assertEquals(10, findID(tmpIdx, 3.6, 1.4));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public void testGrid()
@Test
public void testFullIndex()
{
LocationIndex idx = new Location2IDFullWithEdgesIndex(createSampleGraph(new EncodingManager("CAR")));
assertEquals(5, idx.findID(2, 3));
assertEquals(10, idx.findID(4, 1));
LocationIndex tmpIdx = new Location2IDFullWithEdgesIndex(createSampleGraph(new EncodingManager("CAR")));
assertEquals(5, findID(tmpIdx, 2, 3));
assertEquals(10, findID(tmpIdx, 4, 1));
// 6, 9 or 10
assertEquals(10, idx.findID(3.6, 1.4));
assertEquals(10, findID(tmpIdx, 3.6, 1.4));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testCHGraph()
tmp.setSkippedEdges(iter5.getEdge(), iter6.getEdge());

LocationIndex index = createIndex(ghStorage, -1);
assertEquals(2, index.findID(0, 0.5));
assertEquals(2, findID(index, 0, 0.5));
}

@Test
Expand Down Expand Up @@ -174,9 +174,9 @@ public void testCHGraphBug()
expectedSet.add(2);
assertEquals(expectedSet, set);

assertEquals(0, index.findID(0.51, 0.2));
assertEquals(1, index.findID(0.1, 0.1));
assertEquals(2, index.findID(0.51, 0.51));
assertEquals(3, index.findID(0.51, 1.1));
assertEquals(0, findID(index, 0.51, 0.2));
assertEquals(1, findID(index, 0.1, 0.1));
assertEquals(2, findID(index, 0.51, 0.51));
assertEquals(3, findID(index, 0.51, 1.1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void testInMemIndex()
index.findNetworkEntries(-0.5, -0.9, foundIds, 0);
index.findNetworkEntries(-0.5, -0.9, foundIds, 1);
assertEquals(set, foundIds);
assertEquals(2, index.findID(-0.5, -0.9));
assertEquals(2, findID(index, -0.5, -0.9));

// The optimization if(dist > normedHalf) => feed nodeA or nodeB
// although this reduces chance of nodes outside of the tile
Expand Down Expand Up @@ -239,7 +239,7 @@ public void testMoreReal()
graph.edge(0, 2, 1000, true);
graph.edge(0, 3, 1000, true).setWayGeometry(Helper.createPointList(51.21, 9.43));
LocationIndex index = createIndex(graph, -1);
assertEquals(2, index.findID(51.2, 9.4));
assertEquals(2, findID(index, 51.2, 9.4));
}

// -1 0 1 1.5
Expand Down Expand Up @@ -276,10 +276,10 @@ public void testWayGeometry()
{
Graph g = createTestGraphWithWayGeometry();
LocationIndex index = createIndex(g, -1);
assertEquals(1, index.findID(0, 0));
assertEquals(1, index.findID(0, 0.1));
assertEquals(1, index.findID(0.1, 0.1));
assertEquals(1, index.findID(-0.5, -0.5));
assertEquals(1, findID(index, 0, 0));
assertEquals(1, findID(index, 0, 0.1));
assertEquals(1, findID(index, 0.1, 0.1));
assertEquals(1, findID(index, -0.5, -0.5));
}

@Test
Expand All @@ -296,7 +296,7 @@ public void testFindingWayGeometry()
g.edge(20, 30, 1, true);

LocationIndex index = createIndex(g, 2000);
assertEquals(20, index.findID(51.25, 9.43));
assertEquals(20, findID(index, 51.25, 9.43));
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
<version>3.5.1</version>
<configuration>
<!--
<compilerArgument>-Xlint:unchecked</compilerArgument>
<compilerArgument>-Xlint:unchecked</compilerArgument>
<compilerArgument>-Xlint:deprecation</compilerArgument>
-->

<!-- suppress warning about Unsafe functionality -->
Expand Down

0 comments on commit f703618

Please sign in to comment.