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));
}
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);
}
Aggregations