Change API for invoking per-type primitivegroup serializers.
Before, when calling the per-type serializer, we passed it the encapsulating primitiveblock, into which it would place a newly allocated primitive group. Instead, have it return the new group, and then we store in the primitive block. This will help with re-using per-type serializers for serializing into non-primitiveblocks.
This commit is contained in:
parent
fbfba3bdea
commit
8a7f784de2
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import crosby.binary.Osmformat.PrimitiveGroup;
|
||||
import crosby.binary.file.BlockOutputStream;
|
||||
import crosby.binary.file.FileBlock;
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public class BinarySerializer {
|
|||
/**
|
||||
* This callback is invoked to request that the primgroup serialize itself into the given protocol buffer object.
|
||||
*/
|
||||
public void serialize(Osmformat.PrimitiveBlock.Builder group);
|
||||
public Osmformat.PrimitiveGroup serialize();
|
||||
}
|
||||
|
||||
/** Set the granularity (precision of lat/lon, measured in unites of nanodegrees. */
|
||||
|
|
@ -100,7 +101,9 @@ public class BinarySerializer {
|
|||
stringtable.finish();
|
||||
// Now, start serializing.
|
||||
for (PrimGroupWriterInterface i : groups) {
|
||||
i.serialize(primblock);
|
||||
PrimitiveGroup group = i.serialize();
|
||||
if (group != null)
|
||||
primblock.addPrimitivegroup(group);
|
||||
}
|
||||
primblock.setStringtable(stringtable.serialize());
|
||||
primblock.setGranularity(this.granularity);
|
||||
|
|
|
|||
Loading…
Reference in New Issue