Package crosby.binary
Class BinaryParser
- java.lang.Object
-
- crosby.binary.BinaryParser
-
- All Implemented Interfaces:
BlockReaderAdapter
public abstract class BinaryParser extends java.lang.Object implements BlockReaderAdapter
-
-
Field Summary
Fields Modifier and Type Field Description protected int
date_granularity
protected int
granularity
private long
lat_offset
private long
lon_offset
static java.util.Date
NODATE
private java.lang.String[]
strings
-
Constructor Summary
Constructors Constructor Description BinaryParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.Date
getDate(Osmformat.Info info)
Take a Info protocol buffer containing a date and convert it into a java Date objectprotected java.lang.String
getStringById(int id)
Get a string based on the index used.void
handleBlock(FileBlock message)
Called with the data in the block.protected abstract void
parse(Osmformat.HeaderBlock header)
Parse a header message.void
parse(Osmformat.PrimitiveBlock block)
Parse a Primitive block (containing a string table, other paramaters, and PrimitiveGroupsprotected abstract void
parseDense(Osmformat.DenseNodes nodes)
Parse a DenseNode protocol buffer and send the resulting nodes to a sink.double
parseLat(long degree)
Convert a latitude value stored in a protobuf into a double, compensating for granularity and latitude offsetdouble
parseLon(long degree)
Convert a longitude value stored in a protobuf into a double, compensating for granularity and longitude offsetprotected abstract void
parseNodes(java.util.List<Osmformat.Node> nodes)
Parse a list of Node protocol buffers and send the resulting nodes to a sink.protected abstract void
parseRelations(java.util.List<Osmformat.Relation> rels)
Parse a list of Relation protocol buffers and send the resulting relations to a sink.protected abstract void
parseWays(java.util.List<Osmformat.Way> ways)
Parse a list of Way protocol buffers and send the resulting ways to a sink.boolean
skipBlock(FileBlockPosition block)
Does the reader understand this block? Does it want the data in it? A reference contains the metadata about a block and can saved --- or stored ---- for future random access.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface crosby.binary.file.BlockReaderAdapter
complete
-
-
-
-
Method Detail
-
getDate
protected java.util.Date getDate(Osmformat.Info info)
Take a Info protocol buffer containing a date and convert it into a java Date object
-
getStringById
protected java.lang.String getStringById(int id)
Get a string based on the index used. Index 0 is reserved to use as a delimiter, therefore, index 1 corresponds to the first string in the table- Parameters:
id
- the index- Returns:
- the string at the given index
-
handleBlock
public void handleBlock(FileBlock message)
Description copied from interface:BlockReaderAdapter
Called with the data in the block.- Specified by:
handleBlock
in interfaceBlockReaderAdapter
-
skipBlock
public boolean skipBlock(FileBlockPosition block)
Description copied from interface:BlockReaderAdapter
Does the reader understand this block? Does it want the data in it? A reference contains the metadata about a block and can saved --- or stored ---- for future random access. However, during a strea read of the file, does the user want this block? handleBlock will be called on all blocks that are not skipped, in file order.- Specified by:
skipBlock
in interfaceBlockReaderAdapter
-
parseLat
public double parseLat(long degree)
Convert a latitude value stored in a protobuf into a double, compensating for granularity and latitude offset
-
parseLon
public double parseLon(long degree)
Convert a longitude value stored in a protobuf into a double, compensating for granularity and longitude offset
-
parse
public void parse(Osmformat.PrimitiveBlock block)
Parse a Primitive block (containing a string table, other paramaters, and PrimitiveGroups
-
parseRelations
protected abstract void parseRelations(java.util.List<Osmformat.Relation> rels)
Parse a list of Relation protocol buffers and send the resulting relations to a sink.
-
parseDense
protected abstract void parseDense(Osmformat.DenseNodes nodes)
Parse a DenseNode protocol buffer and send the resulting nodes to a sink.
-
parseNodes
protected abstract void parseNodes(java.util.List<Osmformat.Node> nodes)
Parse a list of Node protocol buffers and send the resulting nodes to a sink.
-
parseWays
protected abstract void parseWays(java.util.List<Osmformat.Way> ways)
Parse a list of Way protocol buffers and send the resulting ways to a sink.
-
parse
protected abstract void parse(Osmformat.HeaderBlock header)
Parse a header message.
-
-