Commit 59349845 authored by NopMap's avatar NopMap
Browse files

routes are now bit encoded

parent dcd93324
......@@ -113,9 +113,9 @@ public class OSMReader
throw new IllegalStateException("Active encoders require elevation data. No DEM present.");
}
if (encodingManager.needsHikingRoutes() || encodingManager.needsBicycleRoutes() || encodingManager.needsHorseRoutes())
if (encodingManager.needsRoutes())
{
routeRelations = new RouteRelationHandler(encodingManager.needsHikingRoutes(), encodingManager.needsBicycleRoutes(), encodingManager.needsHorseRoutes());
routeRelations = new RouteRelationHandler(encodingManager.queryNeeds());
}
StopWatch sw1 = new StopWatch().start();
......
package com.graphhopper.reader;
import com.graphhopper.reader.OSMRelation;
import com.graphhopper.routing.util.AbstractFlagEncoder;
import gnu.trove.set.TLongSet;
import gnu.trove.set.hash.TLongHashSet;
......@@ -21,11 +22,11 @@ public class RouteRelationHandler
private TLongSet cycleWays;
private TLongSet horseWays;
public RouteRelationHandler( boolean trackHikingRoutes, boolean trackBicylceRoutes, boolean trackHorseRoutes )
public RouteRelationHandler( int routeFlags )
{
this.trackHikingRoutes = trackHikingRoutes;
this.trackBicylceRoutes = trackBicylceRoutes;
this.trackHorseRoutes = trackHorseRoutes;
this.trackHikingRoutes = (routeFlags & AbstractFlagEncoder.NEEDS_HIKING_ROUTES) > 0;
this.trackBicylceRoutes = (routeFlags & AbstractFlagEncoder.NEEDS_BICYCLE_ROUTES) > 0;;
this.trackHorseRoutes = (routeFlags & AbstractFlagEncoder.NEEDS_HORSE_ROUTES) > 0;
if( trackHikingRoutes )
hikingWays = new TLongHashSet(10000);
......
......@@ -278,20 +278,21 @@ public class EncodingManager
}
/**
* Check whether hiking routes are required by at least one encoder.
* Query bit-encoded cumulative needs of all encoders.
* @return
*/
public boolean needsHikingRoutes()
public int queryNeeds()
{
return (needs & AbstractFlagEncoder.NEEDS_HIKING_ROUTES) > 0;
return needs;
}
/**
* Check whether bicycle routes are required by at least one encoder.
* Check whether route handling is required by at least one encoder.
* @return
*/
public boolean needsBicycleRoutes()
public boolean needsRoutes()
{
return (needs & AbstractFlagEncoder.NEEDS_BICYCLE_ROUTES) > 0;
return 0 < (needs &
(AbstractFlagEncoder.NEEDS_BICYCLE_ROUTES | AbstractFlagEncoder.NEEDS_HIKING_ROUTES | AbstractFlagEncoder.NEEDS_HORSE_ROUTES ));
}
/**
* Check whether hiking routes are required by at least one encoder.
......
package com.graphhopper.reader;
import com.graphhopper.reader.RouteRelationHandler;
import com.graphhopper.routing.util.AbstractFlagEncoder;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
......@@ -18,7 +19,8 @@ public class RelationHandlerTest
@Test
public void testRouteRelations()
{
RouteRelationHandler handler = new RouteRelationHandler(true, true, true);
RouteRelationHandler handler = new RouteRelationHandler(
AbstractFlagEncoder.NEEDS_BICYCLE_ROUTES | AbstractFlagEncoder.NEEDS_HIKING_ROUTES | AbstractFlagEncoder.NEEDS_HORSE_ROUTES);
Map<String,String> tags1 = new HashMap<String, String>();
tags1.put( "type", "route");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment