Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src.java/crosby/binary/BinaryParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class BinaryParser implements BlockReaderAdapter {
private long lat_offset;
private long lon_offset;
protected int date_granularity;
private String[] strings;
protected String[] strings;

/** Take a Info protocol buffer containing a date and convert it into a java Date object */
protected Date getDate(Osmformat.Info info) {
Expand Down Expand Up @@ -100,12 +100,7 @@ public double parseLon(long degree) {

/** Parse a Primitive block (containing a string table, other paramaters, and PrimitiveGroups */
public void parse(Osmformat.PrimitiveBlock block) {
Osmformat.StringTable stablemessage = block.getStringtable();
strings = new String[stablemessage.getSCount()];

for (int i = 0; i < strings.length; i++) {
strings[i] = stablemessage.getS(i).toStringUtf8();
}
strings = parseStringTable(block.getStringtable());

granularity = block.getGranularity();
lat_offset = block.getLatOffset();
Expand All @@ -122,6 +117,15 @@ public void parse(Osmformat.PrimitiveBlock block) {
parseDense(groupmessage.getDense());
}
}

protected String[] parseStringTable(Osmformat.StringTable stablemessage) {
String[] strings = new String[stablemessage.getSCount()];

for (int i = 0; i < strings.length; i++) {
strings[i] = stablemessage.getS(i).toStringUtf8();
}
return strings;
}

/** Parse a list of Relation protocol buffers and send the resulting relations to a sink. */
protected abstract void parseRelations(List<Osmformat.Relation> rels);
Expand Down