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:
Scott Crosby 2010-09-08 07:47:23 -05:00
parent fbfba3bdea
commit 8a7f784de2
1 changed files with 5 additions and 2 deletions

View File

@ -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);