当前位置: 首页>>代码示例>>Java>>正文


Java PrimitiveBlock类代码示例

本文整理汇总了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);
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:17,代码来源:Parser.java

示例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));

}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:9,代码来源:CompositellParser.java

示例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");
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:32,代码来源:OSMPBFInputFormat.java

示例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);
  }
}
 
开发者ID:kasperisager,项目名称:kelvin-maps,代码行数:20,代码来源:PBFParser.java

示例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();
}
 
开发者ID:gballet,项目名称:osmpbfinputformat,代码行数:38,代码来源:OsmPbfRecordReader.java

示例6: createParser

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
	return new NodeParser(p);
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:5,代码来源:OSMPBFNodeInputFormat.java

示例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());
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:6,代码来源:RelationParser.java

示例8: createParser

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
	return new RelationParser(p);
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:5,代码来源:OSMPBFRelationInputFormat.java

示例9: createParser

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
	return new WayParser(p);
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:5,代码来源:OSMPBFWayInputFormat.java

示例10: createParser

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
@Override
protected Parser createParser(PrimitiveBlock p) {
	return new CompositellParser(p);
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:5,代码来源:OSMPBFAllEntities.java

示例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());

}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:9,代码来源:NodeParser.java

示例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());

	}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:10,代码来源:WayParser.java

示例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;

}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:37,代码来源:OSMPBFInputFormat.java

示例14: parsePrimitiveBlock

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
private PrimitiveBlock parsePrimitiveBlock(ByteString datas) throws Exception {

		return PrimitiveBlock.parseFrom(datas);
	}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:5,代码来源:OSMPBFInputFormat.java

示例15: createParser

import crosby.binary.Osmformat.PrimitiveBlock; //导入依赖的package包/类
protected abstract Parser createParser(PrimitiveBlock p); 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:2,代码来源:OSMPBFInputFormat.java


注:本文中的crosby.binary.Osmformat.PrimitiveBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。