From 8a7f784de26cc9c790196fe53a32e336260a0b9d Mon Sep 17 00:00:00 2001 From: Scott Crosby Date: Wed, 8 Sep 2010 07:47:23 -0500 Subject: [PATCH] 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. --- src.java/crosby/binary/BinarySerializer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src.java/crosby/binary/BinarySerializer.java b/src.java/crosby/binary/BinarySerializer.java index a690c17..9e80e75 100644 --- a/src.java/crosby/binary/BinarySerializer.java +++ b/src.java/crosby/binary/BinarySerializer.java @@ -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);