本文整理匯總了Java中com.graphhopper.reader.osm.OSMReader類的典型用法代碼示例。如果您正苦於以下問題:Java OSMReader類的具體用法?Java OSMReader怎麽用?Java OSMReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OSMReader類屬於com.graphhopper.reader.osm包,在下文中一共展示了OSMReader類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: OSMDataReaderContext
import com.graphhopper.reader.osm.OSMReader; //導入依賴的package包/類
public OSMDataReaderContext(OSMReader osmReader) {
this.osmReader = osmReader;
}
示例2: createOrLoad
import com.graphhopper.reader.osm.OSMReader; //導入依賴的package包/類
public static GraphHopperStorage createOrLoad(GHDirectory directory,
EncodingManager encodingManager, GtfsStorage gtfsStorage,
boolean createWalkNetwork, Collection<String> gtfsFiles,
Collection<String> osmFiles) {
GraphHopperStorage graphHopperStorage = new GraphHopperStorage(
directory, encodingManager, false, gtfsStorage);
if (!new File(directory.getLocation()).exists()) {
graphHopperStorage.create(1000);
for (String osmFile : osmFiles) {
OSMReader osmReader = new OSMReader(graphHopperStorage);
osmReader.setEncodingManager(encodingManager);
osmReader.setFile(new File(osmFile));
osmReader.setDontCreateStorage(true);
try {
osmReader.readGraph();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
List<GTFSFeed> feeds = gtfsFiles
.parallelStream()
.map(filename -> GTFSFeed.fromFile(new File(filename)
.getPath())).collect(Collectors.toList());
if (createWalkNetwork) {
FakeWalkNetworkBuilder.buildWalkNetwork(feeds,
graphHopperStorage,
(PtFlagEncoder) encodingManager.getEncoder("pt"),
Helper.DIST_EARTH);
}
LocationIndex locationIndex;
if (graphHopperStorage.getNodes() > 0) {
locationIndex = new LocationIndexTree(graphHopperStorage,
new RAMDirectory()).prepareIndex();
} else {
locationIndex = new EmptyLocationIndex();
}
for (GTFSFeed feed : feeds) {
new GtfsReader(feed, graphHopperStorage, locationIndex)
.readGraph();
}
graphHopperStorage.flush();
} else {
graphHopperStorage.loadExisting();
}
return graphHopperStorage;
}