primitiveGroupBuilder.addRelations(builder.build());
public Osmformat.PrimitiveGroup serialize() { if (contents.size() == 0) { return null; } // System.out.format("%d Ways ",contents.size()); StringTable stable = getStringTable(); Osmformat.PrimitiveGroup.Builder builder = Osmformat.PrimitiveGroup .newBuilder(); for (Way i : contents) { Osmformat.Way.Builder bi = Osmformat.Way.newBuilder(); bi.setId(i.getId()); long lastid = 0; for (WayNode j : i.getWayNodes()) { long id = j.getNodeId(); bi.addRefs(id - lastid); lastid = id; } for (Tag t : i.getTags()) { bi.addKeys(stable.getIndex(t.getKey())); bi.addVals(stable.getIndex(t.getValue())); } if (!omit_metadata) { bi.setInfo(serializeMetadata(i)); } builder.addWays(bi); } return builder.build(); } }
return new Builder();
.addNodes(Node.newBuilder() .setId(100001) .setLat(1000).setLon(2000) .build()) .build()) .addNodes(Node.newBuilder() .setId(100002) .setLat(1001).setLon(2001) .build()) .build()) .addNodes(Node.newBuilder() .setId(100003) .setLat(1003).setLon(2003) b2.addPrimitivegroup( PrimitiveGroup.newBuilder() .addNodes(Node.newBuilder() .setId(100001) .addKeys(1).addVals(2) .setLat(1000).setLon(2000) .build()) .addNodes(Node.newBuilder() .setId(100002) .setLat(1001).setLon(2001) .build()) .addNodes(Node.newBuilder()
.addNodes(Node.newBuilder() .setId(101).setLat(13*10*1000*1000).setLon(-14*10*1000*1000) .addKeys(1).addVals(2)) .addNodes(Node.newBuilder() .setId(101).setLat(12345678).setLon(-23456789)) // Should be 1.2345678 degrees lat and -2.3456789 lon. ); b1.addPrimitivegroup( PrimitiveGroup.newBuilder() .addWays(Way.newBuilder() .setId(201) .addRefs(101).addRefs(1).addRefs(-1).addRefs(10).addRefs(-20) // Delta coded. Should be 101, 102, 101, 111, 91. .addKeys(2).addVals(1).addKeys(3).addVals(4)) .addWays(Way.newBuilder() .setId(-301) .addRefs(211).addRefs(1).addRefs(-1).addRefs(10).addRefs(-300) // Delta coded. Should be 211, 212, 211, 221, -79 .addKeys(4).addVals(3).addKeys(5).addVals(6)) .addWays(Way.newBuilder() .setId(401).addRefs(211).addRefs(1)) .addWays(Way.newBuilder() .setId(501)) ); .addRelations(Relation.newBuilder() .setId(601) .addTypes(MemberType.NODE).addMemids(50).addRolesSid(2) .addTypes(MemberType.WAY).addMemids(3).addRolesSid(4) .addTypes(MemberType.RELATION).addMemids(3).addRolesSid(5)) .addRelations(Relation.newBuilder()
bi.setInfo(serializeMetadata(i)); builder.addRelations(bi); return builder.build();
@Override public void writeWay(long id, Way way) throws IOException { checkBlockTransition(OSMEntity.Type.WAY); Osmformat.Way.Builder builder = Osmformat.Way.newBuilder().setId(id); /* Tags */ if (way.tags != null) { for (OSMEntity.Tag tag : way.tags) { if (tag.value == null) tag.value = ""; builder.addKeys(stringTable.getCode(tag.key)); builder.addVals(stringTable.getCode(tag.value)); } } /* Node References */ long prevNodeRef = 0; for (long ref : way.nodes) { builder.addRefs(ref - prevNodeRef); // delta-coded node references prevNodeRef = ref; } /* TODO Should we trigger the build here or just call with the builder? */ primitiveGroupBuilder.addWays(builder.build()); }
/** We always add one primitive group of less that 8k elements to each primitive block. */ private void endBlock () { if (nEntitiesInBlock > 0) { if (currEntityType == OSMEntity.Type.NODE) { primitiveGroupBuilder.setDense(denseNodesBuilder); } // Pass the block off to the compression/writing thread try { Osmformat.PrimitiveBlock primitiveBlock = Osmformat.PrimitiveBlock.newBuilder() .setStringtable(stringTable.toBuilder()).addPrimitivegroup(primitiveGroupBuilder).build(); synchronousQueue.put(primitiveBlock); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
/** * <code>repeated .OSMPBF.ChangeSet changesets = 5;</code> */ public Builder removeChangesets(int index) { copyOnWrite(); instance.removeChangesets(index); return this; }
/** * <code>repeated .OSMPBF.ChangeSet changesets = 5;</code> */ public Builder addChangesets( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.ChangeSet.Builder builderForValue) { copyOnWrite(); instance.addChangesets(index, builderForValue); return this; } /**
/** * <code>repeated .OSMPBF.ChangeSet changesets = 5;</code> */ public Builder addChangesets( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.ChangeSet value) { copyOnWrite(); instance.addChangesets(index, value); return this; } /**
/** * <code>repeated .OSMPBF.Relation relations = 4;</code> */ public Builder addRelations( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.Relation.Builder builderForValue) { copyOnWrite(); instance.addRelations(index, builderForValue); return this; } /**
/** * <code>repeated .OSMPBF.Relation relations = 4;</code> */ public Builder addRelations( org.openstreetmap.osmosis.osmbinary.Osmformat.Relation.Builder builderForValue) { copyOnWrite(); instance.addRelations(builderForValue); return this; } /**
/** * <code>repeated .OSMPBF.Relation relations = 4;</code> */ public Builder addRelations( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.Relation value) { copyOnWrite(); instance.addRelations(index, value); return this; } /**
/** * <code>repeated .OSMPBF.Relation relations = 4;</code> */ public Builder setRelations( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.Relation value) { copyOnWrite(); instance.setRelations(index, value); return this; } /**
/** * <code>repeated .OSMPBF.Way ways = 3;</code> */ public Builder addAllWays( java.lang.Iterable<? extends org.openstreetmap.osmosis.osmbinary.Osmformat.Way> values) { copyOnWrite(); instance.addAllWays(values); return this; } /**
/** * <code>repeated .OSMPBF.Way ways = 3;</code> */ public Builder addWays( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.Way value) { copyOnWrite(); instance.addWays(index, value); return this; } /**
/** * <code>repeated .OSMPBF.Way ways = 3;</code> */ public Builder setWays( int index, org.openstreetmap.osmosis.osmbinary.Osmformat.Way.Builder builderForValue) { copyOnWrite(); instance.setWays(index, builderForValue); return this; } /**