[osmpbf] 04/11: Formatting and fixes one formatting-related bug.
Bas Couwenberg
sebastic at xs4all.nl
Sun Mar 16 10:08:44 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastic-guest pushed a commit to tag v1.3.2
in repository osmpbf.
commit 89c61197d2e32166bcf0242c159ce694a8dd3221
Author: Jochen Topf <jochen at topf.org>
Date: Mon Mar 10 20:57:20 2014 +0100
Formatting and fixes one formatting-related bug.
There was a semikolon after an if()...
---
tools/osmpbf-outline.cpp | 115 ++++++++++++++++++++++++++++-------------------
1 file changed, 69 insertions(+), 46 deletions(-)
diff --git a/tools/osmpbf-outline.cpp b/tools/osmpbf-outline.cpp
index 547c833..e4f20e6 100644
--- a/tools/osmpbf-outline.cpp
+++ b/tools/osmpbf-outline.cpp
@@ -43,11 +43,11 @@ OSMPBF::PrimitiveBlock primblock;
// prints a formatted message to stdout, optionally color coded
void msg(const char* format, int color, va_list args) {
- if(usecolor) {
+ if (usecolor) {
fprintf(stdout, "\x1b[0;%dm", color);
}
vfprintf(stdout, format, args);
- if(usecolor) {
+ if (usecolor) {
fprintf(stdout, "\x1b[0m\n");
} else {
fprintf(stdout, "\n");
@@ -98,15 +98,16 @@ int main(int argc, char *argv[]) {
#endif
static struct option long_options[] = {
- {"color", no_argument, 0, 'c'},
- {0,0,0,0}
+ {"color", no_argument, 0, 'c'},
+ {0, 0, 0, 0}
};
while (1) {
int c = getopt_long(argc, argv, "c", long_options, 0);
- if (c == -1)
+ if (c == -1) {
break;
+ }
switch (c) {
case 'c':
@@ -118,35 +119,40 @@ int main(int argc, char *argv[]) {
}
// check for proper command line args
- if(optind != argc-1)
+ if (optind != argc-1) {
err("usage: %s [--color] file.osm.pbf", argv[0]);
+ }
// open specified file
FILE *fp = fopen(argv[optind], "rb");
// read while the file has not reached its end
- while(!feof(fp)) {
+ while (!feof(fp)) {
// storage of size, used multiple times
int32_t sz;
// read the first 4 bytes of the file, this is the size of the blob-header
- if(fread(&sz, sizeof(sz), 1, fp) != 1)
+ if (fread(&sz, sizeof(sz), 1, fp) != 1) {
break; // end of file reached
+ }
// convert the size from network byte-order to host byte-order
sz = ntohl(sz);
// ensure the blob-header is smaller then MAX_BLOB_HEADER_SIZE
- if(sz > OSMPBF::max_blob_header_size)
+ if (sz > OSMPBF::max_blob_header_size) {
err("blob-header-size is bigger then allowed (%u > %u)", sz, OSMPBF::max_blob_header_size);
+ }
// read the blob-header from the file
- if(fread(buffer, sz, 1, fp) != 1)
+ if (fread(buffer, sz, 1, fp) != 1) {
err("unable to read blob-header from file");
+ }
// parse the blob-header from the read-buffer
- if(!blobheader.ParseFromArray(buffer, sz))
+ if (!blobheader.ParseFromArray(buffer, sz)) {
err("unable to parse blob header");
+ }
// tell about the blob-header
info("\nBlobHeader (%d bytes)", sz);
@@ -157,20 +163,24 @@ int main(int argc, char *argv[]) {
debug(" datasize = %u", sz);
// optional indexdata
- if(blobheader.has_indexdata())
+ if (blobheader.has_indexdata()) {
debug(" indexdata = %u bytes", blobheader.indexdata().size());
+ }
// ensure the blob is smaller then MAX_BLOB_SIZE
- if(sz > OSMPBF::max_uncompressed_blob_size)
+ if (sz > OSMPBF::max_uncompressed_blob_size) {
err("blob-size is bigger then allowed (%u > %u)", sz, OSMPBF::max_uncompressed_blob_size);
+ }
// read the blob from the file
- if(fread(buffer, sz, 1, fp) != 1)
+ if (fread(buffer, sz, 1, fp) != 1) {
err("unable to read blob from file");
+ }
// parse the blob from the read-buffer
- if(!blob.ParseFromArray(buffer, sz))
+ if (!blob.ParseFromArray(buffer, sz)) {
err("unable to parse blob");
+ }
// tell about the blob-header
info("Blob (%d bytes)", sz);
@@ -179,7 +189,7 @@ int main(int argc, char *argv[]) {
bool found_data = false;
// if the blob has uncompressed data
- if(blob.has_raw()) {
+ if (blob.has_raw()) {
// we have at least one datastream
found_data = true;
@@ -187,8 +197,9 @@ int main(int argc, char *argv[]) {
sz = blob.raw().size();
// check that raw_size is set correctly
- if(sz != blob.raw_size())
+ if (sz != blob.raw_size()) {
warn(" reports wrong raw_size: %u bytes", blob.raw_size());
+ }
// tell about the blob-data
debug(" contains uncompressed data: %u bytes", sz);
@@ -198,10 +209,11 @@ int main(int argc, char *argv[]) {
}
// if the blob has zlib-compressed data
- if(blob.has_zlib_data()) {
+ if (blob.has_zlib_data()) {
// issue a warning if there is more than one data steam, a blob may only contain one data stream
- if(found_data)
+ if (found_data) {
warn(" contains several data streams");
+ }
// we have at least one datastream
found_data = true;
@@ -233,13 +245,13 @@ int main(int argc, char *argv[]) {
z.zfree = Z_NULL;
z.opaque = Z_NULL;
- if(inflateInit(&z) != Z_OK) {
+ if (inflateInit(&z) != Z_OK) {
err(" failed to init zlib stream");
}
- if(inflate(&z, Z_FINISH) != Z_STREAM_END) {
+ if (inflate(&z, Z_FINISH) != Z_STREAM_END) {
err(" failed to inflate zlib stream");
}
- if(inflateEnd(&z) != Z_OK) {
+ if (inflateEnd(&z) != Z_OK) {
err(" failed to deinit zlib stream");
}
@@ -248,10 +260,11 @@ int main(int argc, char *argv[]) {
}
// if the blob has lzma-compressed data
- if(blob.has_lzma_data()) {
+ if (blob.has_lzma_data()) {
// issue a warning if there is more than one data steam, a blob may only contain one data stream
- if(found_data)
+ if (found_data) {
warn(" contains several data streams");
+ }
// we have at least one datastream
found_data = true;
@@ -265,20 +278,22 @@ int main(int argc, char *argv[]) {
}
// check we have at least one data-stream
- if(!found_data)
+ if (!found_data) {
err(" does not contain any known data stream");
+ }
// switch between different blob-types
- if(blobheader.type() == "OSMHeader") {
+ if (blobheader.type() == "OSMHeader") {
// tell about the OSMHeader blob
info(" OSMHeader");
// parse the HeaderBlock from the blob
- if(!headerblock.ParseFromArray(unpack_buffer, sz))
+ if (!headerblock.ParseFromArray(unpack_buffer, sz)) {
err("unable to parse header block");
+ }
// tell about the bbox
- if(headerblock.has_bbox()) {
+ if (headerblock.has_bbox()) {
OSMPBF::HeaderBBox bbox = headerblock.bbox();
debug(" bbox: %.7f,%.7f,%.7f,%.7f",
(double)bbox.left() / OSMPBF::lonlat_resolution,
@@ -288,29 +303,32 @@ int main(int argc, char *argv[]) {
}
// tell about the required features
- for(int i = 0, l = headerblock.required_features_size(); i < l; i++)
+ for (int i = 0, l = headerblock.required_features_size(); i < l; i++) {
debug(" required_feature: %s", headerblock.required_features(i).c_str());
+ }
// tell about the optional features
- for(int i = 0, l = headerblock.optional_features_size(); i < l; i++)
+ for (int i = 0, l = headerblock.optional_features_size(); i < l; i++) {
debug(" optional_feature: %s", headerblock.optional_features(i).c_str());
+ }
// tell about the writing program
- if(headerblock.has_writingprogram());
+ if (headerblock.has_writingprogram()) {
debug(" writingprogram: %s", headerblock.writingprogram().c_str());
+ }
// tell about the source
- if(headerblock.has_source())
+ if (headerblock.has_source()) {
debug(" source: %s", headerblock.source().c_str());
- }
-
- else if(blobheader.type() == "OSMData") {
+ }
+ } else if (blobheader.type() == "OSMData") {
// tell about the OSMData blob
info(" OSMData");
// parse the PrimitiveBlock from the blob
- if(!primblock.ParseFromArray(unpack_buffer, sz))
+ if (!primblock.ParseFromArray(unpack_buffer, sz)) {
err("unable to parse primitive block");
+ }
// tell about the block's meta info
debug(" granularity: %u", primblock.granularity());
@@ -325,50 +343,55 @@ int main(int argc, char *argv[]) {
debug(" primitivegroups: %u groups", primblock.primitivegroup_size());
// iterate over all PrimitiveGroups
- for(int i = 0, l = primblock.primitivegroup_size(); i < l; i++) {
+ for (int i = 0, l = primblock.primitivegroup_size(); i < l; i++) {
// one PrimitiveGroup from the the Block
OSMPBF::PrimitiveGroup pg = primblock.primitivegroup(i);
bool found_items=false;
// tell about nodes
- if(pg.nodes_size() > 0) {
+ if (pg.nodes_size() > 0) {
found_items = true;
debug(" nodes: %d", pg.nodes_size());
- if(pg.nodes(0).has_info())
+ if (pg.nodes(0).has_info()) {
debug(" with meta-info");
+ }
}
// tell about dense nodes
- if(pg.has_dense()) {
+ if (pg.has_dense()) {
found_items = true;
debug(" dense nodes: %d", pg.dense().id_size());
- if(pg.dense().has_denseinfo())
+ if (pg.dense().has_denseinfo()) {
debug(" with meta-info");
+ }
}
// tell about ways
- if(pg.ways_size() > 0) {
+ if (pg.ways_size() > 0) {
found_items = true;
debug(" ways: %d", pg.ways_size());
- if(pg.ways(0).has_info())
+ if (pg.ways(0).has_info()) {
debug(" with meta-info");
+ }
}
// tell about relations
- if(pg.relations_size() > 0) {
+ if (pg.relations_size() > 0) {
found_items = true;
debug(" relations: %d", pg.relations_size());
- if(pg.relations(0).has_info())
+ if (pg.relations(0).has_info()) {
debug(" with meta-info");
+ }
}
- if(!found_items)
+ if (!found_items) {
warn(" contains no items");
+ }
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmpbf.git
More information about the Pkg-grass-devel
mailing list