@@ -80,7 +80,7 @@ public MiniGraphUI( GraphHopper hopper, boolean debug )
80
80
this .na = graph .getNodeAccess ();
81
81
prepare = hopper .getPreparation ();
82
82
encoder = hopper .getEncodingManager ().getSingle ();
83
- weighting = new PriorityWeighting (encoder );
83
+ weighting = hopper . createWeighting ( "fastest" , encoder ); // new PriorityWeighting(encoder);
84
84
if (prepare == null )
85
85
prepare = NoOpAlgorithmPreparation .createAlgoPrepare (graph , "dijkstrabi" , encoder , weighting );
86
86
@@ -179,7 +179,6 @@ public void paintComponent( Graphics2D g2 )
179
179
// mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, iter.getName());
180
180
//mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, "s:" + (int) encoder.getSpeed(iter.getFlags()));
181
181
//g2.setColor(Color.BLACK);
182
-
183
182
mg .plotEdge (g2 , lat , lon , lat2 , lon2 );
184
183
g2 .setColor (Color .BLACK );
185
184
}
@@ -205,35 +204,34 @@ public void paintComponent( Graphics2D g2 )
205
204
StopWatch sw = new StopWatch ().start ();
206
205
logger .info ("start searching from:" + fromRes + " to:" + toRes + " " + weighting );
207
206
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 ())
214
226
{
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 ;
221
229
}
222
230
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 );
237
235
}
238
236
});
239
237
@@ -277,7 +275,7 @@ private Path plotPath( Path tmpPath, Graphics2D g2, int w )
277
275
278
276
double prevLat = Double .NaN ;
279
277
double prevLon = Double .NaN ;
280
- boolean plotNodes = true ;
278
+ boolean plotNodes = false ;
281
279
TIntList nodes = tmpPath .calcNodes ();
282
280
if (plotNodes )
283
281
{
0 commit comments