Search in sources :

Example 1 with PbfParser

use of de.topobyte.osm4j.pbf.seq.PbfParser in project osm4j-pbf by topobyte.

the class Util method read.

public static void read(File file, boolean fetchMetadata) throws IOException {
    InputStream input = new FileInputStream(file);
    PbfParser parser = new PbfParser(nullHandler, fetchMetadata);
    parser.parse(input);
    input.close();
}
Also used : PbfParser(de.topobyte.osm4j.pbf.seq.PbfParser) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream)

Example 2 with PbfParser

use of de.topobyte.osm4j.pbf.seq.PbfParser in project osm4j-pbf by topobyte.

the class CopyElementwise method main.

public static void main(String[] args) throws IOException, OsmInputException {
    if (args.length != 2) {
        System.out.println("usage: " + CopyElementwise.class.getSimpleName() + " <input> <output>");
        System.exit(1);
    }
    InputStream input = new FileInputStream(args[0]);
    OutputStream output = new FileOutputStream(args[1]);
    final PbfWriter writer = new PbfWriter(output, true);
    PbfParser parser = new PbfParser(new OsmHandler() {

        @Override
        public void handle(OsmBounds bounds) throws IOException {
            writer.write(bounds);
        }

        @Override
        public void handle(OsmNode node) throws IOException {
            writer.write(node);
        }

        @Override
        public void handle(OsmWay way) throws IOException {
            writer.write(way);
        }

        @Override
        public void handle(OsmRelation relation) throws IOException {
            writer.write(relation);
        }

        @Override
        public void complete() throws IOException {
            writer.complete();
        }
    }, true);
    parser.parse(input);
    output.close();
}
Also used : OsmBounds(de.topobyte.osm4j.core.model.iface.OsmBounds) OsmNode(de.topobyte.osm4j.core.model.iface.OsmNode) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) OsmHandler(de.topobyte.osm4j.core.access.OsmHandler) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) PbfParser(de.topobyte.osm4j.pbf.seq.PbfParser) FileOutputStream(java.io.FileOutputStream) PbfWriter(de.topobyte.osm4j.pbf.seq.PbfWriter)

Example 3 with PbfParser

use of de.topobyte.osm4j.pbf.seq.PbfParser in project osm4j-pbf by topobyte.

the class TestCountCallback method main.

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        System.out.println("usage: " + TestCountCallback.class.getSimpleName() + " <filename>");
        System.exit(1);
    }
    File file = new File(args[0]);
    TestCountCallback test = new TestCountCallback();
    PbfParser parser = new PbfParser(test, false);
    FileInputStream input = new FileInputStream(file);
    parser.parse(input);
}
Also used : PbfParser(de.topobyte.osm4j.pbf.seq.PbfParser) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 4 with PbfParser

use of de.topobyte.osm4j.pbf.seq.PbfParser in project osm4j-pbf by topobyte.

the class Util method read.

public static void read(String resource, boolean fetchMetadata) throws IOException {
    InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
    PbfParser parser = new PbfParser(nullHandler, fetchMetadata);
    parser.parse(input);
    input.close();
}
Also used : PbfParser(de.topobyte.osm4j.pbf.seq.PbfParser) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Aggregations

PbfParser (de.topobyte.osm4j.pbf.seq.PbfParser)4 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)3 OsmHandler (de.topobyte.osm4j.core.access.OsmHandler)1 OsmBounds (de.topobyte.osm4j.core.model.iface.OsmBounds)1 OsmNode (de.topobyte.osm4j.core.model.iface.OsmNode)1 OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)1 OsmWay (de.topobyte.osm4j.core.model.iface.OsmWay)1 PbfWriter (de.topobyte.osm4j.pbf.seq.PbfWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1