本文整理汇总了Java中crosby.binary.Osmformat.PrimitiveBlock类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveBlock类的具体用法?Java PrimitiveBlock怎么用?Java PrimitiveBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveBlock类属于crosby.binary.Osmformat包,在下文中一共展示了PrimitiveBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOSMContext
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
protected OSMContext createOSMContext(PrimitiveBlock block) {
assert block != null;
Osmformat.StringTable stablemessage = block.getStringtable();
String[] strings = new String[stablemessage.getSCount()];
for (int i = 0; i < strings.length; i++) {
strings[i] = stablemessage.getS(i).toStringUtf8();
}
int granularity = block.getGranularity();
long lat_offset = block.getLatOffset();
long lon_offset = block.getLonOffset();
int date_granularity = block.getDateGranularity();
return new OSMContext(granularity, lat_offset, lon_offset, date_granularity, strings);
}
示例2: CompositellParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
public CompositellParser(PrimitiveBlock block) {
this.block = block;
parserList.add(new NodeParser(block));
parserList.add(new WayParser(block));
parserList.add(new RelationParser(block));
}
示例3: parseData
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
/**
* Parse out and decompress the data part of a fileblock helper function.
*/
private PrimitiveBlock parseData(Fileformat.Blob blob) throws Exception {
assert blob != null;
if (blob.hasRaw()) {
return parsePrimitiveBlock(blob.getRaw());
} else if (blob.hasZlibData()) {
byte buf2[] = new byte[blob.getRawSize()];
Inflater decompresser = new Inflater();
decompresser.setInput(blob.getZlibData().toByteArray());
// decompresser.getRemaining();
try {
decompresser.inflate(buf2);
} catch (DataFormatException e) {
e.printStackTrace();
throw new Exception(e.getMessage(), e);
}
assert(decompresser.finished());
decompresser.end();
return parsePrimitiveBlock(ByteString.copyFrom(buf2));
}
throw new Exception("unsupported blob");
}
示例4: parse
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
/**
* Parse a primitve block.
*
* @see <a href="http://wiki.openstreetmap.org/wiki/PBF_Format
* #Definition_of_OSMData_fileblock">http://wiki.openstreetmap.org/wiki
* /PBF_Format#Definition_of_OSMData_fileblock</a>
*
* @param block The primitive block to parse.
*/
private void parse(final PrimitiveBlock block) {
this.granularity = block.getGranularity();
this.latOffset = block.getLatOffset();
this.lonOffset = block.getLonOffset();
this.stringTable = block.getStringtable();
for (PrimitiveGroup group: block.getPrimitivegroupList()) {
this.parse(group);
}
}
示例5: loadFileBlock
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
/**
* Decode a File Block at @pos and prepare internal data structures to read
* primitives from it.
*/
private void loadFileBlock() throws IOException, DataFormatException {
/* At this point, pos is at the beginning of a File block */
/* Read the file block header */
final BlobHeader header = readHeader();
// TODO be resilient for invalid headers, a while loop with hasDataSize and seekNextFileBlockStart
byte[] buf = new byte[header.getDatasize()];
fileFD.readFully(buf);
Blob blob = Blob.parseFrom(buf);
// TODO Implement other compression formats
if (blob.hasZlibData())
{
ByteString zlibData = blob.getZlibData();
Inflater inflater = new Inflater();
inflater.setInput(zlibData.toByteArray());
byte[] output = new byte[blob.getRawSize()];
inflater.inflate(output);
currentPB = PrimitiveBlock.parseFrom(output);
currentST = currentPB.getStringtable();
currentPG = currentPB.getPrimitivegroup(0);
currentPGIndex = 0;
nNodes = 0;
nWays = 0;
tagLoc = 0;
} else {
throw new DataFormatException("Unsupported compression algorithm in OSM file block.");
}
pos = fileFD.getPos();
}
示例6: createParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
return new NodeParser(p);
}
示例7: RelationParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
public RelationParser(PrimitiveBlock block) {
assert block != null;
this.ctx = createOSMContext(block);
groups = new ArrayList<PrimitiveGroup>(block.getPrimitivegroupList());
}
示例8: createParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
return new RelationParser(p);
}
示例9: createParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
return new WayParser(p);
}
示例10: createParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
return new CompositellParser(p);
}
示例11: NodeParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
public NodeParser(PrimitiveBlock block) {
assert block != null;
this.ctx = createOSMContext(block);
groups = new ArrayList<PrimitiveGroup>(block.getPrimitivegroupList());
}
示例12: WayParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
public WayParser(PrimitiveBlock block) {
assert block != null;
this.ctx = createOSMContext(block);
groups = new ArrayList<PrimitiveGroup>(block.getPrimitivegroupList());
}
示例13: readChunk
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
/**
* read data chunk
*
* @param datinput
* @throws IOException
* @throws InvalidProtocolBufferException
*/
private PrimitiveBlock readChunk(DataInputStream datinput) throws Exception {
assert datinput != null;
int headersize = datinput.readInt();
byte buf[] = new byte[headersize];
datinput.readFully(buf);
// System.out.format("Read buffer for header of %d bytes\n",buf.length);
Fileformat.BlobHeader header = Fileformat.BlobHeader.parseFrom(buf);
int datasize = header.getDatasize();
// System.out.println("block type :" + header.getType());
// System.out.println("datasize :" + datasize);
byte b[] = new byte[datasize];
datinput.readFully(b);
Blob blob = Fileformat.Blob.parseFrom(b);
if (OSM_DATA_HEADER.equals(header.getType())) {
return parseData(blob);
}
return null;
}
示例14: parsePrimitiveBlock
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
private PrimitiveBlock parsePrimitiveBlock(ByteString datas) throws Exception {
return PrimitiveBlock.parseFrom(datas);
}
示例15: createParser
import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
protected abstract Parser createParser(PrimitiveBlock p);