本文整理汇总了Java中org.openstreetmap.osmosis.osmbinary.Osmformat.HeaderBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Osmformat.HeaderBlock方法的具体用法?Java Osmformat.HeaderBlock怎么用?Java Osmformat.HeaderBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstreetmap.osmosis.osmbinary.Osmformat
的用法示例。
在下文中一共展示了Osmformat.HeaderBlock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
public void parse(Osmformat.HeaderBlock block) {
for (String s : block.getRequiredFeaturesList()) {
if (s.equals("OsmSchema-V0.6")) {
continue;
}
if (s.equals("DenseNodes")) {
continue;
}
if (s.equals("HistoricalInformation")) {
continue;
}
log.error("Cannot parse file");
System.exit(0);
}
}
示例2: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
public void parse(Osmformat.HeaderBlock block) {
for (String s : block.getRequiredFeaturesList()) {
if (s.equals("OsmSchema-V0.6")) {
continue; // We can parse this.
}
if (s.equals("DenseNodes")) {
continue; // We can parse this.
}
throw new IllegalStateException("File requires unknown feature: " + s);
}
if (block.hasOsmosisReplicationTimestamp()) {
long timestamp = block.getOsmosisReplicationTimestamp();
LOG.info("PBF file has a replication timestamp of {}", Instant.ofEpochSecond(timestamp));
entitySink.setReplicationTimestamp(timestamp);
} else {
LOG.info("PBF file has no replication timestamp.");
}
}
示例3: writeOneBlob
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
/** @param block is either a PrimitiveBlock or a HeaderBlock */
private void writeOneBlob(GeneratedMessageLite block) {
// FIXME lotsa big copies going on here
String blobTypeString;
if (block instanceof Osmformat.HeaderBlock) {
blobTypeString = "OSMHeader";
} else if (block instanceof Osmformat.PrimitiveBlock) {
blobTypeString = "OSMData";
} else {
throw new AssertionError("block must be either a header block or a primitive block.");
}
Fileformat.Blob.Builder blobBuilder = Fileformat.Blob.newBuilder();
byte[] serializedBlock = block.toByteArray();
byte[] deflatedBlock = new byte[serializedBlock.length];
int deflatedSize = deflate(serializedBlock, deflatedBlock);
if (deflatedSize < 0) {
LOG.debug("Deflate did not reduce the size of a block. Saving it uncompressed.");
blobBuilder.setRaw(ByteString.copyFrom(serializedBlock));
} else {
blobBuilder.setZlibData(ByteString.copyFrom(deflatedBlock, 0, deflatedSize));
blobBuilder.setRawSize(serializedBlock.length);
}
byte[] serializedBlob = blobBuilder.build().toByteArray();
Fileformat.BlobHeader blobHeader = Fileformat.BlobHeader.newBuilder()
.setType(blobTypeString).setDatasize(serializedBlob.length).build();
byte[] serializedBlobHeader = blobHeader.toByteArray();
try {
// "Returns a big-endian representation of value in a 4-element byte array"
downstream.write(Ints.toByteArray(serializedBlobHeader.length));
downstream.write(serializedBlobHeader);
downstream.write(serializedBlob);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: processOsmHeader
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
private void processOsmHeader( byte[] data ) throws InvalidProtocolBufferException
{
Osmformat.HeaderBlock header = Osmformat.HeaderBlock.parseFrom(data);
// Build the list of active and unsupported features in the file.
List<String> supportedFeatures = Arrays.asList("OsmSchema-V0.6", "DenseNodes");
List<String> activeFeatures = new ArrayList<String>();
List<String> unsupportedFeatures = new ArrayList<String>();
for (String feature : header.getRequiredFeaturesList())
{
if (supportedFeatures.contains(feature))
{
activeFeatures.add(feature);
} else
{
unsupportedFeatures.add(feature);
}
}
// We can't continue if there are any unsupported features. We wait
// until now so that we can display all unsupported features instead of
// just the first one we encounter.
if (unsupportedFeatures.size() > 0)
{
throw new RuntimeException("PBF file contains unsupported features " + unsupportedFeatures);
}
}
示例5: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
public void parse(Osmformat.HeaderBlock block) {
for (String s : block.getRequiredFeaturesList()) {
if (s.equals("OsmSchema-V0.6")) {
continue; // We can parse this.
}
if (s.equals("DenseNodes")) {
continue; // We can parse this.
}
throw new RuntimeException("File requires unknown feature: " + s);
}
// if (block.hasBbox()) {
// String source = OsmosisConstants.VERSION;
// if (block.hasSource()) {
// source = block.getSource();
// }
//
// double multiplier = .000000001;
// double rightf = block.getBbox().getRight() * multiplier;
// double leftf = block.getBbox().getLeft() * multiplier;
// double topf = block.getBbox().getTop() * multiplier;
// double bottomf = block.getBbox().getBottom() * multiplier;
//
// Bound bounds = new Bound(rightf, leftf, topf, bottomf, source);
// sink.process(new BoundContainer(bounds));
// }
}
示例6: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
protected void parse(Osmformat.HeaderBlock headerBlock) {
}
示例7: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
protected void parse(
Osmformat.HeaderBlock header ) {
}
示例8: parse
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
protected void parse(Osmformat.HeaderBlock header) {
}