/** * Creates a new instance. * <p> * * @param primitiveBlock The primitive block containing the fields to be decoded. */ public PbfFieldDecoder(Osmformat.PrimitiveBlock primitiveBlock) { this.coordGranularity = primitiveBlock.getGranularity(); this.coordLatitudeOffset = primitiveBlock.getLatOffset(); this.coordLongitudeOffset = primitiveBlock.getLonOffset(); this.dateGranularity = primitiveBlock.getDateGranularity(); Osmformat.StringTable stringTable = primitiveBlock.getStringtable(); strings = new String[stringTable.getSCount()]; for (int i = 0; i < strings.length; i++) { strings[i] = stringTable.getS(i).toStringUtf8(); } }
switch (method) { case NEW_MUTABLE_INSTANCE: { return new org.openstreetmap.osmosis.osmbinary.Osmformat.PrimitiveBlock(); if (!hasStringtable()) { return null; for (int i = 0; i < getPrimitivegroupCount(); i++) { if (!getPrimitivegroup(i).isInitialized()) { return null; primitivegroup_= visitor.visitList(primitivegroup_, other.primitivegroup_); granularity_ = visitor.visitInt( hasGranularity(), granularity_, other.hasGranularity(), other.granularity_); latOffset_ = visitor.visitLong( hasLatOffset(), latOffset_, other.hasLatOffset(), other.latOffset_); lonOffset_ = visitor.visitLong( hasLonOffset(), lonOffset_, other.hasLonOffset(), other.lonOffset_); dateGranularity_ = visitor.visitInt( hasDateGranularity(), dateGranularity_, other.hasDateGranularity(), other.dateGranularity_); if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor .INSTANCE) { if (!parseUnknownField(tag, input)) { done = true;
void makeGranFileBlock1() throws IOException { PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder(); b1.setLatOffset(10*BILLION + 109208300) .setLonOffset(20*BILLION + 901802700) PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder(); b2.setLatOffset(12*BILLION + 303) .setLonOffset(22*BILLION + 404) .build()) ); output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(),null)); output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(),null));
void makeSimpleFileBlock1() throws IOException { PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder(); b1.setStringtable(makeStringTable("B1")); )); output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(),null)); PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder(); b2.setLatOffset(10*BILLION + 109208300) .setLonOffset(20*BILLION + 901802700) output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(),null));
return; Osmformat.PrimitiveBlock.Builder primblock = Osmformat.PrimitiveBlock .newBuilder(); stringtable.clear(); debug_bytes += message.getSerializedSize(); .toByteString(), null)); } catch (IOException e) {
if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getStringtable());
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeMessage(1, getStringtable()); } for (int i = 0; i < primitivegroup_.size(); i++) { output.writeMessage(2, primitivegroup_.get(i)); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeInt32(17, granularity_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeInt32(18, dateGranularity_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeInt64(19, latOffset_); } if (((bitField0_ & 0x00000008) == 0x00000008)) { output.writeInt64(20, lonOffset_); } unknownFields.writeTo(output); }
/** Runnable interface implementation that compresses and writes output blocks asynchronously. */ @Override public void run() { while (true) { try { Osmformat.PrimitiveBlock block = synchronousQueue.take(); // block until work is available if (block.getPrimitivegroupCount() == 0) { break; // a block with no primitive groups tells the writer thread to shut down. } writeOneBlob(block); } catch (InterruptedException ex) { LOG.error("Block writer thread was interrupted while waiting for work."); break; } } try { downstream.flush(); downstream.close(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void handleBlock(FileBlock message) { // TODO Auto-generated method stub try { if (message.getType().equals("OSMHeader")) { Osmformat.HeaderBlock headerblock = Osmformat.HeaderBlock .parseFrom(message.getData()); parse(headerblock); } else if (message.getType().equals("OSMData")) { Osmformat.PrimitiveBlock primblock = Osmformat.PrimitiveBlock .parseFrom(message.getData()); parse(primblock); } } catch (InvalidProtocolBufferException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new Error("ParseError"); // TODO } }
/** 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(); } granularity = block.getGranularity(); lat_offset = block.getLatOffset(); lon_offset = block.getLonOffset(); date_granularity = block.getDateGranularity(); for (Osmformat.PrimitiveGroup groupmessage : block .getPrimitivegroupList()) { // Exactly one of these should trigger on each loop. parseNodes(groupmessage.getNodesList()); parseWays(groupmessage.getWaysList()); parseRelations(groupmessage.getRelationsList()); if (groupmessage.hasDense()) parseDense(groupmessage.getDense()); } }
/** * Creates a new instance. * <p> * @param primitiveBlock The primitive block containing the fields to be decoded. */ public PbfFieldDecoder( Osmformat.PrimitiveBlock primitiveBlock ) { this.coordGranularity = primitiveBlock.getGranularity(); this.coordLatitudeOffset = primitiveBlock.getLatOffset(); this.coordLongitudeOffset = primitiveBlock.getLonOffset(); this.dateGranularity = primitiveBlock.getDateGranularity(); Osmformat.StringTable stringTable = primitiveBlock.getStringtable(); strings = new String[stringTable.getSCount()]; for (int i = 0; i < strings.length; i++) { strings[i] = stringTable.getS(i).toStringUtf8(); } }
/** * Creates a new instance. * <p> * * @param primitiveBlock The primitive block containing the fields to be decoded. */ public PbfFieldDecoder(Osmformat.PrimitiveBlock primitiveBlock) { this.coordGranularity = primitiveBlock.getGranularity(); this.coordLatitudeOffset = primitiveBlock.getLatOffset(); this.coordLongitudeOffset = primitiveBlock.getLonOffset(); this.dateGranularity = primitiveBlock.getDateGranularity(); Osmformat.StringTable stringTable = primitiveBlock.getStringtable(); strings = new String[stringTable.getSCount()]; for (int i = 0; i < strings.length; i++) { strings[i] = stringTable.getS(i).toStringUtf8(); } }
/** 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); } } }
/** * Creates a new instance. * <p> * * @param primitiveBlock The primitive block containing the fields to be decoded. */ public PbfFieldDecoder(Osmformat.PrimitiveBlock primitiveBlock) { this.coordGranularity = primitiveBlock.getGranularity(); this.coordLatitudeOffset = primitiveBlock.getLatOffset(); this.coordLongitudeOffset = primitiveBlock.getLonOffset(); this.dateGranularity = primitiveBlock.getDateGranularity(); Osmformat.StringTable stringTable = primitiveBlock.getStringtable(); strings = new String[stringTable.getSCount()]; for (int i = 0; i < strings.length; i++) { strings[i] = stringTable.getS(i).toStringUtf8(); } }
/** * Creates a new instance. * * @param primitiveBlock * The primitive block containing the fields to be decoded. */ public PbfFieldDecoder(PrimitiveBlock primitiveBlock) { this.coordGranularity = primitiveBlock.getGranularity(); this.coordLatitudeOffset = primitiveBlock.getLatOffset(); this.coordLongitudeOffset = primitiveBlock.getLonOffset(); this.dateGranularity = primitiveBlock.getDateGranularity(); StringTable stringTable = primitiveBlock.getStringtable(); strings = new String[stringTable.getSCount()]; for (int i = 0; i < strings.length; i++) { strings[i] = stringTable.getS(i).toStringUtf8(); } }
private void processOsmPrimitives( byte[] data ) throws InvalidProtocolBufferException { Osmformat.PrimitiveBlock block = Osmformat.PrimitiveBlock.parseFrom(data); PbfFieldDecoder fieldDecoder = new PbfFieldDecoder(block); for (Osmformat.PrimitiveGroup primitiveGroup : block.getPrimitivegroupList()) { log.debug("Processing OSM primitive group."); processNodes(primitiveGroup.getDense(), fieldDecoder); processNodes(primitiveGroup.getNodesList(), fieldDecoder); processWays(primitiveGroup.getWaysList(), fieldDecoder); processRelations(primitiveGroup.getRelationsList(), fieldDecoder); } }
private void processOsmPrimitives(byte[] data) throws InvalidProtocolBufferException { Osmformat.PrimitiveBlock block = Osmformat.PrimitiveBlock.parseFrom(data); PbfFieldDecoder fieldDecoder = new PbfFieldDecoder(block); for (Osmformat.PrimitiveGroup primitiveGroup : block.getPrimitivegroupList()) { processNodes(primitiveGroup.getDense(), fieldDecoder); processNodes(primitiveGroup.getNodesList(), fieldDecoder); processWays(primitiveGroup.getWaysList(), fieldDecoder); processRelations(primitiveGroup.getRelationsList(), fieldDecoder); } }
/** * <code>required .OSMPBF.StringTable stringtable = 1;</code> */ @java.lang.Override public org.openstreetmap.osmosis.osmbinary.Osmformat.StringTable getStringtable() { return instance.getStringtable(); } /**
/** * <code>optional int64 lon_offset = 20 [default = 0];</code> */ @java.lang.Override public long getLonOffset() { return instance.getLonOffset(); } /**
/** * <code>repeated .OSMPBF.PrimitiveGroup primitivegroup = 2;</code> */ @java.lang.Override public int getPrimitivegroupCount() { return instance.getPrimitivegroupCount(); }/** * <code>repeated .OSMPBF.PrimitiveGroup primitivegroup = 2;</code>