@@ -113,7 +113,7 @@ void start(PMap args) throws IOException {
113
113
put ("measurement.gitinfo" , args .getString ("measurement.gitinfo" , "" ));
114
114
int count = args .getInt ("measurement.count" , 5000 );
115
115
put ("measurement.map" , args .getString ("datareader.file" , "unknown" ));
116
-
116
+ String blockAreaStr = args . getString ( "measurement.block_area" , "" );
117
117
final boolean useMeasurementTimeAsRefTime = args .getBool ("measurement.use_measurement_time_as_ref_time" , false );
118
118
if (useMeasurementTimeAsRefTime && !useJson ) {
119
119
throw new IllegalArgumentException ("Using measurement time as reference time only works with json files" );
@@ -185,16 +185,16 @@ protected DataReader importData() throws IOException {
185
185
GHBitSet allowedEdges = printGraphDetails (g , vehicleStr );
186
186
printMiscUnitPerfTests (g , isCH , encoder , count * 100 , allowedEdges );
187
187
printLocationIndexQuery (g , hopper .getLocationIndex (), count );
188
- String blockAreaStr = "49.394664,11.144428,49.348388,11.144943,49.355768,11.227169,49.411643,11.227512" ;
188
+
189
189
if (runSlow ) {
190
190
printTimeOfRouteQuery (hopper , new QuerySettings ("routing" , vehicleStr , count / 20 , isCH , isLM ).
191
191
withInstructions ());
192
- if (encoder .supportsTurnCosts ()) {
192
+ if (encoder .supportsTurnCosts ())
193
193
printTimeOfRouteQuery (hopper , new QuerySettings ("routing_edge" , vehicleStr , count / 20 , isCH , isLM ).
194
194
withInstructions ().edgeBased ());
195
- }
196
- printTimeOfRouteQuery (hopper , new QuerySettings ("routing_block_area" , vehicleStr , count / 20 , isCH , isLM ).
197
- withInstructions ().blockArea (blockAreaStr ));
195
+ if (! blockAreaStr . isEmpty ())
196
+ printTimeOfRouteQuery (hopper , new QuerySettings ("routing_block_area" , vehicleStr , count / 20 , isCH , isLM ).
197
+ withInstructions ().blockArea (blockAreaStr ));
198
198
}
199
199
200
200
if (hopper .getLMPreparationHandler ().isEnabled ()) {
@@ -210,8 +210,9 @@ protected DataReader importData() throws IOException {
210
210
}
211
211
212
212
final int blockAreaActiveLMCount = 8 ;
213
- printTimeOfRouteQuery (hopper , new QuerySettings ("routingLM" + blockAreaActiveLMCount + "_block_area" , vehicleStr , count / 4 , isCH , isLM ).
214
- withInstructions ().activeLandmarks (blockAreaActiveLMCount ).blockArea (blockAreaStr ));
213
+ if (!blockAreaStr .isEmpty ())
214
+ printTimeOfRouteQuery (hopper , new QuerySettings ("routingLM" + blockAreaActiveLMCount + "_block_area" , vehicleStr , count / 4 , isCH , isLM ).
215
+ withInstructions ().activeLandmarks (blockAreaActiveLMCount ).blockArea (blockAreaStr ));
215
216
// compareRouting(hopper, vehicleStr, count / 5);
216
217
}
217
218
@@ -628,7 +629,8 @@ private void printTimeOfRouteQuery(final GraphHopper hopper, final QuerySettings
628
629
final AtomicInteger failedCount = new AtomicInteger (0 );
629
630
final DistanceCalc distCalc = new DistanceCalcEarth ();
630
631
631
- final EdgeExplorer edgeExplorer = g .createEdgeExplorer (DefaultEdgeFilter .allEdges (hopper .getEncodingManager ().getEncoder (querySettings .vehicle )));
632
+ final EdgeFilter edgeFilter = DefaultEdgeFilter .allEdges (hopper .getEncodingManager ().getEncoder (querySettings .vehicle ));
633
+ final EdgeExplorer edgeExplorer = g .createEdgeExplorer (edgeFilter );
632
634
final AtomicLong visitedNodesSum = new AtomicLong (0 );
633
635
final AtomicLong maxVisitedNodes = new AtomicLong (0 );
634
636
// final AtomicLong extractTimeSum = new AtomicLong(0);
@@ -641,15 +643,34 @@ private void printTimeOfRouteQuery(final GraphHopper hopper, final QuerySettings
641
643
MiniPerfTest miniPerf = new MiniPerfTest () {
642
644
@ Override
643
645
public int doCalc (boolean warmup , int run ) {
644
- int from = rand .nextInt (maxNode );
645
- int to = rand .nextInt (maxNode );
646
- double fromLat = na .getLatitude (from );
647
- double fromLon = na .getLongitude (from );
648
- double toLat = na .getLatitude (to );
649
- double toLon = na .getLongitude (to );
650
- GHRequest req = new GHRequest (fromLat , fromLon , toLat , toLon ).
651
- setWeighting (weighting ).
652
- setVehicle (querySettings .vehicle );
646
+ int from = -1 , to = -1 ;
647
+ Double fromLat = null , fromLon = null , toLat = null , toLon = null ;
648
+ GHRequest req = null ;
649
+
650
+ for (int i = 0 ; i < 5 ; i ++) {
651
+ from = rand .nextInt (maxNode );
652
+ to = rand .nextInt (maxNode );
653
+ fromLat = na .getLatitude (from );
654
+ fromLon = na .getLongitude (from );
655
+ toLat = na .getLatitude (to );
656
+ toLon = na .getLongitude (to );
657
+ req = new GHRequest (fromLat , fromLon , toLat , toLon ).
658
+ setWeighting (weighting ).
659
+ setVehicle (querySettings .vehicle );
660
+
661
+ if (querySettings .blockArea == null )
662
+ break ;
663
+
664
+ try {
665
+ req .getHints ().putObject (BLOCK_AREA , querySettings .blockArea );
666
+ GraphEdgeIdFinder .createBlockArea (hopper .getGraphHopperStorage (), hopper .getLocationIndex (), req .getPoints (), req .getHints (), edgeFilter );
667
+ break ;
668
+ } catch (IllegalArgumentException ex ) {
669
+ if (i >= 4 )
670
+ throw new RuntimeException ("Give up after 5 trials. Cannot find points outside of the block_area "
671
+ + querySettings .blockArea + " - too big block_area or map too small? Request:" + req );
672
+ }
673
+ }
653
674
654
675
req .getHints ().putObject (CH .DISABLE , !querySettings .ch ).
655
676
putObject ("stall_on_demand" , querySettings .sod ).
@@ -671,9 +692,6 @@ public int doCalc(boolean warmup, int run) {
671
692
req .getHints ().putObject (Parameters .Routing .WAY_POINT_MAX_DISTANCE , 0 );
672
693
}
673
694
674
- if (querySettings .blockArea != null )
675
- req .getHints ().putObject (BLOCK_AREA , querySettings .blockArea );
676
-
677
695
if (querySettings .withPointHints ) {
678
696
EdgeIterator iter = edgeExplorer .setBaseNode (from );
679
697
if (!iter .next ())
0 commit comments