@Override public int compare(QueryResult o1, QueryResult o2) { return Double.compare(o1.getQueryDistance(), o2.getQueryDistance()); } };
@Override protected boolean goFurther(int baseNode) { if (baseNode == id) return true; goFurtherHook(baseNode); double currLat = nodeAccess.getLatitude(baseNode); double currLon = nodeAccess.getLongitude(baseNode); double currNormedDist = distCalc.calcNormalizedDist(queryLat, queryLon, currLat, currLon); if (currNormedDist < res.getQueryDistance()) { res.setQueryDistance(currNormedDist); res.setClosestNode(baseNode); return true; } return currNormedDist < maxRasterWidth2InMeterNormed; } }.start(graph.createEdgeExplorer(), id);
res.setQueryDistance(distCalc.calcDenormalizedDist(res.getQueryDistance())); return res;
if (qr.isValid()) { qr.setQueryDistance(distCalc.calcDenormalizedDist(qr.getQueryDistance())); qr.calcSnappedPoint(distCalc); } else {
closestMatch.setQueryDistance(distCalc.calcDenormalizedDist(closestMatch.getQueryDistance())); closestMatch.calcSnappedPoint(distCalc);
@Test public void testSnappedPointAndGeometry() { Graph graph = createTestGraph(encodingManager); LocationIndex index = createIndex(graph, -1); // query directly the tower node QueryResult res = index.findClosest(-0.4, 0.9, EdgeFilter.ALL_EDGES); assertTrue(res.isValid()); assertEquals(new GHPoint(-0.4, 0.9), res.getSnappedPoint()); res = index.findClosest(-0.6, 1.6, EdgeFilter.ALL_EDGES); assertTrue(res.isValid()); assertEquals(new GHPoint(-0.6, 1.6), res.getSnappedPoint()); // query the edge (1,3). The edge (0,4) has 27674 as distance res = index.findClosest(-0.2, 0.3, EdgeFilter.ALL_EDGES); assertTrue(res.isValid()); assertEquals(26936, res.getQueryDistance(), 1); assertEquals(new GHPoint(-0.441624, 0.317259), res.getSnappedPoint()); }
@Override public String toString() { return "entry:" + entry + ", query distance:" + queryResult.getQueryDistance() + ", gpxListIndex:" + gpxListIndex; }
@Override public int compare(QueryResult o1, QueryResult o2) { return Double.compare(o1.getQueryDistance(), o2.getQueryDistance()); } };
@Override public int compare(QueryResult o1, QueryResult o2) { return Double.compare(o1.getQueryDistance(), o2.getQueryDistance()); } };
@Override public int compare(QueryResult o1, QueryResult o2) { return Double.compare(o1.getQueryDistance(), o2.getQueryDistance()); } };
public double getMinDistance() { if (isEmpty()) { throw new IllegalStateException("No minimal distance for " + edgeState); } double min = Double.MAX_VALUE; for (GPXExtension gpxExt : gpxExtensions) { if (gpxExt.queryResult.getQueryDistance() < min) { min = gpxExt.queryResult.getQueryDistance(); } } return min; }
public double getMinDistance() { if (isEmpty()) { throw new IllegalStateException("No minimal distance for " + edgeState); } double min = Double.MAX_VALUE; for (GPXExtension gpxExt : gpxExtensions) { if (gpxExt.getQueryResult().getQueryDistance() < min) { min = gpxExt.getQueryResult().getQueryDistance(); } } return min; }
public double getMinDistance() { if (isEmpty()) { throw new IllegalStateException("No minimal distance for " + edgeState); } double min = Double.MAX_VALUE; for (GPXExtension gpxExt : gpxExtensions) { if (gpxExt.getQueryResult().getQueryDistance() < min) { min = gpxExt.getQueryResult().getQueryDistance(); } } return min; }
private String getSnappedCandidates(Collection<GPXExtension> candidates) { String str = ""; for (GPXExtension gpxe : candidates) { if (!str.isEmpty()) { str += ", "; } str += "distance: " + gpxe.getQueryResult().getQueryDistance() + " to " + gpxe.getQueryResult().getSnappedPoint(); } return "[" + str + "]"; }
private String getSnappedCandidates(Collection<GPXExtension> candidates) { String str = ""; for (GPXExtension gpxe : candidates) { if (!str.isEmpty()) { str += ", "; } str += "distance: " + gpxe.getQueryResult().getQueryDistance() + " to " + gpxe.getQueryResult().getSnappedPoint(); } return "[" + str + "]"; }
private void computeEmissionProbabilities(TimeStep<GPXExtension, GPXEntry, Path> timeStep, HmmProbabilities probabilities) { for (GPXExtension candidate : timeStep.candidates) { // road distance difference in meters final double distance = candidate.getQueryResult().getQueryDistance(); timeStep.addEmissionLogProbability(candidate, probabilities.emissionLogProbability(distance)); } }
private void computeEmissionProbabilities(TimeStep<GPXExtension, GPXEntry, Path> timeStep, HmmProbabilities probabilities) { for (GPXExtension candidate : timeStep.candidates) { // road distance difference in meters final double distance = candidate.getQueryResult().getQueryDistance(); timeStep.addEmissionLogProbability(candidate, probabilities.emissionLogProbability(distance)); } }
@Override protected boolean goFurther(int baseNode) { if (baseNode == id) return true; goFurtherHook(baseNode); double currLat = nodeAccess.getLatitude(baseNode); double currLon = nodeAccess.getLongitude(baseNode); double currNormedDist = distCalc.calcNormalizedDist(queryLat, queryLon, currLat, currLon); if (currNormedDist < res.getQueryDistance()) { res.setQueryDistance(currNormedDist); res.setClosestNode(baseNode); return true; } return currNormedDist < maxRasterWidth2InMeterNormed; } }.start(graph.createEdgeExplorer(), id);
@Override protected boolean goFurther(int baseNode) { if (baseNode == id) return true; goFurtherHook(baseNode); double currLat = nodeAccess.getLatitude(baseNode); double currLon = nodeAccess.getLongitude(baseNode); double currNormedDist = distCalc.calcNormalizedDist(queryLat, queryLon, currLat, currLon); if (currNormedDist < res.getQueryDistance()) { res.setQueryDistance(currNormedDist); res.setClosestNode(baseNode); return true; } return currNormedDist < maxRasterWidth2InMeterNormed; } }.start(graph.createEdgeExplorer(), id);
public Path extractPath(Collection<QueryResult> endQRs) { // pick QueryResult closest to last GPX entry // => prefer QueryResults close to the edge double bestWeight = Double.MAX_VALUE; for (QueryResult qr : endQRs) { int node = qr.getClosestNode(); SPTEntry tmp1 = fromMap.get(node); double w = weighting.getMinWeight(qr.getQueryDistance() * maxSearchWeightMultiplier); if (tmp1 != null && bestWeight > tmp1.weight + w) { currEdge = tmp1; bestWeight = tmp1.weight + w; } } return new Path(graph, flagEncoder).setWeight(currEdge.weight).setSPTEntry(currEdge).extract(); } }