Search in sources :

Example 1 with CountryParser

use of com.graphhopper.routing.util.parsers.CountryParser in project graphhopper by graphhopper.

the class OSMReaderTest method testCurvedWayAlongBorder.

@Test
public void testCurvedWayAlongBorder() throws IOException {
    // see https://discuss.graphhopper.com/t/country-of-way-is-wrong-on-road-near-border-with-curvature/6908/2
    EncodingManager em = EncodingManager.start().add(new CarFlagEncoder()).add(new CountryParser()).build();
    EnumEncodedValue<Country> countryEnc = em.getEnumEncodedValue(Country.KEY, Country.class);
    GraphHopperStorage graph = new GraphBuilder(em).build();
    OSMReader reader = new OSMReader(graph, new OSMReaderConfig());
    reader.setCountryRuleFactory(new CountryRuleFactory());
    reader.setAreaIndex(createCountryIndex());
    reader.setFile(new File(getClass().getResource("test-osm12.xml").getFile()));
    reader.readGraph();
    assertEquals(1, graph.getEdges());
    AllEdgesIterator iter = graph.getAllEdges();
    iter.next();
    assertEquals(Country.BGR, iter.get(countryEnc));
}
Also used : CountryParser(com.graphhopper.routing.util.parsers.CountryParser) OSMReaderConfig(com.graphhopper.routing.OSMReaderConfig) CountryRuleFactory(com.graphhopper.routing.util.countryrules.CountryRuleFactory) File(java.io.File) Test(org.junit.jupiter.api.Test) GraphHopperTest(com.graphhopper.GraphHopperTest)

Aggregations

GraphHopperTest (com.graphhopper.GraphHopperTest)1 OSMReaderConfig (com.graphhopper.routing.OSMReaderConfig)1 CountryRuleFactory (com.graphhopper.routing.util.countryrules.CountryRuleFactory)1 CountryParser (com.graphhopper.routing.util.parsers.CountryParser)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1