Search in sources :

Example 1 with DefaultSpatialRule

use of com.graphhopper.routing.util.spatialrules.DefaultSpatialRule in project graphhopper by graphhopper.

the class LandmarkStorageTest method testWithBorderBlocking.

@Test
public void testWithBorderBlocking() {
    AbstractRoutingAlgorithmTester.initBiGraph(ghStorage);
    LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2);
    final SpatialRule ruleRight = new DefaultSpatialRule() {

        @Override
        public String getId() {
            return "right";
        }
    };
    final SpatialRule ruleLeft = new DefaultSpatialRule() {

        @Override
        public String getId() {
            return "left";
        }
    };
    final SpatialRuleLookup lookup = new SpatialRuleLookup() {

        @Override
        public SpatialRule lookupRule(double lat, double lon) {
            if (lon > 0.00105)
                return ruleRight;
            return ruleLeft;
        }

        @Override
        public SpatialRule lookupRule(GHPoint point) {
            return lookupRule(point.lat, point.lon);
        }

        @Override
        public int getSpatialId(SpatialRule rule) {
            throw new IllegalStateException();
        }

        @Override
        public int size() {
            return 2;
        }

        @Override
        public BBox getBounds() {
            return new BBox(-180, 180, -90, 90);
        }
    };
    storage.setSpatialRuleLookup(lookup);
    storage.setMinimumNodes(2);
    storage.createLandmarks();
    assertEquals(3, storage.getSubnetworksWithLandmarks());
}
Also used : BBox(com.graphhopper.util.shapes.BBox) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) SpatialRule(com.graphhopper.routing.util.spatialrules.SpatialRule) DefaultSpatialRule(com.graphhopper.routing.util.spatialrules.DefaultSpatialRule) DefaultSpatialRule(com.graphhopper.routing.util.spatialrules.DefaultSpatialRule) SpatialRuleLookup(com.graphhopper.routing.util.spatialrules.SpatialRuleLookup) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Aggregations

DefaultSpatialRule (com.graphhopper.routing.util.spatialrules.DefaultSpatialRule)1 SpatialRule (com.graphhopper.routing.util.spatialrules.SpatialRule)1 SpatialRuleLookup (com.graphhopper.routing.util.spatialrules.SpatialRuleLookup)1 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)1 BBox (com.graphhopper.util.shapes.BBox)1 GHPoint (com.graphhopper.util.shapes.GHPoint)1 Test (org.junit.Test)1