[osmpbf] 01/09: Imported Upstream version 1.3.2
Bas Couwenberg
sebastic at xs4all.nl
Wed Mar 12 21:30:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastic-guest pushed a commit to branch debian
in repository osmpbf.
commit 51189c8bebec795acf5ddc55375826d593b7d817
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Wed Mar 12 19:05:53 2014 +0100
Imported Upstream version 1.3.2
---
.gitignore | 6 +
README | 53 ++++++---
ReleaseNotes.txt | 8 ++
build.xml | 2 +-
debian/.gitignore | 8 ++
debian/changelog | 39 +------
debian/clean | 2 +
debian/compat | 2 +-
debian/control | 57 ++++++++--
debian/copyright | 56 +++++++---
debian/{docs => libosmpbf-dev.docs} | 0
debian/libosmpbf-dev.install | 2 +
debian/libosmpbf-java.install | 1 +
debian/osmpbf-bin.install | 1 +
...{libosmpbf-dev.manpages => osmpbf-bin.manpages} | 0
debian/rules | 100 +++++------------
debian/watch | 2 +
include/osmpbf/osmpbf.h | 2 +-
pom.xml | 2 +-
src/Makefile | 16 ++-
tools/Makefile | 13 ++-
tools/osmpbf-outline.cpp | 121 +++++++++++++--------
22 files changed, 280 insertions(+), 213 deletions(-)
diff --git a/.gitignore b/.gitignore
index c7ed701..ed0675e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,11 @@
+build-stamp
+build
+configure-stamp
+osmpbf.jar
+generated.java
include/osmpbf/*.pb.h
src/*.pb.h
src/*.pb.o
src/libosmpbf.a
*.swp
+obj-x86_64-linux-gnu
diff --git a/README b/README
index 2e8517b..05c386d 100644
--- a/README
+++ b/README
@@ -1,34 +1,59 @@
-OSM PBF
-=======
+OSMPBF
+======
-See http://wiki.openstreetmap.org/wiki/PBF_Format .
+Osmpbf is a Java/C library to read and write OpenStreetMap PBF files.
+PBF (Protocol buffer Binary Format) is a binary file format for OpenStreetMap
+data that uses Google Protocol Buffers as low-level storage.
-There is a Java and a C version of the PBF library code here.
+For more information see http://wiki.openstreetmap.org/wiki/PBF_Format .
+
+
+Java Version
+============
+
+To build the osmpbf.jar file run:
+ ant
+
+For a Java usage example, see src.java/crosby/binary/test/ReadFileExample.java
-For a Java usage example, see src.java\crosby\binary\test\ReadFileExample.java
C Version
=========
To compile:
- cd src
- make
+ make -C src
To install:
- cd src
- make install
+ make -C src install
+
+There is a tool named osmpbf-outline that shows a debug output of the contents
+of a PBF file. To compile it:
+ make -C tools
-To build the Debian/Ubuntu package call:
- debuild -I -us -uc
-To install the Debian/Ubuntu package call:
- sudo dpkg --install ../libosmpbf-dev*.deb
+Using the C Library
+===================
To include in your program use:
#include <osmpbf/osmpbf.h>
and link with:
- -lpthread -lz -lprotobuf-lite -losmpbf
+ -pthread -lz -lprotobuf-lite -losmpbf
+
+
+Debian/Ubuntu Packages
+======================
+
+To build the Debian/Ubuntu packages:
+ debuild -I -us -uc
+
+To install the Debian/Ubuntu packages:
+ sudo dpkg --install ../libosmpbf-dev_*.deb
+ sudo dpkg --install ../libosmpbf-java_*.deb
+ sudo dpkg --install ../osmpbf-bin_*.deb
+
+To clean up after:
+ debclean
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index 20e18e0..2dfc41e 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -1,4 +1,12 @@
----------------------------------------
+Release notes for 1.3.2 -- 2014-03-12
+----------------------------------------
+
+Small bugfixes and build enhancements.
+Improved Debian build in coordination with Debian maintainers.
+
+
+----------------------------------------
Release notes for 1.3.1 -- 2013-12-11
----------------------------------------
diff --git a/build.xml b/build.xml
index e302a1e..c1563d7 100644
--- a/build.xml
+++ b/build.xml
@@ -21,7 +21,7 @@
<exec executable="/bin/sh">
<arg value="./build.sh"/>
</exec>
- <javac destdir="${build.dir}">
+ <javac includeantruntime="false" destdir="${build.dir}">
<src>
<dirset dir="${src.dir}"/>
<dirset dir="${src.generated.dir}"/>
diff --git a/debian/.gitignore b/debian/.gitignore
new file mode 100644
index 0000000..e656fd6
--- /dev/null
+++ b/debian/.gitignore
@@ -0,0 +1,8 @@
+.mh
+*.debhelper.log
+*.substvars
+files
+libosmpbf-dev
+libosmpbf-java
+osmpbf-bin
+tmp
diff --git a/debian/changelog b/debian/changelog
index 5f0d629..a9c7d91 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,38 +1,5 @@
-libosmpbf-dev (1.3.1) maverick; urgency=low
+osmpbf (1.3.2) UNRELEASED; urgency=low
- * Several building fixes and enhancements
+ * unreleased
- -- Jochen Topf <jochen at topf.org> Wed, 11 Dec 2013 21:46:12 +0100
-
-libosmpbf-dev (1.3.0) maverick; urgency=low
-
- * Added fields into OSMHeader for OSM replication.
- * Version number change to reflect official new version
-
- -- Scott Crosby <scott at sacrosby.com> Wed, 04 Dec 2012 21:29:37 -0500
-
-libosmpbf-dev (1.2.1) maverick; urgency=low
-
- * Version number change to reflect official new version
-
- -- Jochen Topf <jochen at topf.org> Wed, 19 Oct 2011 09:29:37 +0100
-
-libosmpbf-dev (1.1.1j2) maverick; urgency=low
-
- * Add manpage for osmpbf-outline tool
-
- -- Jochen Topf <jochen at topf.org> Fri, 6 Jun 2011 10:30:12 +0100
-
-libosmpbf-dev (1.1.1j1) maverick; urgency=low
-
- * Add support for OSM history file
- * Add some often used constants to OSMPBF namespace
- * Add osmpbf-outline testing tool
-
- -- Jochen Topf <jochen at topf.org> Fri, 3 Jun 2011 11:36:17 +0100
-
-libosmpbf-dev (0.1) maverick; urgency=low
-
- * Initial debian package
-
- -- Jochen Topf <jochen at topf.org> Wed, 13 Apr 2011 21:50:15 +0100
+ -- Jochen Topf <jochen at topf.org> Wed, 12 Mar 2014 14:17:12 +0100
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..13d6ffc
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1,2 @@
+include/osmpbf/fileformat.pb.h
+include/osmpbf/osmformat.pb.h
diff --git a/debian/compat b/debian/compat
index 7f8f011..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-7
+9
diff --git a/debian/control b/debian/control
index 5452bb4..9baa678 100644
--- a/debian/control
+++ b/debian/control
@@ -1,14 +1,51 @@
-Source: libosmpbf-dev
-Section: libdevel
-Priority: optional
+Source: osmpbf
Maintainer: Jochen Topf <jochen at topf.org>
-Build-Depends: debhelper (>= 7), libprotobuf-dev, protobuf-compiler
-Standards-Version: 3.9.1
-Homepage: http://wiki.openstreetmap.org/wiki/PBF_Format
+Section: java
+Priority: optional
+Build-Depends: debhelper (>= 9~),
+ protobuf-compiler,
+ libprotobuf-java,
+ ant,
+ default-jdk,
+ libprotobuf-dev,
+ maven-repo-helper
+Standards-Version: 3.9.5
+Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-grass/osmpbf.git;a=summary
+Vcs-Git: git://anonscm.debian.org/pkg-grass/osmpbf.git
+Homepage: http://github.com/scrosby/OSM-binary
+
+Package: libosmpbf-java
+Architecture: all
+Depends: ${misc:Depends}
+Description: Java access library for OpenStreetMap PBF file format
+ Osmpbf is a Java/C library to read and write OpenStreetMap PBF files.
+ PBF (Protocol buffer Binary Format) is a binary file format for OpenStreetMap
+ data that uses Google Protocol Buffers as low-level storage.
+ .
+ This package provides a Java library.
Package: libosmpbf-dev
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Library for reading OSM PBF files.
- Interface definition and library for reading binary
- OpenStreetMap data files.
+Section: libdevel
+Depends: ${misc:Depends}
+Description: C headers for OpenStreetMap PBF file format
+ Osmpbf is a Java/C library to read and write OpenStreetMap PBF files.
+ PBF (Protocol buffer Binary Format) is a binary file format for OpenStreetMap
+ data that uses Google Protocol Buffers as low-level storage.
+ .
+ This package provides the C headers to be used in third-party
+ applications.
+
+Package: osmpbf-bin
+Architecture: any
+Section: utils
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: OpenStreetMap PBF file format library - tools
+ Osmpbf is a Java/C library to read and write OpenStreetMap PBF files.
+ PBF (Protocol buffer Binary Format) is a binary file format for OpenStreetMap
+ data that uses Google Protocol Buffers as low-level storage.
+ .
+ This package provides various tools to deal with OpenStreetMap PBF file
+ format.
+
diff --git a/debian/copyright b/debian/copyright
index 7386ce0..3ee781d 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,18 +1,42 @@
-Copyright (c) 2010 Scott A. Crosby. <scott at sacrosby.com>
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Source: http://github.com/scrosby/OSM-binary
+Upstream-Contact: Scott A. Crosby <scott at sacrosby.com>
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-On Debian systems, the license text can usually be found in
-/usr/share/common-licenses.
+Files: *
+Copyright: © 2010, Scott A. Crosby <scott at sacrosby.com>
+License: LGPL-3+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+ .
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU Lesser General Public License
+ version 3 can be found in "/usr/share/common-licenses/LGPL-3".
+Files: debian/*
+Copyright: © 2010-2012, Giovanni Mascellani <gio at debian.org>
+ © 2011-2013, David Paleino <dapal at debian.org>
+License: GPL-3+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ version 3 can be found in "/usr/share/common-licenses/GPL-3".
diff --git a/debian/docs b/debian/libosmpbf-dev.docs
similarity index 100%
rename from debian/docs
rename to debian/libosmpbf-dev.docs
diff --git a/debian/libosmpbf-dev.install b/debian/libosmpbf-dev.install
new file mode 100644
index 0000000..f6ad287
--- /dev/null
+++ b/debian/libosmpbf-dev.install
@@ -0,0 +1,2 @@
+usr/include/
+usr/lib/
diff --git a/debian/libosmpbf-java.install b/debian/libosmpbf-java.install
new file mode 100644
index 0000000..8f04649
--- /dev/null
+++ b/debian/libosmpbf-java.install
@@ -0,0 +1 @@
+osmpbf.jar usr/share/java
diff --git a/debian/osmpbf-bin.install b/debian/osmpbf-bin.install
new file mode 100644
index 0000000..c703cf8
--- /dev/null
+++ b/debian/osmpbf-bin.install
@@ -0,0 +1 @@
+usr/bin/
diff --git a/debian/libosmpbf-dev.manpages b/debian/osmpbf-bin.manpages
similarity index 100%
rename from debian/libosmpbf-dev.manpages
rename to debian/osmpbf-bin.manpages
diff --git a/debian/rules b/debian/rules
index 9f5587f..5492959 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,89 +1,39 @@
#!/usr/bin/make -f
# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-configure: configure-stamp
-configure-stamp:
- dh_testdir
-
- # Add here commands to configure the package.
+CXXFLAGS += $(CPPFLAGS)
- touch configure-stamp
+%:
+ dh $@ --buildsystem makefile --parallel
-build: build-stamp
+override_dh_auto_clean:
+ dh_auto_clean --buildsystem ant
+ dh_auto_clean -Dsrc
+ dh_auto_clean -Dtools
+ mh_clean
-build-stamp: configure-stamp
- dh_testdir
+override_dh_auto_configure:
+ dh_auto_configure --buildsystem ant
+ dh_auto_configure -Dsrc
+ dh_auto_configure -Dtools
- # Add here commands to compile the package.
- $(MAKE) -C src
- $(MAKE) -C tools
+override_dh_auto_build:
+ dh_auto_build --buildsystem ant
+ dh_auto_build -Dsrc
+ dh_auto_build -Dtools
- touch $@
+override_dh_auto_install:
+ dh_auto_install --buildsystem ant
+ dh_auto_install -Dsrc -- PREFIX=/usr
+ dh_auto_install -Dtools -- PREFIX=/usr
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
+override_dh_installchangelogs:
+ dh_installchangelogs -- ReleaseNotes.txt
- # Add here commands to clean up after the build process.
- $(MAKE) -C src clean || /bin/true
- $(MAKE) -C tools clean || /bin/true
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_prep
- dh_installdirs
-
- # Add here commands to install the package into debian/libosmpbf-dev.
- $(MAKE) -C src DESTDIR=$(CURDIR)/debian/libosmpbf-dev PREFIX=/usr install
- $(MAKE) -C tools DESTDIR=$(CURDIR)/debian/libosmpbf-dev PREFIX=/usr install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
+override_dh_install:
dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+ mh_installjar -plibosmpbf-java -l pom.xml osmpbf.jar
+ mh_installpom -plibosmpbf-java pom.xml
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 0000000..dabf08d
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,2 @@
+version=3
+http://githubredir.debian.net/github/scrosby/OSM-binary/v(\d+.*)\.tar\.gz
diff --git a/include/osmpbf/osmpbf.h b/include/osmpbf/osmpbf.h
index 093f4b6..6045baa 100644
--- a/include/osmpbf/osmpbf.h
+++ b/include/osmpbf/osmpbf.h
@@ -7,7 +7,7 @@
// this describes the high-level OSM objects
#include <osmpbf/osmformat.pb.h> // IWYU pragma: export
-#define OSMPBF_VERSION "1.3.1"
+#define OSMPBF_VERSION "1.3.2"
namespace OSMPBF {
diff --git a/pom.xml b/pom.xml
index 91eee77..c653c20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>crosby.binary</groupId>
<artifactId>osmpbf</artifactId>
<packaging>jar</packaging>
- <version>1.3.1</version>
+ <version>1.3.2</version>
<name>OSM-Binary</name>
<description>Library for the OpenStreetMap PBF format</description>
<url>https://github.com/scrosby/OSM-binary</url>
diff --git a/src/Makefile b/src/Makefile
index f621b96..a7fa8e8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,10 +1,14 @@
-PREFIX ?= /usr/local
-CXX ?= g++
-CXXFLAGS ?= -O3 -fPIC
+# these default settings can be overridden by setting environment variables
+PREFIX ?= /usr/local
+CXX ?= g++
+CXXFLAGS ?= -O3
+AR ?= ar
+PROTOC ?= protoc
-AR ?= ar
-PROTOC ?= protoc
+CXXFLAGS += -Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wno-long-long
+
+.PHONY: clean install
all: libosmpbf.a ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h
@@ -12,7 +16,7 @@ libosmpbf.a: fileformat.pb.o osmformat.pb.o
$(AR) -cr $@ fileformat.pb.o osmformat.pb.o
%.pb.o: %.pb.cc
- $(CXX) $(CXXFLAGS) -c -o $@ $<
+ $(CXX) $(CXXFLAGS) -fPIC -c -o $@ $<
%.pb.cc ../include/osmpbf/%.pb.h: %.proto
$(PROTOC) --proto_path=. --cpp_out=. $<
diff --git a/tools/Makefile b/tools/Makefile
index c435845..5051d52 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,11 +1,13 @@
-PREFIX ?= /usr/local
-CXX ?= g++
+# these default settings can be overridden by setting environment variables
+PREFIX ?= /usr/local
+CXX ?= g++
CXXFLAGS ?= -g
-CXXFLAGS += -I../include
-LDFLAGS += -L../src -pthread -lz -lprotobuf-lite -losmpbf
+CXXFLAGS += -I../include -Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wno-long-long
+LDFLAGS += -L../src -pthread -lz -lprotobuf-lite -losmpbf
+.PHONY: clean install
all: osmpbf-outline
@@ -14,7 +16,8 @@ osmpbf-outline: osmpbf-outline.cpp
install:
install -m 755 -d $(DESTDIR)$(PREFIX)/bin
- install -m 644 -s osmpbf-outline $(DESTDIR)$(PREFIX)/bin
+ install -m 755 -s osmpbf-outline $(DESTDIR)$(PREFIX)/bin
clean:
rm -f osmpbf-outline
+
diff --git a/tools/osmpbf-outline.cpp b/tools/osmpbf-outline.cpp
index 18d5ff9..23ffc71 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,44 @@ 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");
+ if (!fp) {
+ err("can't open file '%s'", argv[optind]);
+ }
+
// 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 +167,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 +193,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 +201,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 +213,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 +249,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 +264,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 +282,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 +307,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++)
- debug(" required_feature: %s", headerblock.optional_features(i).c_str());
+ 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 +347,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