Search in sources :

Example 1 with AustriaSpatialRule

use of com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule in project graphhopper by graphhopper.

the class SpatialRuleLookupArrayTest method testSpatialLookup.

@Test
public void testSpatialLookup() {
    SpatialRuleLookupArray lookup = new SpatialRuleLookupArray(new BBox(1, 2, 1, 2), 1, false);
    SpatialRule germanyRule = new GermanySpatialRule().addBorder(new Polygon(new double[] { 1, 1, 2, 2 }, new double[] { 1, 2, 2, 1 }));
    lookup.addRule(germanyRule);
    SpatialRule austriaRule = new AustriaSpatialRule().addBorder(new Polygon(new double[] { 5, 5, 6, 6 }, new double[] { 5, 6, 6, 5 }));
    lookup.addRule(austriaRule);
    SpatialRule rule = lookup.lookupRule(1.5, 1.5);
    assertEquals(germanyRule, rule);
    assertEquals("DEU", rule.getId());
    int id = lookup.getSpatialId(rule);
    assertTrue(id > 0);
    assertEquals(rule, lookup.getSpatialRule(id));
}
Also used : AustriaSpatialRule(com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule) BBox(com.graphhopper.util.shapes.BBox) GermanySpatialRule(com.graphhopper.routing.util.spatialrules.countries.GermanySpatialRule) AustriaSpatialRule(com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule) GermanySpatialRule(com.graphhopper.routing.util.spatialrules.countries.GermanySpatialRule) Test(org.junit.Test)

Example 2 with AustriaSpatialRule

use of com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule in project graphhopper by graphhopper.

the class DefaultModule method buildIndex.

static SpatialRuleLookup buildIndex(Reader reader, BBox graphBBox) {
    GHJson ghJson = new GHJsonBuilder().create();
    JsonFeatureCollection jsonFeatureCollection = ghJson.fromJson(reader, JsonFeatureCollection.class);
    return new SpatialRuleLookupBuilder().build(Arrays.asList(new GermanySpatialRule(), new AustriaSpatialRule()), jsonFeatureCollection, graphBBox, 1, true);
}
Also used : AustriaSpatialRule(com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule) GHJsonBuilder(com.graphhopper.json.GHJsonBuilder) JsonFeatureCollection(com.graphhopper.json.geo.JsonFeatureCollection) GHJson(com.graphhopper.json.GHJson) GermanySpatialRule(com.graphhopper.routing.util.spatialrules.countries.GermanySpatialRule) SpatialRuleLookupBuilder(com.graphhopper.routing.util.spatialrules.SpatialRuleLookupBuilder)

Aggregations

AustriaSpatialRule (com.graphhopper.routing.util.spatialrules.countries.AustriaSpatialRule)2 GermanySpatialRule (com.graphhopper.routing.util.spatialrules.countries.GermanySpatialRule)2 GHJson (com.graphhopper.json.GHJson)1 GHJsonBuilder (com.graphhopper.json.GHJsonBuilder)1 JsonFeatureCollection (com.graphhopper.json.geo.JsonFeatureCollection)1 SpatialRuleLookupBuilder (com.graphhopper.routing.util.spatialrules.SpatialRuleLookupBuilder)1 BBox (com.graphhopper.util.shapes.BBox)1 Test (org.junit.Test)1