use of de.topobyte.osm4j.pbf.raf.PbfFile in project osm4j-pbf by topobyte.
the class EntitySplitBlockwise method main.
public static void main(String[] args) throws IOException {
// @formatter:off
Options options = new Options();
OptionHelper.addL(options, OPTION_INPUT, true, true, "input file");
OptionHelper.addL(options, OPTION_OUTPUT_NODES, true, false, "the file to write nodes to");
OptionHelper.addL(options, OPTION_OUTPUT_WAYS, true, false, "the file to write ways to");
OptionHelper.addL(options, OPTION_OUTPUT_RELATIONS, true, false, "the file to write relations to");
// @formatter:on
CommandLine line = null;
try {
line = new DefaultParser().parse(options, args);
} catch (ParseException e) {
System.out.println("unable to parse command line: " + e.getMessage());
new HelpFormatter().printHelp(HELP_MESSAGE, options);
System.exit(1);
}
if (line == null) {
return;
}
String inputPath = line.getOptionValue(OPTION_INPUT);
File file = new File(inputPath);
PbfFile pbfFile = new PbfFile(file);
OutputStream outNodes = null, outWays = null, outRelations = null;
if (line.hasOption(OPTION_OUTPUT_NODES)) {
String path = line.getOptionValue(OPTION_OUTPUT_NODES);
FileOutputStream fos = new FileOutputStream(path);
outNodes = new BufferedOutputStream(fos);
}
if (line.hasOption(OPTION_OUTPUT_WAYS)) {
String path = line.getOptionValue(OPTION_OUTPUT_WAYS);
FileOutputStream fos = new FileOutputStream(path);
outWays = new BufferedOutputStream(fos);
}
if (line.hasOption(OPTION_OUTPUT_RELATIONS)) {
String path = line.getOptionValue(OPTION_OUTPUT_RELATIONS);
FileOutputStream fos = new FileOutputStream(path);
outRelations = new BufferedOutputStream(fos);
}
if (outNodes == null && outWays == null && outRelations == null) {
System.out.println("You should specify an output for at least one entity");
System.exit(1);
}
EntitySplitBlockwise task = new EntitySplitBlockwise(pbfFile, outNodes, outWays, outRelations);
task.execute();
}
use of de.topobyte.osm4j.pbf.raf.PbfFile in project osm4j-pbf by topobyte.
the class FindEntityBlockIntervals method main.
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("usage: " + FindEntityBlockIntervals.class.getSimpleName() + " <filename>");
System.exit(1);
}
File file = new File(args[0]);
PbfFile pbfFile = new PbfFile(file);
pbfFile.buildBlockIndex();
FileStructure fileStructure = FileStructureAnalyzer.analyze(pbfFile);
for (EntityType type : EntityType.values()) {
if (!fileStructure.hasType(type)) {
System.out.println(type + ": none");
} else {
Interval blocks = fileStructure.getBlocks(type);
System.out.println(String.format(type + ": [%d, %d]", blocks.getStart(), blocks.getEnd()));
}
}
}
Aggregations