Skip to content

Commit ac13c0e

Browse files
author
Peter
committed
tools: switch to normal routing
1 parent 7a6e067 commit ac13c0e

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

tools/src/main/java/com/graphhopper/ui/MiniGraphUI.java

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public MiniGraphUI( GraphHopper hopper, boolean debug )
8080
this.na = graph.getNodeAccess();
8181
prepare = hopper.getPreparation();
8282
encoder = hopper.getEncodingManager().getSingle();
83-
weighting = new PriorityWeighting(encoder);
83+
weighting = hopper.createWeighting("fastest", encoder); //new PriorityWeighting(encoder);
8484
if (prepare == null)
8585
prepare = NoOpAlgorithmPreparation.createAlgoPrepare(graph, "dijkstrabi", encoder, weighting);
8686

@@ -179,7 +179,6 @@ public void paintComponent( Graphics2D g2 )
179179
// mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, iter.getName());
180180
//mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, "s:" + (int) encoder.getSpeed(iter.getFlags()));
181181
//g2.setColor(Color.BLACK);
182-
183182
mg.plotEdge(g2, lat, lon, lat2, lon2);
184183
g2.setColor(Color.BLACK);
185184
}
@@ -205,35 +204,34 @@ public void paintComponent( Graphics2D g2 )
205204
StopWatch sw = new StopWatch().start();
206205
logger.info("start searching from:" + fromRes + " to:" + toRes + " " + weighting);
207206

208-
GHPoint qp = fromRes.getQueryPoint();
209-
TIntHashSet set = index.findNetworkEntries(qp.lat, qp.lon, 1);
210-
TIntIterator nodeIter = set.iterator();
211-
DistanceCalc distCalc = new DistancePlaneProjection();
212-
System.out.println("set:" + set.size());
213-
while (nodeIter.hasNext())
207+
// GHPoint qp = fromRes.getQueryPoint();
208+
// TIntHashSet set = index.findNetworkEntries(qp.lat, qp.lon, 1);
209+
// TIntIterator nodeIter = set.iterator();
210+
// DistanceCalc distCalc = new DistancePlaneProjection();
211+
// System.out.println("set:" + set.size());
212+
// while (nodeIter.hasNext())
213+
// {
214+
// int nodeId = nodeIter.next();
215+
// double lat = graph.getNodeAccess().getLat(nodeId);
216+
// double lon = graph.getNodeAccess().getLon(nodeId);
217+
// int dist = (int) Math.round(distCalc.calcDist(qp.lat, qp.lon, lat, lon));
218+
// mg.plotText(g2, lat, lon, nodeId + ": " + dist);
219+
// mg.plotNode(g2, nodeId, Color.red);
220+
// }
221+
path = algo.calcPath(fromRes, toRes);
222+
sw.stop();
223+
224+
// if directed edges
225+
if (!path.isFound())
214226
{
215-
int nodeId = nodeIter.next();
216-
double lat = graph.getNodeAccess().getLat(nodeId);
217-
double lon = graph.getNodeAccess().getLon(nodeId);
218-
int dist = (int) Math.round(distCalc.calcDist(qp.lat, qp.lon, lat, lon));
219-
mg.plotText(g2, lat, lon, nodeId + ": " + dist);
220-
mg.plotNode(g2, nodeId, Color.red);
227+
logger.warn("path not found! direction not valid?");
228+
return;
221229
}
222230

223-
// path = algo.calcPath(fromRes, toRes);
224-
// sw.stop();
225-
//
226-
// // if directed edges
227-
// if (!path.isFound())
228-
// {
229-
// logger.warn("path not found! direction not valid?");
230-
// return;
231-
// }
232-
//
233-
// logger.info("found path in " + sw.getSeconds() + "s with nodes:"
234-
// + path.calcNodes().size() + ", millis: " + path.getMillis() + ", " + path);
235-
// g2.setColor(Color.BLUE.brighter().brighter());
236-
// plotPath(path, g2, 1);
231+
logger.info("found path in " + sw.getSeconds() + "s with nodes:"
232+
+ path.calcNodes().size() + ", millis: " + path.getMillis() + ", " + path);
233+
g2.setColor(Color.BLUE.brighter().brighter());
234+
plotPath(path, g2, 1);
237235
}
238236
});
239237

@@ -277,7 +275,7 @@ private Path plotPath( Path tmpPath, Graphics2D g2, int w )
277275

278276
double prevLat = Double.NaN;
279277
double prevLon = Double.NaN;
280-
boolean plotNodes = true;
278+
boolean plotNodes = false;
281279
TIntList nodes = tmpPath.calcNodes();
282280
if (plotNodes)
283281
{

0 commit comments

Comments
 (0)