diff --git a/src.java/crosby/binary/test/ReadFileExample.java b/src.java/crosby/binary/test/ReadFileExample.java index 082d406..d8ad520 100644 --- a/src.java/crosby/binary/test/ReadFileExample.java +++ b/src.java/crosby/binary/test/ReadFileExample.java @@ -1,86 +1,86 @@ -package crosby.binary.test; - -import crosby.binary.*; -import crosby.binary.Osmformat.*; -import crosby.binary.file.*; -import java.io.*; -import java.util.List; - -/** - * Demonstrates how to read a file. Reads sample.pbf from the resources folder - * and prints details about it to the standard output. - * - * @author Michael Tandy - */ -public class ReadFileExample { - - public static void main(String[] args) throws Exception { - InputStream input = ReadFileExample.class.getResourceAsStream("/sample.pbf"); - BlockReaderAdapter brad = new TestBinaryParser(); - new BlockInputStream(input, brad).process(); - } - - private static class TestBinaryParser extends BinaryParser { - - @Override - protected void parseRelations(List rels) { - if (!rels.isEmpty()) - System.out.println("Got some relations to parse."); - Relation r = null; - } - - @Override - protected void parseDense(DenseNodes nodes) { - long lastId=0; - long lastLat=0; - long lastLon=0; - - for (int i=0 ; i nodes) { - for (Node n : nodes) { - System.out.printf("Regular node, ID %d @ %.6f,%.6f\n", - n.getId(),parseLat(n.getLat()),parseLon(n.getLon())); - } - } - - @Override - protected void parseWays(List ways) { - for (Way w : ways) { - System.out.println("Way ID " + w.getId()); - StringBuilder sb = new StringBuilder(); - sb.append(" Nodes: "); - long lastRef = 0; - for (Long ref : w.getRefsList()) { - lastRef+= ref; - sb.append(lastRef).append(" "); - } - sb.append("\n Key=value pairs: "); - for (int i=0 ; i rels) { + if (!rels.isEmpty()) + System.out.println("Got some relations to parse."); + Relation r = null; + } + + @Override + protected void parseDense(DenseNodes nodes) { + long lastId=0; + long lastLat=0; + long lastLon=0; + + for (int i=0 ; i nodes) { + for (Node n : nodes) { + System.out.printf("Regular node, ID %d @ %.6f,%.6f\n", + n.getId(),parseLat(n.getLat()),parseLon(n.getLon())); + } + } + + @Override + protected void parseWays(List ways) { + for (Way w : ways) { + System.out.println("Way ID " + w.getId()); + StringBuilder sb = new StringBuilder(); + sb.append(" Nodes: "); + long lastRef = 0; + for (Long ref : w.getRefsList()) { + lastRef+= ref; + sb.append(lastRef).append(" "); + } + sb.append("\n Key=value pairs: "); + for (int i=0 ; i