Compare commits
115 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
30db69822d | |
|
|
0265ab5f3d | |
|
|
5b5ae13a4a | |
|
|
c33d74be06 | |
|
|
01f1a3f0be | |
|
|
719a26d4af | |
|
|
5b6d2afa9c | |
|
|
830df177b5 | |
|
|
eda1580ce9 | |
|
|
9eddf3d1f8 | |
|
|
8857d08d80 | |
|
|
28f76c6bf0 | |
|
|
5bb6bbfc62 | |
|
|
bc457ce7c0 | |
|
|
7c3f68f622 | |
|
|
ca046bcff4 | |
|
|
4048bf6e35 | |
|
|
de424ed053 | |
|
|
0cc6f10fcf | |
|
|
32c3e92166 | |
|
|
a2e364e5e7 | |
|
|
92a9c8d572 | |
|
|
68d2b397a1 | |
|
|
c5044e0f0a | |
|
|
a8c4dd1c11 | |
|
|
505052800e | |
|
|
f427d7458e | |
|
|
7050448620 | |
|
|
ecf26bf6a3 | |
|
|
65e7e976f5 | |
|
|
fa266b6f9b | |
|
|
db10ff0949 | |
|
|
802d4603b2 | |
|
|
30097cd4cb | |
|
|
4e009b0055 | |
|
|
8219186b2e | |
|
|
374895c1e3 | |
|
|
3b3b9cd2cd | |
|
|
7259487654 | |
|
|
85e763ea0f | |
|
|
ffd833fb22 | |
|
|
6483ae0dcb | |
|
|
587cbd2776 | |
|
|
37adab91e5 | |
|
|
4195fe6557 | |
|
|
6e9c00769f | |
|
|
cffbe661b1 | |
|
|
a3f9e58622 | |
|
|
278c07098f | |
|
|
edad45f7ab | |
|
|
6d91b131e1 | |
|
|
7e111e6791 | |
|
|
0e99a6fef2 | |
|
|
d9ee34140d | |
|
|
40d041e344 | |
|
|
5b8c95fb1d | |
|
|
6d42449842 | |
|
|
22b9f74702 | |
|
|
a1e4a59995 | |
|
|
3dac689ea7 | |
|
|
1c7fadcde8 | |
|
|
cba41e6ce1 | |
|
|
77f631ee8e | |
|
|
751bada225 | |
|
|
025a229a0c | |
|
|
bc5ddaaa74 | |
|
|
c5fc8124bc | |
|
|
eccef0c255 | |
|
|
ee9144ef25 | |
|
|
d5bdd020c1 | |
|
|
9985bf46ad | |
|
|
712c8cacf7 | |
|
|
b787a1fdaa | |
|
|
22092218af | |
|
|
8789d7f40c | |
|
|
bf2076840e | |
|
|
bd8b4e8a17 | |
|
|
de663a3de3 | |
|
|
26d0a8328d | |
|
|
23c0203f27 | |
|
|
7b8354aadb | |
|
|
a683b4c2fa | |
|
|
b77df6b492 | |
|
|
f1a1bfbe49 | |
|
|
35ab2cdad0 | |
|
|
a386f1b48c | |
|
|
218bfe8ed8 | |
|
|
e5de634ce2 | |
|
|
7982f902f7 | |
|
|
f0715149be | |
|
|
1b5f7f5fde | |
|
|
33e940238b | |
|
|
fa86a8a640 | |
|
|
ac8cf96890 | |
|
|
d77e04b6eb | |
|
|
e7d3201a97 | |
|
|
1651aa12b4 | |
|
|
6785d43ba7 | |
|
|
4374b9a535 | |
|
|
27eebf0e5f | |
|
|
4c743e9d9a | |
|
|
2b4045f84b | |
|
|
721fade148 | |
|
|
92b3bcb185 | |
|
|
c6814279f5 | |
|
|
58fc205b15 | |
|
|
e464c06294 | |
|
|
a627e4b9dd | |
|
|
18de493160 | |
|
|
0b753d8efd | |
|
|
a748ef336b | |
|
|
8ab05caeb4 | |
|
|
09845ca408 | |
|
|
e0d4b58e66 | |
|
|
98ac3470ce |
|
|
@ -0,0 +1,20 @@
|
|||
name: Windows Build
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Create build directory
|
||||
run: mkdir build
|
||||
shell: bash
|
||||
|
||||
- name: Configure
|
||||
run: cmake -LA .. -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
shell: bash
|
||||
working-directory: build
|
||||
|
||||
- name: Build
|
||||
run: cmake --build .
|
||||
shell: bash
|
||||
working-directory: build
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
name: Build
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Create build directory
|
||||
run: mkdir build
|
||||
shell: bash
|
||||
|
||||
- name: Configure
|
||||
run: cmake -LA .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
|
||||
shell: bash
|
||||
working-directory: build
|
||||
|
||||
- name: Build
|
||||
run: make VERBOSE=1
|
||||
shell: bash
|
||||
working-directory: build
|
||||
|
||||
- name: Run outline
|
||||
run: build/demo/osmpbf-outline resources/sample.pbf
|
||||
shell: bash
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
name: Install Prerequisites on macOS
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Install packages
|
||||
run: brew install protobuf
|
||||
shell: bash
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
name: Install Prerequisites on Ubuntu
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Install packages
|
||||
run: sudo apt-get install -yq protobuf-compiler libprotobuf-dev
|
||||
shell: bash
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
name: Install Prerequisites on Windows
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
steps:
|
||||
- name: Install packages
|
||||
run: vcpkg install protobuf:x64-windows zlib:x64-windows
|
||||
shell: powershell
|
||||
|
||||
|
|
@ -1,12 +1,85 @@
|
|||
name: C CI
|
||||
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
ubuntu22:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
CXXFLAGS: -Werror -Wall -pedantic
|
||||
BUILD_TYPE: Debug
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt-get install protobuf-compiler libprotobuf-dev
|
||||
- run: make -C src
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-ubuntu
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
ubuntu24:
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
CXXFLAGS: -Werror -Wall -pedantic
|
||||
BUILD_TYPE: Debug
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-ubuntu
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
ubuntu26:
|
||||
runs-on: ubuntu-26.04
|
||||
env:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
CXXFLAGS: -Werror -Wall -pedantic
|
||||
BUILD_TYPE: Debug
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-ubuntu
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
ubuntu24-clang:
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
CC: clang-18
|
||||
CXX: clang++-18
|
||||
CXXFLAGS: -Werror -Wall -pedantic
|
||||
BUILD_TYPE: Debug
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-ubuntu
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
ubuntu24-release:
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
# disabled array-bounds warning because it is triggered by code generated by the protoc compiler
|
||||
CXXFLAGS: -Werror -Wall -pedantic -Wno-array-bounds
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-ubuntu
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: -Werror -Wall -pedantic -Wno-nullability-extension
|
||||
BUILD_TYPE: Debug
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-macos
|
||||
- uses: ./.github/actions/build
|
||||
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: ./.github/actions/install-windows
|
||||
- uses: ./.github/actions/build-windows
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,83 @@
|
|||
name: Java CI
|
||||
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
maven-ubuntu22:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
with:
|
||||
version: '3.x'
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
maven-ubuntu24:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
maven-ubuntu26:
|
||||
runs-on: ubuntu-26.04
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
ant-ubuntu22:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler libprotobuf-java
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Ant
|
||||
run: ant
|
||||
|
||||
ant-ubuntu24:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler libprotobuf-java
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Ant
|
||||
run: ant
|
||||
|
||||
ant-ubuntu26:
|
||||
runs-on: ubuntu-26.04
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: sudo apt-get install protobuf-compiler libprotobuf-java
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 8
|
||||
- name: Build with Ant
|
||||
run: ant
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
build-stamp
|
||||
build
|
||||
configure-stamp
|
||||
/build
|
||||
osmpbf.jar
|
||||
generated.java
|
||||
include/osmpbf/*.pb.h
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
## Unreleased
|
||||
|
||||
## Release notes for 1.7.0 (2026-07-26)
|
||||
|
||||
- C++: Fix buffer overflow in osmpbf-outline tool [#95](https://github.com/openstreetmap/OSM-binary/pull/95)
|
||||
- C++: Various small code cleanups and modernizations
|
||||
- C++: osmpbf-outline tool moved to demo directory, it isn't installed by default any more. This tool was never really useful for normal users, it is more a demo/example showing how to use the library
|
||||
|
||||
Note to packagers: You should remove the osmpbf-outline tool from packages.
|
||||
|
||||
## Release notes for 1.6.1 (2025-12-20)
|
||||
|
||||
- Java: Update to latest protoc and protobuf runtime versions [#92](https://github.com/openstreetmap/OSM-binary/pull/92)
|
||||
|
||||
## Release notes for 1.6.0 (2024-12-10)
|
||||
|
||||
- Java: Update to latest protoc and protobuf runtime versions [#84](https://github.com/openstreetmap/OSM-binary/pull/84)
|
||||
|
||||
## Release notes for 1.5.0 (2021-01-06)
|
||||
|
||||
- C: Support hardening buildflags set in the environment ([09845ca4](https://github.com/openstreetmap/OSM-binary/commit/09845ca4087c7404b1de33914233dbf53f9de4c3))
|
||||
- C: Updated CMake configuration. This can now completely replace the configuration using the Makefiles. The Makefiles are deprecated now and will be removed in a future version.
|
||||
- Proto: Add optional way to add node locations to way ([e7d3201](https://github.com/openstreetmap/OSM-binary/commit/e7d3201a97a86ef0c0608bfcd960e44e54962d7b))
|
||||
- Proto: Add optional LZ4 and ZSTD compressed data blocks ([218bfe8](https://github.com/openstreetmap/OSM-binary/commit/218bfe8ed800173279ede2d9028fd9a5c33d12e4))
|
||||
|
||||
## Release notes for 1.4.0 (2020-10-20)
|
||||
|
||||
- License the `.proto` and header files under MIT ([5a4c8c11](https://github.com/openstreetmap/OSM-binary/commit/5a4c8c11564104afca14b787ef14131053977b5b))
|
||||
- Proto: Disable deprecated `optimize_for = LITE_RUNTIME` option ([f7b77826](https://github.com/openstreetmap/OSM-binary/commit/f7b77826e493ce272daf5b1fe8b2143a818134c9))
|
||||
- Proto: Specify `proto2` syntax to fix warnings with protobuf 3.0.0 ([17f2228c](https://github.com/openstreetmap/OSM-binary/commit/17f2228ca80a6477af947c4d282b99a19482fb73))
|
||||
- C: Build and install a shared library ([cfea70cd](https://github.com/openstreetmap/OSM-binary/commit/cfea70cdc8f321c950f53250cd9b580043ab3266))
|
||||
- C: Add support for large files ([779715f1](https://github.com/openstreetmap/OSM-binary/commit/779715f1a09f32e235d6d621b37596632d8bcba0))
|
||||
- Java: Deploy Java library to Maven Central ([7a05c39e](https://github.com/openstreetmap/OSM-binary/commit/7a05c39ea5dcb8b8794e2a1b531b506ce1fae5f8))
|
||||
- Java: Update Java build
|
||||
- Enable GitHub CI for Java and C ([fcdf48d9](https://github.com/openstreetmap/OSM-binary/commit/fcdf48d942578af38897d4ea9f911bcdd888b3de), [2a636a31](https://github.com/openstreetmap/OSM-binary/commit/2a636a31f07d47cbb247a064bf8ec2bf9bc2bf65))
|
||||
|
||||
## Release notes for 1.3.3 (2014-03-15)
|
||||
|
||||
- Fixed ant build file.
|
||||
|
||||
## 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)
|
||||
|
||||
- Several building fixes and enhancements.
|
||||
|
||||
## Release notes for 1.3.0 (2012-12-04)
|
||||
|
||||
- Add osmosis replication fields into the header.
|
||||
-- Changes from Frederick Ramm <frederik@remote.org>
|
||||
|
||||
## Release notes for 1.2.1 (2011-10-29)
|
||||
|
||||
## Release notes for 1.2.0 (NOT RELEASED)
|
||||
|
||||
- Bad tag, so not releasable.
|
||||
- Switched to the lite (non-introspective) version of protocol buffers
|
||||
for a smaller library.
|
||||
- Includes support for "visible" flag on OSM objects. This allows PBF to
|
||||
handle OSM history files.
|
||||
- Namespace and include conventions changes for the C++ library. Everything
|
||||
is in the OSMPBF namespace. You now do:
|
||||
#include <osmpbf/osmpbf.h>
|
||||
- Added stuff needed to build Debian/Ubuntu libosmpbf-dev package containing
|
||||
the C++ library.
|
||||
- Added osmpbf-outline tool that shows internals of a PBF file for debugging.
|
||||
- Added magic file that can recognize OSM PBF files.
|
||||
|
||||
-- Changes from Jochen Topf <jochen@topf.org>
|
||||
Peter <github@mazdermind.de>
|
||||
|
||||
- Added a pom.xml
|
||||
|
||||
-- Changes from Zsombor Welker <flaktack@welker.hu>
|
||||
|
|
@ -1,15 +1,24 @@
|
|||
PROJECT(OSMBinary)
|
||||
cmake_minimum_required(VERSION 2.8.5)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
SET(SEARCH_PREFIX CACHE PATH "Additional prefix to search libraries (Protobuf etc.)" )
|
||||
project(osmpbf VERSION 1.7.0)
|
||||
|
||||
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${SEARCH_PREFIX})
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# This is needed for the protobuf_generate_cpp() function to work on newer
|
||||
# versions of the Protobuf CMake config.
|
||||
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "")
|
||||
|
||||
# This is needed so that we pick up the (more modern) CONFIG mode cmake file
|
||||
# before the (older) MODULE mode cmake config file. Seems to be needed on macOS.
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
|
||||
|
||||
include(FindProtobuf)
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIR})
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(osmpbf)
|
||||
|
||||
# The osmpbf-outline tool does not compile on Windows because getopt.h is missing
|
||||
if(NOT MSVC)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
add_subdirectory(demo)
|
||||
endif()
|
||||
|
|
|
|||
674
COPYING
674
COPYING
|
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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 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 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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
72
README.md
72
README.md
|
|
@ -1,57 +1,84 @@
|
|||
|
||||
# OSMPBF
|
||||
|
||||
Osmpbf is a Java/C library to read and write OpenStreetMap PBF files.
|
||||
https://github.com/openstreetmap/OSM-binary
|
||||
|
||||
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.
|
||||
|
||||
For more information see https://wiki.openstreetmap.org/wiki/PBF_Format .
|
||||
|
||||
Note that this is a low-level library that does only part of the
|
||||
encoding/decoding needed for actually writing/reading an OSM PBF file. For
|
||||
something more complete see [libosmium](https://osmcode.org/libosmium/).
|
||||
|
||||
[](https://github.com/openstreetmap/OSM-binary/actions/workflows/c.yml)
|
||||
[](https://github.com/openstreetmap/OSM-binary/actions/workflows/java.yml)
|
||||
[](https://repology.org/project/libosmpbf/versions)
|
||||
|
||||
## Java Version
|
||||
|
||||
We publish the Java library to [Maven Central](https://search.maven.org/):
|
||||
### Building with Maven
|
||||
|
||||
We publish the Java library to [Maven Central](https://mvnrepository.com/artifact/org.openstreetmap.pbf/osmpbf): 
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openstreetmap.pbf</groupId>
|
||||
<artifactId>osmpbf</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>${LATEST_VERSION}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
To build the Java library run:
|
||||
|
||||
```sh
|
||||
mvn package
|
||||
```
|
||||
|
||||
For a Java usage example, see src.java/crosby/binary/test/ReadFileExample.java
|
||||
For a Java usage example, see
|
||||
[`ReadFileTest`](https://github.com/openstreetmap/OSM-binary/blob/master/test.java/crosby/binary/ReadFileTest.java).
|
||||
|
||||
### Building with Ant
|
||||
|
||||
## C Version
|
||||
If you can not use Maven for some reason you can use the
|
||||
[Ant](https://ant.apache.org/) instead:
|
||||
|
||||
```sh
|
||||
ant
|
||||
```
|
||||
|
||||
This will build `osmpbf.jar` in the main directory.
|
||||
|
||||
This build is also used for Debian packaging.
|
||||
|
||||
## C++ Version
|
||||
|
||||
To compile:
|
||||
|
||||
```sh
|
||||
make -C src
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
To install:
|
||||
|
||||
```sh
|
||||
make -C src install
|
||||
make install
|
||||
```
|
||||
|
||||
There is a tool named osmpbf-outline that shows a debug output of the contents
|
||||
of a PBF file. To compile it:
|
||||
There is a demo tool named osmpbf-outline that shows a debug output of some of
|
||||
the contents of a PBF file. To run it:
|
||||
|
||||
```sh
|
||||
make -C tools
|
||||
demo/osmpbf-outline osm-file.osm.pbf
|
||||
```
|
||||
|
||||
|
||||
## Using the C Library
|
||||
## Using the C++ Library
|
||||
|
||||
To include in your program use:
|
||||
|
||||
|
|
@ -62,31 +89,10 @@ To include in your program use:
|
|||
and link with:
|
||||
|
||||
```
|
||||
-pthread -lz -lprotobuf-lite -losmpbf
|
||||
-pthread -lz -lprotobuf -losmpbf
|
||||
```
|
||||
|
||||
|
||||
## Debian/Ubuntu Packages
|
||||
|
||||
To build the Debian/Ubuntu packages:
|
||||
|
||||
```sh
|
||||
debuild -I -us -uc
|
||||
```
|
||||
|
||||
To install the Debian/Ubuntu packages:
|
||||
|
||||
```sh
|
||||
sudo dpkg --install ../libosmpbf-dev_*.deb
|
||||
sudo dpkg --install ../libosmpbf-java_*.deb
|
||||
sudo dpkg --install ../osmpbf-bin_*.deb
|
||||
```
|
||||
|
||||
To clean up after:
|
||||
```sh
|
||||
debclean
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The .proto definition files and osmpbf.h are licensed under the MIT license.
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
----------------------------------------
|
||||
Release notes for 1.3.3 -- 2014-03-15
|
||||
----------------------------------------
|
||||
|
||||
Fixed ant build file.
|
||||
|
||||
----------------------------------------
|
||||
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
|
||||
----------------------------------------
|
||||
|
||||
Several building fixes and enhancements.
|
||||
|
||||
|
||||
----------------------------------------
|
||||
Release notes for 1.3.0 -- 2012-12-04
|
||||
----------------------------------------
|
||||
|
||||
Add osmosis replication fields into the header.
|
||||
-- Changes from Frederick Ramm <frederik@remote.org>
|
||||
|
||||
|
||||
----------------------------------------
|
||||
Release notes for 1.2.1 -- 2011-10-29
|
||||
----------------------------------------
|
||||
|
||||
--------------------------------------
|
||||
Release notes for 1.2.0 -- NOT RELEASED
|
||||
--------------------------------------
|
||||
|
||||
* Bad tag, so not releasable.
|
||||
|
||||
|
||||
* Switched to the lite (non-introspective) version of protocol buffers
|
||||
for a smaller library.
|
||||
* Includes support for "visible" flag on OSM objects. This allows PBF to
|
||||
handle OSM history files.
|
||||
* Namespace and include conventions changes for the C++ library. Everything
|
||||
is in the OSMPBF namespace. You now do:
|
||||
#include <osmpbf/osmpbf.h>
|
||||
* Added stuff needed to build Debian/Ubuntu libosmpbf-dev package containing
|
||||
the C++ library.
|
||||
* Added osmpbf-outline tool that shows internals of a PBF file for debugging.
|
||||
* Added magic file that can recognize OSM PBF files.
|
||||
|
||||
-- Changes from Jochen Topf <jochen@topf.org>
|
||||
Peter <github@mazdermind.de>
|
||||
|
||||
* Added a pom.xml
|
||||
|
||||
-- Changes from Zsombor Welker <flaktack@welker.hu>
|
||||
4
build.sh
4
build.sh
|
|
@ -1,2 +1,2 @@
|
|||
protoc --java_out=generated.java src/osmformat.proto
|
||||
protoc --java_out=generated.java src/fileformat.proto
|
||||
protoc --java_out=generated.java osmpbf/osmformat.proto
|
||||
protoc --java_out=generated.java osmpbf/fileformat.proto
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<exec executable="/bin/sh">
|
||||
<arg value="./build.sh"/>
|
||||
</exec>
|
||||
<javac includeantruntime="false" destdir="${build.dir}">
|
||||
<javac includeantruntime="false" destdir="${build.dir}" source="1.8" target="1.8">
|
||||
<src path="${src.dir}"/>
|
||||
<src path="${src.generated.dir}"/>
|
||||
<classpath>
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
osmpbf (1.3.3) UNRELEASED; urgency=low
|
||||
|
||||
* unreleased
|
||||
|
||||
-- Jochen Topf <jochen@topf.org> Sat, 15 Mar 2014 16:10:12 +0100
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
include/osmpbf/fileformat.pb.h
|
||||
include/osmpbf/osmformat.pb.h
|
||||
|
|
@ -1 +0,0 @@
|
|||
9
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
Source: osmpbf
|
||||
Maintainer: Jochen Topf <jochen@topf.org>
|
||||
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
|
||||
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
|
||||
Section: libdevel
|
||||
Depends: libprotobuf-dev,
|
||||
${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.
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
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@sacrosby.com>
|
||||
|
||||
Files: *
|
||||
Copyright: © 2010, Scott A. Crosby <scott@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@debian.org>
|
||||
© 2011-2013, David Paleino <dapal@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".
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
src/fileformat.proto
|
||||
src/osmformat.proto
|
||||
README
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
usr/include/
|
||||
usr/lib/
|
||||
|
|
@ -1 +0,0 @@
|
|||
osmpbf.jar usr/share/java
|
||||
|
|
@ -1 +0,0 @@
|
|||
usr/bin/
|
||||
|
|
@ -1 +0,0 @@
|
|||
tools/osmpbf-outline.1
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
CXXFLAGS += $(CPPFLAGS)
|
||||
|
||||
%:
|
||||
dh $@ --buildsystem makefile --parallel
|
||||
|
||||
override_dh_auto_clean:
|
||||
dh_auto_clean --buildsystem ant
|
||||
dh_auto_clean -Dsrc
|
||||
dh_auto_clean -Dtools
|
||||
mh_clean
|
||||
|
||||
override_dh_auto_configure:
|
||||
dh_auto_configure --buildsystem ant
|
||||
dh_auto_configure -Dsrc
|
||||
dh_auto_configure -Dtools
|
||||
|
||||
override_dh_auto_build:
|
||||
dh_auto_build --buildsystem ant
|
||||
dh_auto_build -Dsrc
|
||||
dh_auto_build -Dtools
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install --buildsystem ant
|
||||
dh_auto_install -Dsrc -- PREFIX=/usr
|
||||
dh_auto_install -Dtools -- PREFIX=/usr
|
||||
|
||||
override_dh_installchangelogs:
|
||||
dh_installchangelogs -- ReleaseNotes.txt
|
||||
|
||||
override_dh_install:
|
||||
dh_install
|
||||
mh_installjar -plibosmpbf-java -l pom.xml osmpbf.jar
|
||||
mh_installpom -plibosmpbf-java pom.xml
|
||||
|
|
@ -1 +0,0 @@
|
|||
3.0 (native)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
version=3
|
||||
http://githubredir.debian.net/github/scrosby/OSM-binary/v(\d+.*)\.tar\.gz
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
find_package(ZLIB REQUIRED)
|
||||
find_package(Threads)
|
||||
|
||||
include_directories("${CMAKE_SOURCE_DIR}/include")
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
|
||||
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
|
||||
|
||||
add_executable(osmpbf-outline osmpbf-outline.cpp)
|
||||
|
||||
target_include_directories(osmpbf-outline SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
|
||||
target_link_libraries(osmpbf-outline PRIVATE osmpbf ZLIB::ZLIB protobuf::libprotobuf)
|
||||
set_property(TARGET osmpbf-outline PROPERTY CXX_STANDARD 11)
|
||||
|
||||
#install(TARGETS osmpbf-outline RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
#install(FILES osmpbf-outline.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
|
|
@ -15,22 +15,22 @@ osmpbf-outline - outline the content of an .osm.pbf or .osh.pbf file
|
|||
.SH DESCRIPTION
|
||||
|
||||
.I osmpbf-outline
|
||||
generates an colored outline an .osm.pbf or .osh.pbf file, revealing its inner structure.
|
||||
generates a colored outline of an .osm.pbf or .osh.pbf file, revealing its inner structure.
|
||||
It does not decode all information nor does it check for of possible mistakes, but it will
|
||||
warn on some bad mistakes one can make when generating .osm.pbf files.
|
||||
|
||||
This tool can be used by authors of .osm.pbf readers and writers and is useful to understand
|
||||
the inner blob/block structure of .osm.pbf files.
|
||||
|
||||
Its source code is heavily documented and can be used as a good start on how to read- and
|
||||
write .osm.pbf files with C++.
|
||||
Its source code is heavily documented and can be used as a good starting point
|
||||
understanding on how to read and write .osm.pbf files with C++.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP 5
|
||||
|
||||
.B -c --color
|
||||
usually colorization is disabled when writing to a file descriptor that is no tty (eg. when
|
||||
the output is piped to a file or to a pager like to more or less). Some pagers can handle ANSI
|
||||
.B -c, --color
|
||||
usually colorization is disabled when writing to a file descriptor that is not a tty (eg. when
|
||||
the output is piped to a file or to a pager like more or less). Some pagers can handle ANSI
|
||||
color code (
|
||||
.I more
|
||||
can, less can when invoked as
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
// used for 'isatty'
|
||||
#include <unistd.h>
|
||||
|
||||
// used for va_list in debug-print methods
|
||||
#include <stdarg.h>
|
||||
#include <cstdarg>
|
||||
|
||||
// file io lib
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
// getopt is used to check for the --color-flag
|
||||
#include <getopt.h>
|
||||
|
|
@ -20,47 +23,31 @@
|
|||
// this is the header to pbf format
|
||||
#include <osmpbf/osmpbf.h>
|
||||
|
||||
namespace {
|
||||
|
||||
// should the output use color?
|
||||
bool usecolor = false;
|
||||
|
||||
// buffer for reading a compressed blob from file
|
||||
char buffer[OSMPBF::max_uncompressed_blob_size];
|
||||
|
||||
// buffer for decompressing the blob
|
||||
char unpack_buffer[OSMPBF::max_uncompressed_blob_size];
|
||||
|
||||
// pbf struct of a BlobHeader
|
||||
OSMPBF::BlobHeader blobheader;
|
||||
|
||||
// pbf struct of a Blob
|
||||
OSMPBF::Blob blob;
|
||||
|
||||
// pbf struct of an OSM HeaderBlock
|
||||
OSMPBF::HeaderBlock headerblock;
|
||||
|
||||
// pbf struct of an OSM PrimitiveBlock
|
||||
OSMPBF::PrimitiveBlock primblock;
|
||||
|
||||
// prints a formatted message to stdout, optionally color coded
|
||||
void msg(const char* format, int color, va_list args) {
|
||||
if (usecolor) {
|
||||
fprintf(stdout, "\x1b[0;%dm", color);
|
||||
std::fprintf(stdout, "\x1b[0;%dm", color);
|
||||
}
|
||||
vfprintf(stdout, format, args);
|
||||
std::vfprintf(stdout, format, args);
|
||||
if (usecolor) {
|
||||
fprintf(stdout, "\x1b[0m\n");
|
||||
std::fprintf(stdout, "\x1b[0m\n");
|
||||
} else {
|
||||
fprintf(stdout, "\n");
|
||||
std::fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// prints a formatted message to stdout, color coded to red
|
||||
void err(const char* format, ...) {
|
||||
[[noreturn]] void err(const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
msg(format, 31, args);
|
||||
va_end(args);
|
||||
exit(1);
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
// prints a formatted message to stdout, color coded to yellow
|
||||
|
|
@ -87,23 +74,25 @@ void debug(const char* format, ...) {
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// application main method
|
||||
int main(int argc, char *argv[]) {
|
||||
// check if the output is a tty so we can use colors
|
||||
|
||||
#ifdef WIN32
|
||||
usecolor = 0;
|
||||
usecolor = false;
|
||||
#else
|
||||
usecolor = isatty(1);
|
||||
#endif
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"color", no_argument, 0, 'c'},
|
||||
{0, 0, 0, 0}
|
||||
option const long_options[] = {
|
||||
{"color", no_argument, nullptr, 'c'},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
while (1) {
|
||||
int c = getopt_long(argc, argv, "c", long_options, 0);
|
||||
while (true) {
|
||||
int const c = getopt_long(argc, argv, "c", long_options, nullptr);
|
||||
|
||||
if (c == -1) {
|
||||
break;
|
||||
|
|
@ -114,7 +103,7 @@ int main(int argc, char *argv[]) {
|
|||
usecolor = true;
|
||||
break;
|
||||
default:
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,19 +113,25 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// open specified file
|
||||
FILE *fp = fopen(argv[optind], "rb");
|
||||
FILE *fp = std::fopen(argv[optind], "rb");
|
||||
|
||||
if (!fp) {
|
||||
err("can't open file '%s'", argv[optind]);
|
||||
}
|
||||
|
||||
// buffer for reading a compressed blob from file
|
||||
static char buffer[OSMPBF::max_uncompressed_blob_size];
|
||||
|
||||
// buffer for decompressing the blob
|
||||
static char unpack_buffer[OSMPBF::max_uncompressed_blob_size];
|
||||
|
||||
// read while the file has not reached its end
|
||||
while (!feof(fp)) {
|
||||
while (!std::feof(fp)) {
|
||||
// storage of size, used multiple times
|
||||
int32_t sz;
|
||||
std::uint32_t sz = 0;
|
||||
|
||||
// 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 (std::fread(&sz, sizeof(sz), 1, fp) != 1) {
|
||||
break; // end of file reached
|
||||
}
|
||||
|
||||
|
|
@ -149,12 +144,15 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// read the blob-header from the file
|
||||
if (fread(buffer, sz, 1, fp) != 1) {
|
||||
if (std::fread(buffer, sz, 1, fp) != 1) {
|
||||
err("unable to read blob-header from file");
|
||||
}
|
||||
|
||||
// pbf struct of a BlobHeader
|
||||
OSMPBF::BlobHeader blobheader;
|
||||
|
||||
// parse the blob-header from the read-buffer
|
||||
if (!blobheader.ParseFromArray(buffer, sz)) {
|
||||
if (!blobheader.ParseFromArray(buffer, static_cast<int>(sz))) {
|
||||
err("unable to parse blob header");
|
||||
}
|
||||
|
||||
|
|
@ -177,12 +175,15 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// read the blob from the file
|
||||
if (fread(buffer, sz, 1, fp) != 1) {
|
||||
if (std::fread(buffer, sz, 1, fp) != 1) {
|
||||
err("unable to read blob from file");
|
||||
}
|
||||
|
||||
// pbf struct of a Blob
|
||||
OSMPBF::Blob blob;
|
||||
|
||||
// parse the blob from the read-buffer
|
||||
if (!blob.ParseFromArray(buffer, sz)) {
|
||||
if (!blob.ParseFromArray(buffer, static_cast<int>(sz))) {
|
||||
err("unable to parse blob");
|
||||
}
|
||||
|
||||
|
|
@ -201,15 +202,15 @@ int main(int argc, char *argv[]) {
|
|||
sz = blob.raw().size();
|
||||
|
||||
// check that raw_size is set correctly
|
||||
if (sz != blob.raw_size()) {
|
||||
warn(" reports wrong raw_size: %u bytes", blob.raw_size());
|
||||
if (sz != static_cast<std::uint32_t>(blob.raw_size())) {
|
||||
warn(" reports wrong raw_size: %d bytes", blob.raw_size());
|
||||
}
|
||||
|
||||
// tell about the blob-data
|
||||
debug(" contains uncompressed data: %u bytes", sz);
|
||||
|
||||
// copy the uncompressed data over to the unpack_buffer
|
||||
memcpy(unpack_buffer, buffer, sz);
|
||||
std::memcpy(unpack_buffer, buffer, sz);
|
||||
}
|
||||
|
||||
// if the blob has zlib-compressed data
|
||||
|
|
@ -229,6 +230,12 @@ int main(int argc, char *argv[]) {
|
|||
debug(" contains zlib-compressed data: %u bytes", sz);
|
||||
debug(" uncompressed size: %u bytes", blob.raw_size());
|
||||
|
||||
// ensure the raw_size fits into the unpack_buffer, otherwise
|
||||
// zlib would inflate past the end of the fixed-size buffer
|
||||
if (blob.raw_size() < 0 || blob.raw_size() > OSMPBF::max_uncompressed_blob_size) {
|
||||
err(" raw_size is bigger then allowed (%d > %u)", blob.raw_size(), OSMPBF::max_uncompressed_blob_size);
|
||||
}
|
||||
|
||||
// zlib information
|
||||
z_stream z;
|
||||
|
||||
|
|
@ -270,9 +277,6 @@ int main(int argc, char *argv[]) {
|
|||
warn(" contains several data streams");
|
||||
}
|
||||
|
||||
// we have at least one datastream
|
||||
found_data = true;
|
||||
|
||||
// tell about the compressed data
|
||||
debug(" contains lzma-compressed data: %u bytes", blob.lzma_data().size());
|
||||
debug(" uncompressed size: %u bytes", blob.raw_size());
|
||||
|
|
@ -281,6 +285,36 @@ int main(int argc, char *argv[]) {
|
|||
err(" lzma-decompression is not supported");
|
||||
}
|
||||
|
||||
// if the blob has lz4-compressed data
|
||||
if (blob.has_lz4_data()) {
|
||||
// issue a warning if there is more than one data steam, a blob may only contain one data stream
|
||||
if (found_data) {
|
||||
warn(" contains several data streams");
|
||||
}
|
||||
|
||||
// tell about the compressed data
|
||||
debug(" contains lz4-compressed data: %u bytes", blob.lz4_data().size());
|
||||
debug(" uncompressed size: %u bytes", blob.raw_size());
|
||||
|
||||
// issue a warning, lz4 compression is not yet supported
|
||||
err(" lz4-decompression is not supported");
|
||||
}
|
||||
|
||||
// if the blob has zstd-compressed data
|
||||
if (blob.has_zstd_data()) {
|
||||
// issue a warning if there is more than one data steam, a blob may only contain one data stream
|
||||
if (found_data) {
|
||||
warn(" contains several data streams");
|
||||
}
|
||||
|
||||
// tell about the compressed data
|
||||
debug(" contains zstd-compressed data: %u bytes", blob.zstd_data().size());
|
||||
debug(" uncompressed size: %u bytes", blob.raw_size());
|
||||
|
||||
// issue a warning, zstd compression is not yet supported
|
||||
err(" zstd-decompression is not supported");
|
||||
}
|
||||
|
||||
// check we have at least one data-stream
|
||||
if (!found_data) {
|
||||
err(" does not contain any known data stream");
|
||||
|
|
@ -291,28 +325,31 @@ int main(int argc, char *argv[]) {
|
|||
// tell about the OSMHeader blob
|
||||
info(" OSMHeader");
|
||||
|
||||
// pbf struct of an OSM HeaderBlock
|
||||
OSMPBF::HeaderBlock headerblock;
|
||||
|
||||
// parse the HeaderBlock from the blob
|
||||
if (!headerblock.ParseFromArray(unpack_buffer, sz)) {
|
||||
if (!headerblock.ParseFromArray(unpack_buffer, static_cast<int>(sz))) {
|
||||
err("unable to parse header block");
|
||||
}
|
||||
|
||||
// tell about the bbox
|
||||
if (headerblock.has_bbox()) {
|
||||
OSMPBF::HeaderBBox bbox = headerblock.bbox();
|
||||
OSMPBF::HeaderBBox const& bbox = headerblock.bbox();
|
||||
debug(" bbox: %.7f,%.7f,%.7f,%.7f",
|
||||
(double)bbox.left() / OSMPBF::lonlat_resolution,
|
||||
(double)bbox.bottom() / OSMPBF::lonlat_resolution,
|
||||
(double)bbox.right() / OSMPBF::lonlat_resolution,
|
||||
(double)bbox.top() / OSMPBF::lonlat_resolution);
|
||||
static_cast<double>(bbox.left()) / OSMPBF::lonlat_resolution,
|
||||
static_cast<double>(bbox.bottom()) / OSMPBF::lonlat_resolution,
|
||||
static_cast<double>(bbox.right()) / OSMPBF::lonlat_resolution,
|
||||
static_cast<double>(bbox.top()) / OSMPBF::lonlat_resolution);
|
||||
}
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
|
|
@ -329,8 +366,11 @@ int main(int argc, char *argv[]) {
|
|||
// tell about the OSMData blob
|
||||
info(" OSMData");
|
||||
|
||||
// pbf struct of an OSM PrimitiveBlock
|
||||
OSMPBF::PrimitiveBlock primblock;
|
||||
|
||||
// parse the PrimitiveBlock from the blob
|
||||
if (!primblock.ParseFromArray(unpack_buffer, sz)) {
|
||||
if (!primblock.ParseFromArray(unpack_buffer, static_cast<int>(sz))) {
|
||||
err("unable to parse primitive block");
|
||||
}
|
||||
|
||||
|
|
@ -347,11 +387,11 @@ 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);
|
||||
OSMPBF::PrimitiveGroup const& pg = primblock.primitivegroup(i);
|
||||
|
||||
bool found_items=false;
|
||||
bool found_items = false;
|
||||
|
||||
// tell about nodes
|
||||
if (pg.nodes_size() > 0) {
|
||||
|
|
@ -406,7 +446,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// close the file pointer
|
||||
fclose(fp);
|
||||
std::fclose(fp);
|
||||
|
||||
// clean up the protobuf lib
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
// this describes the high-level OSM objects
|
||||
#include <osmpbf/osmformat.pb.h> // IWYU pragma: export
|
||||
|
||||
#define OSMPBF_VERSION "1.3.3"
|
||||
#define OSMPBF_VERSION "1.7.0"
|
||||
|
||||
namespace OSMPBF {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
protobuf_generate_cpp(CPPS HS fileformat.proto osmformat.proto)
|
||||
|
||||
add_library(osmpbf STATIC ${CPPS})
|
||||
target_compile_features(osmpbf PUBLIC cxx_std_11)
|
||||
target_link_libraries(osmpbf PRIVATE protobuf::libprotobuf)
|
||||
target_include_directories(osmpbf SYSTEM PUBLIC ${Protobuf_INCLUDE_DIRS})
|
||||
install(TARGETS osmpbf ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
add_library(osmpbf_shared SHARED ${CPPS})
|
||||
target_compile_features(osmpbf_shared PUBLIC cxx_std_11)
|
||||
target_link_libraries(osmpbf_shared PRIVATE protobuf::libprotobuf)
|
||||
target_include_directories(osmpbf_shared SYSTEM PUBLIC ${Protobuf_INCLUDE_DIRS})
|
||||
set_target_properties(osmpbf_shared PROPERTIES OUTPUT_NAME osmpbf
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
install(TARGETS osmpbf_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/include/osmpbf/osmpbf.h
|
||||
${CMAKE_BINARY_DIR}/osmpbf/osmformat.pb.h
|
||||
${CMAKE_BINARY_DIR}/osmpbf/fileformat.pb.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/osmpbf)
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) OpenStreetMap developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "crosby.binary";
|
||||
package OSMPBF;
|
||||
|
||||
//protoc --java_out=../.. fileformat.proto
|
||||
|
||||
|
||||
//
|
||||
// STORAGE LAYER: Storing primitives.
|
||||
//
|
||||
|
||||
message Blob {
|
||||
optional int32 raw_size = 2; // When compressed, the uncompressed size
|
||||
|
||||
oneof data {
|
||||
bytes raw = 1; // No compression
|
||||
|
||||
// Possible compressed versions of the data.
|
||||
bytes zlib_data = 3;
|
||||
|
||||
// For LZMA compressed data (optional)
|
||||
bytes lzma_data = 4;
|
||||
|
||||
// Formerly used for bzip2 compressed data. Deprecated in 2010.
|
||||
bytes OBSOLETE_bzip2_data = 5 [deprecated=true]; // Don't reuse this tag number.
|
||||
|
||||
// For LZ4 compressed data (optional)
|
||||
bytes lz4_data = 6;
|
||||
|
||||
// For ZSTD compressed data (optional)
|
||||
bytes zstd_data = 7;
|
||||
}
|
||||
}
|
||||
|
||||
/* A file contains an sequence of fileblock headers, each prefixed by
|
||||
their length in network byte order, followed by a data block
|
||||
containing the actual data. Types starting with a "_" are reserved.
|
||||
*/
|
||||
|
||||
message BlobHeader {
|
||||
required string type = 1;
|
||||
optional bytes indexdata = 2;
|
||||
required int32 datasize = 3;
|
||||
}
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "crosby.binary";
|
||||
package OSMPBF;
|
||||
|
||||
/* OSM Binary file format
|
||||
|
||||
This is the master schema file of the OSM binary file format. This
|
||||
file is designed to support limited random-access and future
|
||||
extendability.
|
||||
|
||||
A binary OSM file consists of a sequence of FileBlocks (please see
|
||||
fileformat.proto). The first fileblock contains a serialized instance
|
||||
of HeaderBlock, followed by a sequence of PrimitiveBlock blocks that
|
||||
contain the primitives.
|
||||
|
||||
Each primitiveblock is designed to be independently parsable. It
|
||||
contains a string table storing all strings in that block (keys and
|
||||
values in tags, roles in relations, usernames, etc.) as well as
|
||||
metadata containing the precision of coordinates or timestamps in that
|
||||
block.
|
||||
|
||||
A primitiveblock contains a sequence of primitive groups, each
|
||||
containing primitives of the same type (nodes, densenodes, ways,
|
||||
relations). Coordinates are stored in signed 64-bit integers. Lat&lon
|
||||
are measured in units <granularity> nanodegrees. The default of
|
||||
granularity of 100 nanodegrees corresponds to about 1cm on the ground,
|
||||
and a full lat or lon fits into 32 bits.
|
||||
|
||||
Converting an integer to a latitude or longitude uses the formula:
|
||||
$OUT = IN * granularity / 10**9$. Many encoding schemes use delta
|
||||
coding when representing nodes and relations.
|
||||
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Contains the file header. */
|
||||
|
||||
message HeaderBlock {
|
||||
optional HeaderBBox bbox = 1;
|
||||
|
||||
/* Additional tags to aid in parsing this dataset */
|
||||
repeated string required_features = 4;
|
||||
repeated string optional_features = 5;
|
||||
|
||||
optional string writingprogram = 16;
|
||||
optional string source = 17; // From the bbox field.
|
||||
|
||||
/* Tags that allow continuing an Osmosis replication */
|
||||
|
||||
// Replication timestamp, expressed in seconds since the epoch,
|
||||
// otherwise the same value as in the "timestamp=..." field
|
||||
// in the state.txt file used by Osmosis.
|
||||
optional int64 osmosis_replication_timestamp = 32;
|
||||
|
||||
// Replication sequence number (sequenceNumber in state.txt).
|
||||
optional int64 osmosis_replication_sequence_number = 33;
|
||||
|
||||
// Replication base URL (from Osmosis' configuration.txt file).
|
||||
optional string osmosis_replication_base_url = 34;
|
||||
}
|
||||
|
||||
|
||||
/** The bounding box field in the OSM header. BBOX, as used in the OSM
|
||||
header. Units are always in nanodegrees -- they do not obey
|
||||
granularity rules. */
|
||||
|
||||
message HeaderBBox {
|
||||
required sint64 left = 1;
|
||||
required sint64 right = 2;
|
||||
required sint64 top = 3;
|
||||
required sint64 bottom = 4;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
message PrimitiveBlock {
|
||||
required StringTable stringtable = 1;
|
||||
repeated PrimitiveGroup primitivegroup = 2;
|
||||
|
||||
// Granularity, units of nanodegrees, used to store coordinates in this block.
|
||||
optional int32 granularity = 17 [default=100];
|
||||
|
||||
// Offset value between the output coordinates and the granularity grid in units of nanodegrees.
|
||||
optional int64 lat_offset = 19 [default=0];
|
||||
optional int64 lon_offset = 20 [default=0];
|
||||
|
||||
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
|
||||
optional int32 date_granularity = 18 [default=1000];
|
||||
}
|
||||
|
||||
// Group of OSMPrimitives. All primitives in a group must be the same type.
|
||||
message PrimitiveGroup {
|
||||
repeated Node nodes = 1;
|
||||
optional DenseNodes dense = 2;
|
||||
repeated Way ways = 3;
|
||||
repeated Relation relations = 4;
|
||||
repeated ChangeSet changesets = 5;
|
||||
}
|
||||
|
||||
|
||||
/** String table, contains the common strings in each block.
|
||||
|
||||
Note that we reserve index '0' as a delimiter, so the entry at that
|
||||
index in the table is ALWAYS blank and unused.
|
||||
|
||||
*/
|
||||
message StringTable {
|
||||
repeated bytes s = 1;
|
||||
}
|
||||
|
||||
/* Optional metadata that may be included into each primitive. */
|
||||
message Info {
|
||||
optional int32 version = 1 [default = -1];
|
||||
optional int64 timestamp = 2;
|
||||
optional int64 changeset = 3;
|
||||
optional int32 uid = 4;
|
||||
optional uint32 user_sid = 5; // String IDs
|
||||
|
||||
// The visible flag is used to store history information. It indicates that
|
||||
// the current object version has been created by a delete operation on the
|
||||
// OSM API.
|
||||
// When a writer sets this flag, it MUST add a required_features tag with
|
||||
// value "HistoricalInformation" to the HeaderBlock.
|
||||
// If this flag is not available for some object it MUST be assumed to be
|
||||
// true if the file has the required_features tag "HistoricalInformation"
|
||||
// set.
|
||||
optional bool visible = 6;
|
||||
}
|
||||
|
||||
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
|
||||
message DenseInfo {
|
||||
repeated int32 version = 1 [packed = true];
|
||||
repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
|
||||
repeated sint64 changeset = 3 [packed = true]; // DELTA coded
|
||||
repeated sint32 uid = 4 [packed = true]; // DELTA coded
|
||||
repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded
|
||||
|
||||
// The visible flag is used to store history information. It indicates that
|
||||
// the current object version has been created by a delete operation on the
|
||||
// OSM API.
|
||||
// When a writer sets this flag, it MUST add a required_features tag with
|
||||
// value "HistoricalInformation" to the HeaderBlock.
|
||||
// If this flag is not available for some object it MUST be assumed to be
|
||||
// true if the file has the required_features tag "HistoricalInformation"
|
||||
// set.
|
||||
repeated bool visible = 6 [packed = true];
|
||||
}
|
||||
|
||||
|
||||
// This is kept for backwards compatibility but not used anywhere.
|
||||
message ChangeSet {
|
||||
required int64 id = 1;
|
||||
}
|
||||
|
||||
|
||||
message Node {
|
||||
required sint64 id = 1;
|
||||
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true]; // String IDs.
|
||||
repeated uint32 vals = 3 [packed = true]; // String IDs.
|
||||
|
||||
optional Info info = 4; // May be omitted in omitmeta
|
||||
|
||||
required sint64 lat = 8;
|
||||
required sint64 lon = 9;
|
||||
}
|
||||
|
||||
/* Used to densly represent a sequence of nodes that do not have any tags.
|
||||
|
||||
We represent these nodes columnwise as five columns: ID's, lats, and
|
||||
lons, all delta coded. When metadata is not omitted,
|
||||
|
||||
We encode keys & vals for all nodes as a single array of integers
|
||||
containing key-stringid and val-stringid, using a stringid of 0 as a
|
||||
delimiter between nodes.
|
||||
|
||||
( (<keyid> <valid>)* '0' )*
|
||||
*/
|
||||
|
||||
message DenseNodes {
|
||||
repeated sint64 id = 1 [packed = true]; // DELTA coded
|
||||
|
||||
optional DenseInfo denseinfo = 5;
|
||||
|
||||
repeated sint64 lat = 8 [packed = true]; // DELTA coded
|
||||
repeated sint64 lon = 9 [packed = true]; // DELTA coded
|
||||
|
||||
// Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
|
||||
repeated int32 keys_vals = 10 [packed = true];
|
||||
}
|
||||
|
||||
|
||||
message Way {
|
||||
required int64 id = 1;
|
||||
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true];
|
||||
repeated uint32 vals = 3 [packed = true];
|
||||
|
||||
optional Info info = 4;
|
||||
|
||||
repeated sint64 refs = 8 [packed = true]; // DELTA coded
|
||||
|
||||
// The following two fields are optional. They are only used in a special
|
||||
// format where node locations are also added to the ways. This makes the
|
||||
// files larger, but allows creating way geometries directly.
|
||||
//
|
||||
// If this is used, you MUST set the optional_features tag "LocationsOnWays"
|
||||
// and the number of values in refs, lat, and lon MUST be the same.
|
||||
repeated sint64 lat = 9 [packed = true]; // DELTA coded, optional
|
||||
repeated sint64 lon = 10 [packed = true]; // DELTA coded, optional
|
||||
}
|
||||
|
||||
message Relation {
|
||||
enum MemberType {
|
||||
NODE = 0;
|
||||
WAY = 1;
|
||||
RELATION = 2;
|
||||
}
|
||||
|
||||
required int64 id = 1;
|
||||
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true];
|
||||
repeated uint32 vals = 3 [packed = true];
|
||||
|
||||
optional Info info = 4;
|
||||
|
||||
// Parallel arrays
|
||||
repeated int32 roles_sid = 8 [packed = true]; // This should have been defined as uint32 for consistency, but it is now too late to change it
|
||||
repeated sint64 memids = 9 [packed = true]; // DELTA encoded
|
||||
repeated MemberType types = 10 [packed = true];
|
||||
}
|
||||
61
pom.xml
61
pom.xml
|
|
@ -6,14 +6,14 @@
|
|||
<groupId>org.openstreetmap.pbf</groupId>
|
||||
<artifactId>osmpbf</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.4.0</version>
|
||||
<version>1.7.0</version>
|
||||
<name>OSM-Binary</name>
|
||||
<description>Library for the OpenStreetMap PBF format</description>
|
||||
<url>https://github.com/openstreetmap/OSM-binary</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Lesser Public License (LGPL) version 3.0</name>
|
||||
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
|
||||
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
|
@ -31,16 +31,31 @@
|
|||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<protobuf.version>4.33.2</protobuf.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src.java</sourceDirectory>
|
||||
<outputDirectory>${basedir}/build</outputDirectory>
|
||||
<extensions>
|
||||
<!-- makes build variables like os.detected.classifier available.
|
||||
use to select the correct protoc instance for the OS.
|
||||
see protobuf-maven-plugin below -->
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<sourceDirectory>${basedir}/src.java</sourceDirectory>
|
||||
<testSourceDirectory>${basedir}/test.java</testSourceDirectory>
|
||||
|
||||
<resources><resource><directory>${basedir}/resources</directory></resource></resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
|
|
@ -55,7 +70,7 @@
|
|||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
<version>0.6.1</version>
|
||||
<configuration>
|
||||
<protocExecutable>protoc</protocExecutable>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
@ -66,7 +81,7 @@
|
|||
</goals>
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<protoSourceRoot>${basedir}/src</protoSourceRoot>
|
||||
<protoSourceRoot>${basedir}/osmpbf</protoSourceRoot>
|
||||
<includes>
|
||||
<param>**/*.proto</param>
|
||||
</includes>
|
||||
|
|
@ -118,16 +133,19 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
<autoPublish>true</autoPublish>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>dtrott</id>
|
||||
<url>http://maven.davidtrott.com/repository</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
@ -139,19 +157,8 @@
|
|||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<version>${protobuf.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
Name: osmpbf
|
||||
Version: 1.3.3
|
||||
Release: 2%{?dist}
|
||||
Summary: C version of the PBF library code
|
||||
License: LGPL-3+
|
||||
URL: https://github.com/scrosby/OSM-binary
|
||||
Source0: OSM-binary-%{version}.tar.bz2
|
||||
BuildRequires: protobuf-devel, protobuf-lite-devel
|
||||
BuildRequires: gcc, gcc-c++
|
||||
|
||||
%description
|
||||
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.
|
||||
|
||||
For more information see http://wiki.openstreetmap.org/wiki/PBF_Format
|
||||
|
||||
%prep
|
||||
%setup -q -n OSM-binary-%{version}
|
||||
|
||||
%build
|
||||
%{__make} -C src %{?jobs:-j%jobs}
|
||||
%{__make} -C tools %{?jobs:-j%jobs}
|
||||
|
||||
%install
|
||||
%{__make} -C src DESTDIR=%{buildroot} PREFIX=%{_prefix} LIBDIR=%{_libdir} install
|
||||
%{__make} -C tools DESTDIR=%{buildroot} PREFIX=%{_prefix} install
|
||||
install -m 644 tools/osmpbf-outline.1 $RPM_BUILD_ROOT%{_mandir}/man1/
|
||||
|
||||
%files
|
||||
%defattr(-, root, root, -)
|
||||
%doc COPYING.osmpbf README ReleaseNotes.txt
|
||||
%dir %{_includedir}/osmpbf
|
||||
%{_includedir}/osmpbf/*.h
|
||||
%{_bindir}/osmpbf-outline
|
||||
%{_mandir}/man1/osmpbf-outline.1*
|
||||
%{_libdir}/libosmpbf.a
|
||||
|
||||
%changelog
|
||||
* Wed Mar 19 2014 <kay.diam@gmail.com> - 1.3.3-2
|
||||
- Bump version
|
||||
- Updated spec file to use normal make
|
||||
|
||||
* Mon Sep 23 2013 <kay.diam@gmail.com> - 1.3.1-1
|
||||
- Initial release
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -18,27 +18,28 @@
|
|||
package crosby.binary;
|
||||
|
||||
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import crosby.binary.Osmformat;
|
||||
import crosby.binary.file.BlockReaderAdapter;
|
||||
import crosby.binary.file.FileBlock;
|
||||
import crosby.binary.file.FileBlockPosition;
|
||||
import crosby.binary.file.FileFormatException;
|
||||
|
||||
public abstract class BinaryParser implements BlockReaderAdapter {
|
||||
protected int granularity;
|
||||
private long lat_offset;
|
||||
private long lon_offset;
|
||||
protected int date_granularity;
|
||||
private String strings[];
|
||||
private String[] strings;
|
||||
|
||||
/** Take a Info protocol buffer containing a date and convert it into a java Date object */
|
||||
protected Date getDate(Osmformat.Info info) {
|
||||
if (info.hasTimestamp()) {
|
||||
return new Date(date_granularity * (long) info.getTimestamp());
|
||||
return new Date(date_granularity * info.getTimestamp());
|
||||
} else
|
||||
return NODATE;
|
||||
}
|
||||
|
|
@ -47,8 +48,8 @@ public abstract class BinaryParser implements BlockReaderAdapter {
|
|||
/** Get a string based on the index used.
|
||||
*
|
||||
* Index 0 is reserved to use as a delimiter, therefore, index 1 corresponds to the first string in the table
|
||||
* @param id
|
||||
* @return
|
||||
* @param id the index
|
||||
* @return the string at the given index
|
||||
*/
|
||||
protected String getStringById(int id) {
|
||||
return strings[id];
|
||||
|
|
@ -56,7 +57,6 @@ public abstract class BinaryParser implements BlockReaderAdapter {
|
|||
|
||||
@Override
|
||||
public void handleBlock(FileBlock message) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
if (message.getType().equals("OSMHeader")) {
|
||||
Osmformat.HeaderBlock headerblock = Osmformat.HeaderBlock
|
||||
|
|
@ -68,9 +68,7 @@ public abstract class BinaryParser implements BlockReaderAdapter {
|
|||
parse(primblock);
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new Error("ParseError"); // TODO
|
||||
throw new UncheckedIOException(new FileFormatException(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@
|
|||
|
||||
package crosby.binary;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.Flushable;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -35,7 +38,7 @@ import crosby.binary.file.FileBlock;
|
|||
* ordered to process their data at the appropriate time.
|
||||
* */
|
||||
|
||||
public class BinarySerializer {
|
||||
public class BinarySerializer implements Closeable, Flushable {
|
||||
|
||||
/**
|
||||
* Interface used to write a group of primitives. One of these for each
|
||||
|
|
@ -67,11 +70,11 @@ public class BinarySerializer {
|
|||
this.batch_limit = batch_limit;
|
||||
}
|
||||
|
||||
// Paramaters affecting the output size.
|
||||
// Parameters affecting the output size.
|
||||
protected final int MIN_DENSE = 10;
|
||||
protected int batch_limit = 4000;
|
||||
|
||||
// Parmaters affecting the output.
|
||||
// Parameters affecting the output.
|
||||
|
||||
protected int granularity = 100;
|
||||
protected int date_granularity = 1000;
|
||||
|
|
@ -80,8 +83,8 @@ public class BinarySerializer {
|
|||
/** How many primitives have been seen in this batch */
|
||||
protected int batch_size = 0;
|
||||
protected int total_entities = 0;
|
||||
private StringTable stringtable = new StringTable();
|
||||
protected List<PrimGroupWriterInterface> groups = new ArrayList<PrimGroupWriterInterface>();
|
||||
private final StringTable stringtable = new StringTable();
|
||||
protected List<PrimGroupWriterInterface> groups = new ArrayList<>();
|
||||
protected BlockOutputStream output;
|
||||
|
||||
public BinarySerializer(BlockOutputStream output) {
|
||||
|
|
@ -92,11 +95,13 @@ public class BinarySerializer {
|
|||
return stringtable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
processBatch();
|
||||
output.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
flush();
|
||||
output.close();
|
||||
|
|
@ -139,9 +144,7 @@ public class BinarySerializer {
|
|||
output.write(FileBlock.newInstance("OSMData", message
|
||||
.toByteString(), null));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new Error(e);
|
||||
throw new UncheckedIOException(e);
|
||||
} finally {
|
||||
batch_size = 0;
|
||||
groups.clear();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.HashMap;
|
|||
import com.google.protobuf.ByteString;
|
||||
|
||||
/**
|
||||
* Class for mapping a set of strings to integers, giving frequently occuring
|
||||
* Class for mapping a set of strings to integers, giving frequently occurring
|
||||
* strings small integers.
|
||||
*/
|
||||
public class StringTable {
|
||||
|
|
@ -34,34 +34,28 @@ public class StringTable {
|
|||
|
||||
private HashMap<String, Integer> counts;
|
||||
private HashMap<String, Integer> stringmap;
|
||||
private String set[];
|
||||
private String[] set;
|
||||
|
||||
/**
|
||||
* Increments the count of the given string
|
||||
* @param s the string
|
||||
*/
|
||||
public void incr(String s) {
|
||||
if (counts.containsKey(s)) {
|
||||
counts.put(s, new Integer(counts.get(s).intValue() + 1));
|
||||
} else {
|
||||
counts.put(s, new Integer(1));
|
||||
}
|
||||
counts.merge(s, 1, Integer::sum);
|
||||
}
|
||||
|
||||
/** After the stringtable has been built, return the offset of a string in it.
|
||||
*
|
||||
* Note, value '0' is reserved for use as a delimiter and will not be returned.
|
||||
* @param s
|
||||
* @return
|
||||
* @param s the string to lookup
|
||||
* @return the offset of the string
|
||||
*/
|
||||
public int getIndex(String s) {
|
||||
return stringmap.get(s).intValue();
|
||||
return stringmap.get(s);
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
Comparator<String> comparator = new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(final String s1, String s2) {
|
||||
int diff = counts.get(s2) - counts.get(s1);
|
||||
return diff;
|
||||
}
|
||||
};
|
||||
Comparator<String> comparator = (s1, s2) -> counts.get(s2) - counts.get(s1);
|
||||
|
||||
/* Sort the stringtable */
|
||||
|
||||
|
|
@ -88,7 +82,7 @@ public class StringTable {
|
|||
So, when I decide on the master stringtable to use, I put the 127 most frequently occurring
|
||||
strings into A (accomplishing goal 1), and sort them by frequency (to accomplish goal 2), but
|
||||
for B and C, which contain the less progressively less frequently encountered strings, I sort
|
||||
them lexiconographically, to maximize goal 3 and ignoring goal 2.
|
||||
them lexicographically, to maximize goal 3 and ignoring goal 2.
|
||||
|
||||
Goal 1 is the most important. Goal 2 helped enough to be worth it, and goal 3 was pretty minor,
|
||||
but all should be re-benchmarked.
|
||||
|
|
@ -103,7 +97,7 @@ public class StringTable {
|
|||
// Sort based on the frequency.
|
||||
Arrays.sort(set, comparator);
|
||||
// Each group of keys that serializes to the same number of bytes is
|
||||
// sorted lexiconographically.
|
||||
// sorted lexicographically.
|
||||
// to maximize deflate compression.
|
||||
|
||||
// Don't sort the first array. There's not likely to be much benefit, and we want frequent values to be small.
|
||||
|
|
@ -114,15 +108,15 @@ public class StringTable {
|
|||
Arrays.sort(set, Math.min(1 << 14, set.length-1), Math.min(1 << 21,
|
||||
set.length-1), comparator);
|
||||
}
|
||||
stringmap = new HashMap<String, Integer>(2 * set.length);
|
||||
stringmap = new HashMap<>(2 * set.length);
|
||||
for (int i = 0; i < set.length; i++) {
|
||||
stringmap.put(set[i], new Integer(i+1)); // Index 0 is reserved for use as a delimiter.
|
||||
stringmap.put(set[i], i + 1); // Index 0 is reserved for use as a delimiter.
|
||||
}
|
||||
counts = null;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
counts = new HashMap<String, Integer>(100);
|
||||
counts = new HashMap<>(100);
|
||||
stringmap = null;
|
||||
set = null;
|
||||
}
|
||||
|
|
@ -131,8 +125,9 @@ public class StringTable {
|
|||
Osmformat.StringTable.Builder builder = Osmformat.StringTable
|
||||
.newBuilder();
|
||||
builder.addS(ByteString.copyFromUtf8("")); // Add a unused string at offset 0 which is used as a delimiter.
|
||||
for (int i = 0; i < set.length; i++)
|
||||
builder.addS(ByteString.copyFromUtf8(set[i]));
|
||||
for (String s : set) {
|
||||
builder.addS(ByteString.copyFromUtf8(s));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package crosby.binary.file;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class BlockInputStream {
|
||||
public class BlockInputStream implements Closeable {
|
||||
// TODO: Should be seekable input stream!
|
||||
public BlockInputStream(InputStream input, BlockReaderAdapter adaptor) {
|
||||
this.input = input;
|
||||
|
|
@ -38,6 +39,7 @@ public class BlockInputStream {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
input.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,15 @@
|
|||
|
||||
package crosby.binary.file;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.Flushable;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
enum CompressFlags {
|
||||
NONE, DEFLATE
|
||||
}
|
||||
|
||||
public class BlockOutputStream {
|
||||
public class BlockOutputStream implements Closeable, Flushable {
|
||||
|
||||
public BlockOutputStream(OutputStream output) {
|
||||
this.outwrite = new DataOutputStream(output);
|
||||
|
|
@ -44,7 +42,7 @@ public class BlockOutputStream {
|
|||
else if (s.equals("deflate"))
|
||||
compression = CompressFlags.DEFLATE;
|
||||
else
|
||||
throw new Error("Unknown compression type: " + s);
|
||||
throw new IllegalArgumentException("Unknown compression type: " + s);
|
||||
}
|
||||
|
||||
/** Write a block with the stream's default compression flag */
|
||||
|
|
@ -59,16 +57,18 @@ public class BlockOutputStream {
|
|||
writtenblocks.add(ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
outwrite.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
outwrite.flush();
|
||||
outwrite.close();
|
||||
}
|
||||
|
||||
OutputStream outwrite;
|
||||
List<FileBlockPosition> writtenblocks = new ArrayList<FileBlockPosition>();
|
||||
List<FileBlockPosition> writtenblocks = new ArrayList<>();
|
||||
CompressFlags compression;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package crosby.binary.file;
|
||||
|
||||
public enum CompressFlags {
|
||||
NONE, DEFLATE
|
||||
}
|
||||
|
|
@ -18,10 +18,12 @@
|
|||
package crosby.binary.file;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
|
|
@ -48,13 +50,13 @@ public class FileBlock extends FileBlockBase {
|
|||
if (blob != null && blob.size() > MAX_BODY_SIZE/2) {
|
||||
System.err.println("Warning: Fileblock has body size too large and may be considered corrupt");
|
||||
if (blob != null && blob.size() > MAX_BODY_SIZE-1024*1024) {
|
||||
throw new Error("This file has too many entities in a block. Parsers will reject it.");
|
||||
throw new IllegalArgumentException("This file has too many entities in a block. Parsers will reject it.");
|
||||
}
|
||||
}
|
||||
if (indexdata != null && indexdata.size() > MAX_HEADER_SIZE/2) {
|
||||
System.err.println("Warning: Fileblock has indexdata too large and may be considered corrupt");
|
||||
if (indexdata != null && indexdata.size() > MAX_HEADER_SIZE-512) {
|
||||
throw new Error("This file header is too large. Parsers will reject it.");
|
||||
throw new IllegalArgumentException("This file header is too large. Parsers will reject it.");
|
||||
}
|
||||
}
|
||||
return new FileBlock(type, blob, indexdata);
|
||||
|
|
@ -65,7 +67,7 @@ public class FileBlock extends FileBlockBase {
|
|||
Deflater deflater = new Deflater();
|
||||
deflater.setInput(data.toByteArray());
|
||||
deflater.finish();
|
||||
byte out[] = new byte[size];
|
||||
byte[] out = new byte[size];
|
||||
deflater.deflate(out);
|
||||
|
||||
if (!deflater.finished()) {
|
||||
|
|
@ -77,7 +79,7 @@ public class FileBlock extends FileBlockBase {
|
|||
deflater.deflate(out, deflater.getTotalOut(), out.length
|
||||
- deflater.getTotalOut());
|
||||
if (!deflater.finished()) {
|
||||
throw new Error("Internal error in compressor");
|
||||
throw new UncheckedIOException(new EOFException());
|
||||
}
|
||||
}
|
||||
ByteString compressed = ByteString.copyFrom(out, 0, deflater
|
||||
|
|
@ -103,7 +105,7 @@ public class FileBlock extends FileBlockBase {
|
|||
if (flags == CompressFlags.DEFLATE)
|
||||
deflateInto(blobbuilder);
|
||||
else
|
||||
throw new Error("Compression flag not understood");
|
||||
throw new IllegalArgumentException("Compression flag not understood");
|
||||
}
|
||||
Fileformat.Blob blob = blobbuilder.build();
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class FileBlockHead extends FileBlockReference {
|
|||
throw new FileFormatException("Unexpectedly long header "+MAX_HEADER_SIZE+ " bytes. Possibly corrupt file.");
|
||||
}
|
||||
|
||||
byte buf[] = new byte[headersize];
|
||||
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
|
||||
|
|
@ -90,7 +90,7 @@ public class FileBlockHead extends FileBlockReference {
|
|||
*/
|
||||
FileBlock readContents(InputStream input) throws IOException {
|
||||
DataInputStream datinput = new DataInputStream(input);
|
||||
byte buf[] = new byte[getDatasize()];
|
||||
byte[] buf = new byte[getDatasize()];
|
||||
datinput.readFully(buf);
|
||||
return parseData(buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.io.DataInputStream;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
|
|
@ -43,21 +44,20 @@ public class FileBlockPosition extends FileBlockBase {
|
|||
}
|
||||
|
||||
/** Parse out and decompress the data part of a fileblock helper function. */
|
||||
FileBlock parseData(byte buf[]) throws InvalidProtocolBufferException {
|
||||
FileBlock parseData(byte[] buf) throws InvalidProtocolBufferException {
|
||||
FileBlock out = FileBlock.newInstance(type, null, indexdata);
|
||||
Fileformat.Blob blob = Fileformat.Blob.parseFrom(buf);
|
||||
if (blob.hasRaw()) {
|
||||
out.data = blob.getRaw();
|
||||
} else if (blob.hasZlibData()) {
|
||||
byte buf2[] = new byte[blob.getRawSize()];
|
||||
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 Error(e);
|
||||
throw new UncheckedIOException(new FileFormatException(e));
|
||||
}
|
||||
assert (decompresser.finished());
|
||||
decompresser.end();
|
||||
|
|
@ -85,11 +85,11 @@ public class FileBlockPosition extends FileBlockBase {
|
|||
public FileBlock read(InputStream input) throws IOException {
|
||||
if (input instanceof FileInputStream) {
|
||||
((FileInputStream) input).getChannel().position(data_offset);
|
||||
byte buf[] = new byte[getDatasize()];
|
||||
byte[] buf = new byte[getDatasize()];
|
||||
(new DataInputStream(input)).readFully(buf);
|
||||
return parseData(buf);
|
||||
} else {
|
||||
throw new Error("Random access binary reads require seekability");
|
||||
throw new IllegalArgumentException("Random access binary reads require seekability");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,12 +98,12 @@ public class FileBlockPosition extends FileBlockBase {
|
|||
* stored.
|
||||
*/
|
||||
public ByteString serialize() {
|
||||
throw new Error("TODO");
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
}
|
||||
|
||||
/** TODO: Parse a serialized representation of this block reference */
|
||||
static FileBlockPosition parseFrom(ByteString b) {
|
||||
throw new Error("TODO");
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
}
|
||||
|
||||
protected int datasize;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class FileFormatException extends IOException {
|
|||
super(string);
|
||||
}
|
||||
|
||||
public FileFormatException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,243 +0,0 @@
|
|||
/** Copyright (c) 2010 Scott A. Crosby. <scott@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 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/>.
|
||||
|
||||
*/
|
||||
|
||||
package crosby.binary.test;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import crosby.binary.Fileformat.Blob;
|
||||
import crosby.binary.Fileformat.BlobHeader;
|
||||
import crosby.binary.Osmformat.DenseNodes;
|
||||
import crosby.binary.Osmformat.HeaderBlock;
|
||||
import crosby.binary.Osmformat.Info;
|
||||
import crosby.binary.Osmformat.Node;
|
||||
import crosby.binary.Osmformat.PrimitiveBlock;
|
||||
import crosby.binary.Osmformat.PrimitiveBlock.Builder;
|
||||
import crosby.binary.Osmformat.PrimitiveGroup;
|
||||
import crosby.binary.Osmformat.Relation;
|
||||
import crosby.binary.Osmformat.Relation.MemberType;
|
||||
import crosby.binary.Osmformat.StringTable;
|
||||
import crosby.binary.Osmformat.Way;
|
||||
import crosby.binary.file.BlockOutputStream;
|
||||
import crosby.binary.file.FileBlock;
|
||||
|
||||
public class BuildTestFile {
|
||||
BlockOutputStream output;
|
||||
public static final long BILLION = 1000000000L;
|
||||
|
||||
StringTable makeStringTable(String prefix) {
|
||||
return
|
||||
StringTable.newBuilder()
|
||||
.addS(ByteString.copyFromUtf8("")) // Never used.
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset1"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset2"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset3"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset4"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset5"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset6"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset7"))
|
||||
.addS(ByteString.copyFromUtf8(prefix+"Offset8"))
|
||||
.build();
|
||||
}
|
||||
void makeSimpleFileBlock1() throws IOException {
|
||||
PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder();
|
||||
b1.setStringtable(makeStringTable("B1"));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(101).setLat(13*10*1000*1000).setLon(-14*10*1000*1000)
|
||||
.addKeys(1).addVals(2))
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(101).setLat(12345678).setLon(-23456789)) // Should be 1.2345678 degrees lat and -2.3456789 lon.
|
||||
);
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(201)
|
||||
.addRefs(101).addRefs(1).addRefs(-1).addRefs(10).addRefs(-20) // Delta coded. Should be 101, 102, 101, 111, 91.
|
||||
.addKeys(2).addVals(1).addKeys(3).addVals(4))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(-301)
|
||||
.addRefs(211).addRefs(1).addRefs(-1).addRefs(10).addRefs(-300) // Delta coded. Should be 211, 212, 211, 221, -79
|
||||
.addKeys(4).addVals(3).addKeys(5).addVals(6))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(401).addRefs(211).addRefs(1))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(501))
|
||||
);
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addRelations(Relation.newBuilder()
|
||||
.setId(601)
|
||||
.addTypes(MemberType.NODE).addMemids(50).addRolesSid(2)
|
||||
.addTypes(MemberType.NODE).addMemids(3).addRolesSid(3)
|
||||
.addTypes(MemberType.WAY).addMemids(3).addRolesSid(4)
|
||||
.addTypes(MemberType.RELATION).addMemids(3).addRolesSid(5))
|
||||
.addRelations(Relation.newBuilder()
|
||||
.setId(701)
|
||||
.addTypes(MemberType.RELATION).addMemids(60).addRolesSid(6)
|
||||
.addTypes(MemberType.RELATION).addMemids(5).addRolesSid(7)
|
||||
.addKeys(1).addVals(2)));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.setDense(DenseNodes.newBuilder()
|
||||
.addId(1001).addId(110).addId(-2000).addId(8889)
|
||||
.addLat(12*10000000).addLat(1500000).addLat(-12*10000000).addLat(-12*10000000)
|
||||
.addLon(-12*10000000).addLon(2500000).addLon(13*10000000).addLon(2*10000000)
|
||||
.addKeysVals(1).addKeysVals(2).addKeysVals(0)
|
||||
.addKeysVals(0)
|
||||
.addKeysVals(2).addKeysVals(3).addKeysVals(4).addKeysVals(5).addKeysVals(0)
|
||||
.addKeysVals(3).addKeysVals(3).addKeysVals(0)
|
||||
));
|
||||
|
||||
output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(),null));
|
||||
|
||||
PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder();
|
||||
b2.setLatOffset(10*BILLION + 109208300)
|
||||
.setLonOffset(20*BILLION + 901802700)
|
||||
.setGranularity(1200);
|
||||
b2.setStringtable(makeStringTable("B2"));
|
||||
|
||||
// Test out granularity stuff.
|
||||
b2.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder().setId(100000).setLat(0).setLon(0))
|
||||
.addNodes(Node.newBuilder().setId(100001).setLat(1000).setLon(2000))
|
||||
.addNodes(Node.newBuilder().setId(100002).setLat(1001).setLon(2001))
|
||||
.addNodes(Node.newBuilder().setId(100003).setLat(1002).setLon(2002))
|
||||
.addNodes(Node.newBuilder().setId(100004).setLat(1003).setLon(2003))
|
||||
.addNodes(Node.newBuilder().setId(100005).setLat(1004).setLon(2004)));
|
||||
|
||||
|
||||
output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(),null));
|
||||
}
|
||||
|
||||
|
||||
BuildTestFile(String name, String compress) throws IOException {
|
||||
output = new BlockOutputStream(new FileOutputStream(name));
|
||||
output.setCompress(compress);
|
||||
HeaderBlock.Builder b = HeaderBlock.newBuilder();
|
||||
b.addRequiredFeatures("OsmSchema-V0.6").addRequiredFeatures("DenseNodes").setSource("QuickBrownFox");
|
||||
output.write(FileBlock.newInstance("OSMHeader",b.build().toByteString(),null));
|
||||
}
|
||||
|
||||
|
||||
public static void main(String [] args) {
|
||||
try {
|
||||
BuildTestFile out1a = new BuildTestFile("TestFile1-deflate.osm.pbf","deflate");
|
||||
out1a.makeSimpleFileBlock1();
|
||||
out1a.output.close();
|
||||
|
||||
BuildTestFile out1b = new BuildTestFile("TestFile1-none.osm.pbf","none");
|
||||
out1b.makeSimpleFileBlock1();
|
||||
out1b.output.close();
|
||||
|
||||
BuildTestFile out2 = new BuildTestFile("TestFile2-uncom.osm.pbf","deflate");
|
||||
out2.makeGranFileBlock1();
|
||||
out2.output.close();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void makeGranFileBlock1() throws IOException {
|
||||
PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder();
|
||||
b1.setLatOffset(10*BILLION + 109208300)
|
||||
.setLonOffset(20*BILLION + 901802700)
|
||||
.setGranularity(1200)
|
||||
.setDateGranularity(2500);
|
||||
b1.setStringtable(makeStringTable("C1"));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100001)
|
||||
.setLat(1000).setLon(2000)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setTimestamp(1001)
|
||||
.setChangeset(-12)
|
||||
.setUid(21)
|
||||
.setUserSid(6)
|
||||
.build())
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100002)
|
||||
.setLat(1001).setLon(2001)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setVersion(102)
|
||||
.setTimestamp(1002)
|
||||
.setChangeset(12)
|
||||
.setUid(-21)
|
||||
.setUserSid(5)
|
||||
.build())
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100003)
|
||||
.setLat(1003).setLon(2003)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setVersion(103)
|
||||
.setUserSid(4)
|
||||
.build())
|
||||
.build())
|
||||
)
|
||||
|
||||
;
|
||||
|
||||
// The same, but with different granularities.
|
||||
PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder();
|
||||
b2.setLatOffset(12*BILLION + 303)
|
||||
.setLonOffset(22*BILLION + 404)
|
||||
.setGranularity(1401)
|
||||
.setDateGranularity(3003);
|
||||
b2.setStringtable(makeStringTable("C2"));
|
||||
b2.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100001)
|
||||
.addKeys(1).addVals(2)
|
||||
.addKeys(1).addVals(3) // Support multiple vals for a key.
|
||||
.addKeys(3).addVals(4)
|
||||
.setLat(1000).setLon(2000)
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100002)
|
||||
.setLat(1001).setLon(2001)
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100003)
|
||||
.setLat(1003).setLon(2003)
|
||||
.addKeys(5).addVals(6)
|
||||
.build())
|
||||
);
|
||||
output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(),null));
|
||||
output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(),null));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
package crosby.binary.test;
|
||||
|
||||
import crosby.binary.*;
|
||||
import crosby.binary.Osmformat.*;
|
||||
import crosby.binary.file.*;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Demonstrates how to read a file. Reads sample.pbf from the resources folder
|
||||
* and prints details about it to the standard output.
|
||||
*
|
||||
* @author Michael Tandy
|
||||
*/
|
||||
public class ReadFileExample {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
InputStream input = ReadFileExample.class.getResourceAsStream("/sample.pbf");
|
||||
BlockReaderAdapter brad = new TestBinaryParser();
|
||||
new BlockInputStream(input, brad).process();
|
||||
}
|
||||
|
||||
private static class TestBinaryParser extends BinaryParser {
|
||||
|
||||
@Override
|
||||
protected void parseRelations(List<Relation> rels) {
|
||||
if (!rels.isEmpty())
|
||||
System.out.println("Got some relations to parse.");
|
||||
Relation r = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseDense(DenseNodes nodes) {
|
||||
long lastId=0;
|
||||
long lastLat=0;
|
||||
long lastLon=0;
|
||||
|
||||
for (int i=0 ; i<nodes.getIdCount() ; i++) {
|
||||
lastId += nodes.getId(i);
|
||||
lastLat += nodes.getLat(i);
|
||||
lastLon += nodes.getLon(i);
|
||||
System.out.printf("Dense node, ID %d @ %.6f,%.6f\n",
|
||||
lastId,parseLat(lastLat),parseLon(lastLon));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseNodes(List<Node> nodes) {
|
||||
for (Node n : nodes) {
|
||||
System.out.printf("Regular node, ID %d @ %.6f,%.6f\n",
|
||||
n.getId(),parseLat(n.getLat()),parseLon(n.getLon()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseWays(List<Way> ways) {
|
||||
for (Way w : ways) {
|
||||
System.out.println("Way ID " + w.getId());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" Nodes: ");
|
||||
long lastRef = 0;
|
||||
for (Long ref : w.getRefsList()) {
|
||||
lastRef+= ref;
|
||||
sb.append(lastRef).append(" ");
|
||||
}
|
||||
sb.append("\n Key=value pairs: ");
|
||||
for (int i=0 ; i<w.getKeysCount() ; i++) {
|
||||
sb.append(getStringById(w.getKeys(i))).append("=")
|
||||
.append(getStringById(w.getVals(i))).append(" ");
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(HeaderBlock header) {
|
||||
System.out.println("Got header block.");
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
System.out.println("Complete!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
PROTOBUF_GENERATE_CPP(CPPS HS fileformat.proto osmformat.proto)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/O3")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-O3")
|
||||
endif()
|
||||
|
||||
add_library(osmpbf STATIC ${CPPS})
|
||||
|
||||
set_target_properties(osmpbf PROPERTIES LINKER_LANGUAGE CXX LANGUAGE CXX)
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET osmpbf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/src/fileformat.pb.h ${CMAKE_SOURCE_DIR}/include/osmpbf)
|
||||
ADD_CUSTOM_COMMAND(TARGET osmpbf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/src/osmformat.pb.h ${CMAKE_SOURCE_DIR}/include/osmpbf)
|
||||
|
||||
SET(INCLUDE_INSTALL "include/osmpbf")
|
||||
SET(files ${CMAKE_SOURCE_DIR}/include/osmpbf/osmpbf.h ${CMAKE_BINARY_DIR}/src/osmformat.pb.h ${CMAKE_BINARY_DIR}/src/fileformat.pb.h)
|
||||
INSTALL(FILES ${files} DESTINATION ${INCLUDE_INSTALL})
|
||||
install(TARGETS osmpbf LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||
44
src/Makefile
44
src/Makefile
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
# these default settings can be overridden by setting environment variables
|
||||
PREFIX ?= /usr/local
|
||||
LIBDIR ?= $(PREFIX)/lib
|
||||
CXX ?= g++
|
||||
CXXFLAGS ?= -O3
|
||||
AR ?= ar
|
||||
PROTOC ?= protoc
|
||||
SONAME ?= libosmpbf.so.1
|
||||
VERSION ?= 1.3.3
|
||||
|
||||
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 libosmpbf.so ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h
|
||||
|
||||
libosmpbf.a: fileformat.pb.o osmformat.pb.o
|
||||
$(AR) -cr $@ fileformat.pb.o osmformat.pb.o
|
||||
|
||||
libosmpbf.so: fileformat.pb.o osmformat.pb.o
|
||||
$(CXX) -shared -Wl,-soname,$(SONAME) -o $@ fileformat.pb.o osmformat.pb.o
|
||||
|
||||
%.pb.o: %.pb.cc
|
||||
$(CXX) $(CXXFLAGS) -fPIC -c -o $@ $<
|
||||
|
||||
%.pb.cc ../include/osmpbf/%.pb.h: %.proto
|
||||
$(PROTOC) --proto_path=. --cpp_out=. $<
|
||||
cp -v $(subst .proto,.pb.h,$<) ../include/osmpbf/
|
||||
|
||||
install:
|
||||
install -m 755 -d $(DESTDIR)$(LIBDIR)
|
||||
install -m 644 libosmpbf.a $(DESTDIR)$(LIBDIR)
|
||||
install -m 755 libosmpbf.so $(DESTDIR)$(LIBDIR)/libosmpbf.so.$(VERSION)
|
||||
ln -s libosmpbf.so.$(VERSION) $(DESTDIR)$(LIBDIR)/$(SONAME)
|
||||
ln -s libosmpbf.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libosmpbf.so
|
||||
install -m 755 -d $(DESTDIR)$(PREFIX)/include/osmpbf
|
||||
install -m 644 ../include/osmpbf/osmpbf.h $(DESTDIR)$(PREFIX)/include/osmpbf
|
||||
install -m 644 ../include/osmpbf/fileformat.pb.h $(DESTDIR)$(PREFIX)/include/osmpbf
|
||||
install -m 644 ../include/osmpbf/osmformat.pb.h $(DESTDIR)$(PREFIX)/include/osmpbf
|
||||
|
||||
clean:
|
||||
rm -f *.pb.h *.pb.cc *.pb.o libosmpbf.a
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "crosby.binary";
|
||||
package OSMPBF;
|
||||
|
||||
//protoc --java_out=../.. fileformat.proto
|
||||
|
||||
|
||||
//
|
||||
// STORAGE LAYER: Storing primitives.
|
||||
//
|
||||
|
||||
message Blob {
|
||||
optional bytes raw = 1; // No compression
|
||||
optional int32 raw_size = 2; // When compressed, the uncompressed size
|
||||
|
||||
// Possible compressed versions of the data.
|
||||
optional bytes zlib_data = 3;
|
||||
|
||||
// PROPOSED feature for LZMA compressed data. SUPPORT IS NOT REQUIRED.
|
||||
optional bytes lzma_data = 4;
|
||||
|
||||
// Formerly used for bzip2 compressed data. Depreciated in 2010.
|
||||
optional bytes OBSOLETE_bzip2_data = 5 [deprecated=true]; // Don't reuse this tag number.
|
||||
}
|
||||
|
||||
/* A file contains an sequence of fileblock headers, each prefixed by
|
||||
their length in network byte order, followed by a data block
|
||||
containing the actual data. types staring with a "_" are reserved.
|
||||
*/
|
||||
|
||||
message BlobHeader {
|
||||
required string type = 1;
|
||||
optional bytes indexdata = 2;
|
||||
required int32 datasize = 3;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,254 +0,0 @@
|
|||
/** Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "crosby.binary";
|
||||
package OSMPBF;
|
||||
|
||||
/* OSM Binary file format
|
||||
|
||||
This is the master schema file of the OSM binary file format. This
|
||||
file is designed to support limited random-access and future
|
||||
extendability.
|
||||
|
||||
A binary OSM file consists of a sequence of FileBlocks (please see
|
||||
fileformat.proto). The first fileblock contains a serialized instance
|
||||
of HeaderBlock, followed by a sequence of PrimitiveBlock blocks that
|
||||
contain the primitives.
|
||||
|
||||
Each primitiveblock is designed to be independently parsable. It
|
||||
contains a string table storing all strings in that block (keys and
|
||||
values in tags, roles in relations, usernames, etc.) as well as
|
||||
metadata containing the precision of coordinates or timestamps in that
|
||||
block.
|
||||
|
||||
A primitiveblock contains a sequence of primitive groups, each
|
||||
containing primitives of the same type (nodes, densenodes, ways,
|
||||
relations). Coordinates are stored in signed 64-bit integers. Lat&lon
|
||||
are measured in units <granularity> nanodegrees. The default of
|
||||
granularity of 100 nanodegrees corresponds to about 1cm on the ground,
|
||||
and a full lat or lon fits into 32 bits.
|
||||
|
||||
Converting an integer to a lattitude or longitude uses the formula:
|
||||
$OUT = IN * granularity / 10**9$. Many encoding schemes use delta
|
||||
coding when representing nodes and relations.
|
||||
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Contains the file header. */
|
||||
|
||||
message HeaderBlock {
|
||||
optional HeaderBBox bbox = 1;
|
||||
/* Additional tags to aid in parsing this dataset */
|
||||
repeated string required_features = 4;
|
||||
repeated string optional_features = 5;
|
||||
|
||||
optional string writingprogram = 16;
|
||||
optional string source = 17; // From the bbox field.
|
||||
|
||||
/* Tags that allow continuing an Osmosis replication */
|
||||
|
||||
// replication timestamp, expressed in seconds since the epoch,
|
||||
// otherwise the same value as in the "timestamp=..." field
|
||||
// in the state.txt file used by Osmosis
|
||||
optional int64 osmosis_replication_timestamp = 32;
|
||||
|
||||
// replication sequence number (sequenceNumber in state.txt)
|
||||
optional int64 osmosis_replication_sequence_number = 33;
|
||||
|
||||
// replication base URL (from Osmosis' configuration.txt file)
|
||||
optional string osmosis_replication_base_url = 34;
|
||||
}
|
||||
|
||||
|
||||
/** The bounding box field in the OSM header. BBOX, as used in the OSM
|
||||
header. Units are always in nanodegrees -- they do not obey
|
||||
granularity rules. */
|
||||
|
||||
message HeaderBBox {
|
||||
required sint64 left = 1;
|
||||
required sint64 right = 2;
|
||||
required sint64 top = 3;
|
||||
required sint64 bottom = 4;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
message PrimitiveBlock {
|
||||
required StringTable stringtable = 1;
|
||||
repeated PrimitiveGroup primitivegroup = 2;
|
||||
|
||||
// Granularity, units of nanodegrees, used to store coordinates in this block
|
||||
optional int32 granularity = 17 [default=100];
|
||||
// Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees.
|
||||
optional int64 lat_offset = 19 [default=0];
|
||||
optional int64 lon_offset = 20 [default=0];
|
||||
|
||||
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
|
||||
optional int32 date_granularity = 18 [default=1000];
|
||||
|
||||
|
||||
// Proposed extension:
|
||||
//optional BBox bbox = XX;
|
||||
}
|
||||
|
||||
// Group of OSMPrimitives. All primitives in a group must be the same type.
|
||||
message PrimitiveGroup {
|
||||
repeated Node nodes = 1;
|
||||
optional DenseNodes dense = 2;
|
||||
repeated Way ways = 3;
|
||||
repeated Relation relations = 4;
|
||||
repeated ChangeSet changesets = 5;
|
||||
}
|
||||
|
||||
|
||||
/** String table, contains the common strings in each block.
|
||||
|
||||
Note that we reserve index '0' as a delimiter, so the entry at that
|
||||
index in the table is ALWAYS blank and unused.
|
||||
|
||||
*/
|
||||
message StringTable {
|
||||
repeated bytes s = 1;
|
||||
}
|
||||
|
||||
/* Optional metadata that may be included into each primitive. */
|
||||
message Info {
|
||||
optional int32 version = 1 [default = -1];
|
||||
optional int64 timestamp = 2;
|
||||
optional int64 changeset = 3;
|
||||
optional int32 uid = 4;
|
||||
optional uint32 user_sid = 5; // String IDs
|
||||
|
||||
// The visible flag is used to store history information. It indicates that
|
||||
// the current object version has been created by a delete operation on the
|
||||
// OSM API.
|
||||
// When a writer sets this flag, it MUST add a required_features tag with
|
||||
// value "HistoricalInformation" to the HeaderBlock.
|
||||
// If this flag is not available for some object it MUST be assumed to be
|
||||
// true if the file has the required_features tag "HistoricalInformation"
|
||||
// set.
|
||||
optional bool visible = 6;
|
||||
}
|
||||
|
||||
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
|
||||
message DenseInfo {
|
||||
repeated int32 version = 1 [packed = true];
|
||||
repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
|
||||
repeated sint64 changeset = 3 [packed = true]; // DELTA coded
|
||||
repeated sint32 uid = 4 [packed = true]; // DELTA coded
|
||||
repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded
|
||||
|
||||
// The visible flag is used to store history information. It indicates that
|
||||
// the current object version has been created by a delete operation on the
|
||||
// OSM API.
|
||||
// When a writer sets this flag, it MUST add a required_features tag with
|
||||
// value "HistoricalInformation" to the HeaderBlock.
|
||||
// If this flag is not available for some object it MUST be assumed to be
|
||||
// true if the file has the required_features tag "HistoricalInformation"
|
||||
// set.
|
||||
repeated bool visible = 6 [packed = true];
|
||||
}
|
||||
|
||||
|
||||
// THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW.
|
||||
// TODO: REMOVE THIS?
|
||||
message ChangeSet {
|
||||
required int64 id = 1;
|
||||
//
|
||||
// // Parallel arrays.
|
||||
// repeated uint32 keys = 2 [packed = true]; // String IDs.
|
||||
// repeated uint32 vals = 3 [packed = true]; // String IDs.
|
||||
//
|
||||
// optional Info info = 4;
|
||||
|
||||
// optional int64 created_at = 8;
|
||||
// optional int64 closetime_delta = 9;
|
||||
// optional bool open = 10;
|
||||
// optional HeaderBBox bbox = 11;
|
||||
}
|
||||
|
||||
|
||||
message Node {
|
||||
required sint64 id = 1;
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true]; // String IDs.
|
||||
repeated uint32 vals = 3 [packed = true]; // String IDs.
|
||||
|
||||
optional Info info = 4; // May be omitted in omitmeta
|
||||
|
||||
required sint64 lat = 8;
|
||||
required sint64 lon = 9;
|
||||
}
|
||||
|
||||
/* Used to densly represent a sequence of nodes that do not have any tags.
|
||||
|
||||
We represent these nodes columnwise as five columns: ID's, lats, and
|
||||
lons, all delta coded. When metadata is not omitted,
|
||||
|
||||
We encode keys & vals for all nodes as a single array of integers
|
||||
containing key-stringid and val-stringid, using a stringid of 0 as a
|
||||
delimiter between nodes.
|
||||
|
||||
( (<keyid> <valid>)* '0' )*
|
||||
*/
|
||||
|
||||
message DenseNodes {
|
||||
repeated sint64 id = 1 [packed = true]; // DELTA coded
|
||||
|
||||
//repeated Info info = 4;
|
||||
optional DenseInfo denseinfo = 5;
|
||||
|
||||
repeated sint64 lat = 8 [packed = true]; // DELTA coded
|
||||
repeated sint64 lon = 9 [packed = true]; // DELTA coded
|
||||
|
||||
// Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
|
||||
repeated int32 keys_vals = 10 [packed = true];
|
||||
}
|
||||
|
||||
|
||||
message Way {
|
||||
required int64 id = 1;
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true];
|
||||
repeated uint32 vals = 3 [packed = true];
|
||||
|
||||
optional Info info = 4;
|
||||
|
||||
repeated sint64 refs = 8 [packed = true]; // DELTA coded
|
||||
}
|
||||
|
||||
message Relation {
|
||||
enum MemberType {
|
||||
NODE = 0;
|
||||
WAY = 1;
|
||||
RELATION = 2;
|
||||
}
|
||||
required int64 id = 1;
|
||||
|
||||
// Parallel arrays.
|
||||
repeated uint32 keys = 2 [packed = true];
|
||||
repeated uint32 vals = 3 [packed = true];
|
||||
|
||||
optional Info info = 4;
|
||||
|
||||
// Parallel arrays
|
||||
repeated int32 roles_sid = 8 [packed = true]; // This should have been defined as uint32 for consistency, but it is now too late to change it
|
||||
repeated sint64 memids = 9 [packed = true]; // DELTA encoded
|
||||
repeated MemberType types = 10 [packed = true];
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,531 @@
|
|||
package crosby.binary;
|
||||
|
||||
import crosby.binary.Osmformat.*;
|
||||
import crosby.binary.file.BlockInputStream;
|
||||
import crosby.binary.file.BlockReaderAdapter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Demonstrates how to read a file. Reads sample.pbf from the resources folder
|
||||
* and prints details about it to the standard output.
|
||||
*
|
||||
* @author Michael Tandy
|
||||
*/
|
||||
public class ReadFileTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
String expected = ("" +
|
||||
"Got header block.\n" +
|
||||
"Dense node, ID 653970877 @ 51.763603,-0.228757\n" +
|
||||
"Dense node, ID 647105170 @ 51.763591,-0.234465\n" +
|
||||
"Dense node, ID 672663476 @ 51.765749,-0.229070\n" +
|
||||
"Dense node, ID 241806356 @ 51.768945,-0.232662\n" +
|
||||
"Dense node, ID 692945017 @ 51.766185,-0.230069\n" +
|
||||
"Dense node, ID 1709246734 @ 51.766433,-0.230854\n" +
|
||||
"Dense node, ID 175685506 @ 51.765169,-0.229374\n" +
|
||||
"Dense node, ID 647105129 @ 51.769327,-0.218457\n" +
|
||||
"Dense node, ID 647105160 @ 51.768192,-0.231686\n" +
|
||||
"Dense node, ID 672663473 @ 51.765530,-0.229187\n" +
|
||||
"Dense node, ID 647105141 @ 51.773204,-0.222598\n" +
|
||||
"Dense node, ID 25365926 @ 51.766340,-0.233556\n" +
|
||||
"Dense node, ID 1685167296 @ 51.766924,-0.234783\n" +
|
||||
"Dense node, ID 677439943 @ 51.763178,-0.230230\n" +
|
||||
"Dense node, ID 1701110757 @ 51.766400,-0.228489\n" +
|
||||
"Dense node, ID 663806673 @ 51.765470,-0.229220\n" +
|
||||
"Dense node, ID 502550970 @ 51.765118,-0.233667\n" +
|
||||
"Dense node, ID 692887095 @ 51.766318,-0.229190\n" +
|
||||
"Dense node, ID 1685167376 @ 51.760411,-0.241161\n" +
|
||||
"Dense node, ID 175697821 @ 51.765000,-0.232204\n" +
|
||||
"Dense node, ID 677438877 @ 51.764126,-0.228303\n" +
|
||||
"Dense node, ID 175685111 @ 51.764882,-0.229966\n" +
|
||||
"Dense node, ID 647105131 @ 51.769022,-0.217223\n" +
|
||||
"Dense node, ID 240134267 @ 51.764217,-0.233120\n" +
|
||||
"Dense node, ID 691203111 @ 51.765755,-0.230230\n" +
|
||||
"Dense node, ID 1685167394 @ 51.761213,-0.240218\n" +
|
||||
"Dense node, ID 534873274 @ 51.763918,-0.236563\n" +
|
||||
"Dense node, ID 676945192 @ 51.765148,-0.230615\n" +
|
||||
"Dense node, ID 691203106 @ 51.764494,-0.233449\n" +
|
||||
"Dense node, ID 647105155 @ 51.769580,-0.232061\n" +
|
||||
"Dense node, ID 32950368 @ 51.769048,-0.232790\n" +
|
||||
"Dense node, ID 647105133 @ 51.769183,-0.216784\n" +
|
||||
"Dense node, ID 175683944 @ 51.763140,-0.232112\n" +
|
||||
"Dense node, ID 623540467 @ 51.765719,-0.225990\n" +
|
||||
"Dense node, ID 647225601 @ 51.762732,-0.231722\n" +
|
||||
"Dense node, ID 32953195 @ 51.761987,-0.231091\n" +
|
||||
"Dense node, ID 653970876 @ 51.763436,-0.229153\n" +
|
||||
"Dense node, ID 676945352 @ 51.765646,-0.228469\n" +
|
||||
"Dense node, ID 663806670 @ 51.765540,-0.228771\n" +
|
||||
"Dense node, ID 1709246676 @ 51.766438,-0.231121\n" +
|
||||
"Dense node, ID 647105047 @ 51.774057,-0.222895\n" +
|
||||
"Dense node, ID 175697862 @ 51.765004,-0.232747\n" +
|
||||
"Dense node, ID 647105145 @ 51.771007,-0.230355\n" +
|
||||
"Dense node, ID 647105167 @ 51.762860,-0.236278\n" +
|
||||
"Dense node, ID 1111758067 @ 51.771433,-0.216984\n" +
|
||||
"Dense node, ID 647105166 @ 51.767468,-0.234229\n" +
|
||||
"Dense node, ID 692887118 @ 51.766186,-0.228918\n" +
|
||||
"Dense node, ID 663806658 @ 51.765679,-0.228614\n" +
|
||||
"Dense node, ID 175685507 @ 51.765508,-0.229788\n" +
|
||||
"Dense node, ID 647224486 @ 51.766388,-0.228706\n" +
|
||||
"Dense node, ID 502552074 @ 51.766711,-0.229590\n" +
|
||||
"Dense node, ID 647105132 @ 51.768905,-0.216932\n" +
|
||||
"Dense node, ID 25365925 @ 51.766651,-0.233518\n" +
|
||||
"Dense node, ID 623540472 @ 51.765321,-0.225475\n" +
|
||||
"Dense node, ID 691202857 @ 51.766804,-0.231711\n" +
|
||||
"Dense node, ID 175686201 @ 51.765721,-0.228361\n" +
|
||||
"Dense node, ID 927070648 @ 51.763087,-0.232061\n" +
|
||||
"Dense node, ID 25365924 @ 51.767090,-0.233453\n" +
|
||||
"Dense node, ID 676945335 @ 51.765388,-0.228437\n" +
|
||||
"Dense node, ID 647105127 @ 51.769321,-0.219637\n" +
|
||||
"Dense node, ID 647105134 @ 51.769124,-0.216290\n" +
|
||||
"Dense node, ID 30983853 @ 51.764268,-0.233185\n" +
|
||||
"Dense node, ID 647105164 @ 51.767548,-0.233295\n" +
|
||||
"Dense node, ID 502552081 @ 51.766833,-0.233484\n" +
|
||||
"Dense node, ID 691202855 @ 51.766809,-0.231946\n" +
|
||||
"Dense node, ID 647057820 @ 51.765382,-0.226710\n" +
|
||||
"Dense node, ID 691202869 @ 51.767216,-0.231947\n" +
|
||||
"Dense node, ID 647105159 @ 51.768849,-0.232458\n" +
|
||||
"Dense node, ID 1739780291 @ 51.764890,-0.226086\n" +
|
||||
"Dense node, ID 676945267 @ 51.763905,-0.228040\n" +
|
||||
"Dense node, ID 663806664 @ 51.765444,-0.229274\n" +
|
||||
"Dense node, ID 647105143 @ 51.771399,-0.230034\n" +
|
||||
"Dense node, ID 691202858 @ 51.765928,-0.232698\n" +
|
||||
"Dense node, ID 1701110775 @ 51.766290,-0.228709\n" +
|
||||
"Dense node, ID 365548881 @ 51.763854,-0.232807\n" +
|
||||
"Dense node, ID 647224465 @ 51.765604,-0.226263\n" +
|
||||
"Dense node, ID 691202873 @ 51.766711,-0.232826\n" +
|
||||
"Dense node, ID 287659881 @ 51.766233,-0.228823\n" +
|
||||
"Dense node, ID 1685167328 @ 51.765389,-0.235803\n" +
|
||||
"Dense node, ID 1685167381 @ 51.762135,-0.238938\n" +
|
||||
"Dense node, ID 1685167371 @ 51.768683,-0.233758\n" +
|
||||
"Dense node, ID 1709246791 @ 51.765771,-0.229747\n" +
|
||||
"Dense node, ID 647105156 @ 51.769420,-0.232072\n" +
|
||||
"Dense node, ID 647105139 @ 51.773291,-0.221257\n" +
|
||||
"Dense node, ID 32953193 @ 51.763418,-0.232387\n" +
|
||||
"Dense node, ID 676945199 @ 51.765151,-0.230782\n" +
|
||||
"Dense node, ID 647105147 @ 51.770210,-0.231976\n" +
|
||||
"Dense node, ID 672628083 @ 51.764391,-0.225433\n" +
|
||||
"Dense node, ID 25365922 @ 51.768145,-0.233167\n" +
|
||||
"Dense node, ID 1709246741 @ 51.765960,-0.229886\n" +
|
||||
"Dense node, ID 647105153 @ 51.769673,-0.232265\n" +
|
||||
"Dense node, ID 30983851 @ 51.765372,-0.233546\n" +
|
||||
"Dense node, ID 691202863 @ 51.765224,-0.232225\n" +
|
||||
"Dense node, ID 691202838 @ 51.767798,-0.233387\n" +
|
||||
"Dense node, ID 175684459 @ 51.763370,-0.231564\n" +
|
||||
"Dense node, ID 1685167313 @ 51.762503,-0.238485\n" +
|
||||
"Dense node, ID 692945016 @ 51.765714,-0.230069\n" +
|
||||
"Dense node, ID 25365921 @ 51.768513,-0.232722\n" +
|
||||
"Dense node, ID 676945322 @ 51.765118,-0.229479\n" +
|
||||
"Dense node, ID 534873251 @ 51.763658,-0.236760\n" +
|
||||
"Dense node, ID 1685167341 @ 51.768171,-0.234063\n" +
|
||||
"Dense node, ID 691203110 @ 51.765769,-0.230874\n" +
|
||||
"Dense node, ID 676945292 @ 51.764506,-0.228754\n" +
|
||||
"Dense node, ID 1685167391 @ 51.761506,-0.239827\n" +
|
||||
"Dense node, ID 676945241 @ 51.763212,-0.229644\n" +
|
||||
"Dense node, ID 663806653 @ 51.765898,-0.228877\n" +
|
||||
"Dense node, ID 623624259 @ 51.764905,-0.234965\n" +
|
||||
"Dense node, ID 1685167373 @ 51.763777,-0.237235\n" +
|
||||
"Dense node, ID 676945320 @ 51.765375,-0.230143\n" +
|
||||
"Dense node, ID 240134268 @ 51.764403,-0.232382\n" +
|
||||
"Dense node, ID 676945316 @ 51.764949,-0.230532\n" +
|
||||
"Dense node, ID 623624154 @ 51.765244,-0.234365\n" +
|
||||
"Dense node, ID 647105142 @ 51.774147,-0.226321\n" +
|
||||
"Dense node, ID 1739780285 @ 51.764824,-0.226000\n" +
|
||||
"Dense node, ID 175697671 @ 51.765012,-0.233620\n" +
|
||||
"Dense node, ID 647224613 @ 51.764970,-0.229134\n" +
|
||||
"Dense node, ID 647105121 @ 51.769055,-0.221268\n" +
|
||||
"Dense node, ID 692887101 @ 51.766293,-0.228488\n" +
|
||||
"Dense node, ID 175683342 @ 51.763273,-0.229558\n" +
|
||||
"Dense node, ID 240134269 @ 51.765577,-0.230133\n" +
|
||||
"Dense node, ID 691203053 @ 51.766871,-0.230638\n" +
|
||||
"Dense node, ID 1697422651 @ 51.763725,-0.228467\n" +
|
||||
"Dense node, ID 534873285 @ 51.764110,-0.236786\n" +
|
||||
"Dense node, ID 647105148 @ 51.770131,-0.232104\n" +
|
||||
"Dense node, ID 647105165 @ 51.767482,-0.233317\n" +
|
||||
"Dense node, ID 534873185 @ 51.763403,-0.236752\n" +
|
||||
"Dense node, ID 175685104 @ 51.764391,-0.231506\n" +
|
||||
"Dense node, ID 647105163 @ 51.768079,-0.233048\n" +
|
||||
"Dense node, ID 651652536 @ 51.764591,-0.224432\n" +
|
||||
"Dense node, ID 647105115 @ 51.766990,-0.227373\n" +
|
||||
"Dense node, ID 677439944 @ 51.763332,-0.229790\n" +
|
||||
"Dense node, ID 647105162 @ 51.768232,-0.232866\n" +
|
||||
"Dense node, ID 676945319 @ 51.765218,-0.230449\n" +
|
||||
"Dense node, ID 1539682123 @ 51.769102,-0.232828\n" +
|
||||
"Dense node, ID 534873208 @ 51.763536,-0.236889\n" +
|
||||
"Dense node, ID 647105128 @ 51.769354,-0.219090\n" +
|
||||
"Dense node, ID 1739780280 @ 51.764758,-0.225914\n" +
|
||||
"Dense node, ID 175698323 @ 51.767216,-0.231110\n" +
|
||||
"Dense node, ID 676945189 @ 51.764650,-0.230926\n" +
|
||||
"Dense node, ID 1739780294 @ 51.764955,-0.224922\n" +
|
||||
"Dense node, ID 676945326 @ 51.765291,-0.229382\n" +
|
||||
"Dense node, ID 663806672 @ 51.765417,-0.229059\n" +
|
||||
"Dense node, ID 45169425 @ 51.769130,-0.233478\n" +
|
||||
"Dense node, ID 672663469 @ 51.765930,-0.229036\n" +
|
||||
"Dense node, ID 675146 @ 51.769270,-0.232860\n" +
|
||||
"Dense node, ID 691203054 @ 51.766658,-0.230273\n" +
|
||||
"Dense node, ID 1606957353 @ 51.760049,-0.241558\n" +
|
||||
"Dense node, ID 647105125 @ 51.769248,-0.220260\n" +
|
||||
"Dense node, ID 534874147 @ 51.765262,-0.235825\n" +
|
||||
"Dense node, ID 14713407 @ 51.765828,-0.227391\n" +
|
||||
"Dense node, ID 818056434 @ 51.766040,-0.233470\n" +
|
||||
"Dense node, ID 1111758069 @ 51.769198,-0.216444\n" +
|
||||
"Dense node, ID 175699187 @ 51.765663,-0.231004\n" +
|
||||
"Dense node, ID 175698155 @ 51.767389,-0.230809\n" +
|
||||
"Dense node, ID 691202861 @ 51.765516,-0.231002\n" +
|
||||
"Dense node, ID 651594517 @ 51.763745,-0.228419\n" +
|
||||
"Dense node, ID 691203051 @ 51.765901,-0.231217\n" +
|
||||
"Dense node, ID 647224485 @ 51.765127,-0.226399\n" +
|
||||
"Dense node, ID 1709246749 @ 51.765632,-0.230025\n" +
|
||||
"Dense node, ID 677440300 @ 51.762625,-0.231624\n" +
|
||||
"Dense node, ID 647105172 @ 51.764294,-0.233070\n" +
|
||||
"Dense node, ID 175686498 @ 51.765424,-0.228052\n" +
|
||||
"Dense node, ID 692944963 @ 51.764665,-0.233953\n" +
|
||||
"Dense node, ID 663806656 @ 51.765763,-0.228715\n" +
|
||||
"Dense node, ID 647105154 @ 51.769626,-0.232179\n" +
|
||||
"Dense node, ID 676945317 @ 51.765015,-0.230385\n" +
|
||||
"Dense node, ID 647105169 @ 51.763033,-0.235323\n" +
|
||||
"Dense node, ID 692945021 @ 51.766617,-0.229479\n" +
|
||||
"Dense node, ID 1709246789 @ 51.766231,-0.230173\n" +
|
||||
"Dense node, ID 175686499 @ 51.765976,-0.228635\n" +
|
||||
"Dense node, ID 691202866 @ 51.767110,-0.232955\n" +
|
||||
"Dense node, ID 1111758072 @ 51.769507,-0.216315\n" +
|
||||
"Dense node, ID 647105123 @ 51.769155,-0.220818\n" +
|
||||
"Dense node, ID 672663468 @ 51.765622,-0.228672\n" +
|
||||
"Dense node, ID 676945197 @ 51.765281,-0.230541\n" +
|
||||
"Dense node, ID 692945020 @ 51.766471,-0.229673\n" +
|
||||
"Dense node, ID 175697881 @ 51.764664,-0.232747\n" +
|
||||
"Dense node, ID 175685109 @ 51.764946,-0.230095\n" +
|
||||
"Dense node, ID 1685167304 @ 51.760787,-0.240738\n" +
|
||||
"Dense node, ID 692944951 @ 51.764943,-0.234254\n" +
|
||||
"Dense node, ID 692945019 @ 51.766225,-0.229673\n" +
|
||||
"Dense node, ID 676945334 @ 51.765467,-0.228255\n" +
|
||||
"Dense node, ID 175684463 @ 51.765445,-0.226790\n" +
|
||||
"Dense node, ID 692944957 @ 51.764651,-0.234168\n" +
|
||||
"Dense node, ID 647105144 @ 51.771332,-0.229905\n" +
|
||||
"Dense node, ID 691203055 @ 51.765928,-0.230187\n" +
|
||||
"Dense node, ID 676945331 @ 51.765589,-0.229749\n" +
|
||||
"Dense node, ID 672663474 @ 51.765638,-0.229315\n" +
|
||||
"Dense node, ID 647105146 @ 51.770283,-0.231836\n" +
|
||||
"Dense node, ID 534873171 @ 51.763005,-0.237147\n" +
|
||||
"Dense node, ID 647105157 @ 51.769307,-0.232308\n" +
|
||||
"Dense node, ID 676945327 @ 51.765347,-0.229744\n" +
|
||||
"Dense node, ID 675150 @ 51.766907,-0.229904\n" +
|
||||
"Dense node, ID 663806666 @ 51.765165,-0.228973\n" +
|
||||
"Dense node, ID 691202871 @ 51.766950,-0.232826\n" +
|
||||
"Dense node, ID 672663477 @ 51.765646,-0.228948\n" +
|
||||
"Dense node, ID 647105158 @ 51.769015,-0.232297\n" +
|
||||
"Dense node, ID 673784380 @ 51.762202,-0.231241\n" +
|
||||
"Dense node, ID 647105152 @ 51.769739,-0.232330\n" +
|
||||
"Dense node, ID 692945022 @ 51.766344,-0.228825\n" +
|
||||
"Dense node, ID 676945315 @ 51.764929,-0.230336\n" +
|
||||
"Dense node, ID 676945346 @ 51.765450,-0.228506\n" +
|
||||
"Dense node, ID 647105119 @ 51.768119,-0.223854\n" +
|
||||
"Dense node, ID 175698430 @ 51.766924,-0.231110\n" +
|
||||
"Dense node, ID 1685167387 @ 51.765901,-0.235408\n" +
|
||||
"Dense node, ID 175685910 @ 51.766003,-0.227820\n" +
|
||||
"Dense node, ID 820969139 @ 51.767836,-0.231358\n" +
|
||||
"Dense node, ID 647105102 @ 51.763883,-0.232727\n" +
|
||||
"Dense node, ID 675151 @ 51.766141,-0.228136\n" +
|
||||
"Dense node, ID 175698324 @ 51.766008,-0.231131\n" +
|
||||
"Dense node, ID 1685167282 @ 51.762958,-0.237989\n" +
|
||||
"Dense node, ID 502552090 @ 51.765557,-0.233577\n" +
|
||||
"Dense node, ID 623624155 @ 51.765449,-0.234590\n" +
|
||||
"Dense node, ID 267826070 @ 51.764017,-0.232970\n" +
|
||||
"Dense node, ID 25365930 @ 51.766791,-0.234972\n" +
|
||||
"Dense node, ID 676945195 @ 51.765156,-0.230570\n" +
|
||||
"Dense node, ID 1709246675 @ 51.766423,-0.230168\n" +
|
||||
"Dense node, ID 647105137 @ 51.774248,-0.218055\n" +
|
||||
"Dense node, ID 651652534 @ 51.764261,-0.225160\n" +
|
||||
"Dense node, ID 676945293 @ 51.764816,-0.229133\n" +
|
||||
"Dense node, ID 1692947499 @ 51.773860,-0.225851\n" +
|
||||
"Dense node, ID 623624257 @ 51.765396,-0.234075\n" +
|
||||
"Dense node, ID 175697824 @ 51.764998,-0.232032\n" +
|
||||
"Dense node, ID 672663478 @ 51.765575,-0.229104\n" +
|
||||
"Dense node, ID 1685167290 @ 51.763311,-0.237639\n" +
|
||||
"Dense node, ID 390911769 @ 51.766861,-0.229798\n" +
|
||||
"Dense node, ID 676945323 @ 51.765506,-0.229937\n" +
|
||||
"Dense node, ID 647105136 @ 51.773720,-0.217976\n" +
|
||||
"Dense node, ID 1539682039 @ 51.768036,-0.233265\n" +
|
||||
"Dense node, ID 691202860 @ 51.766247,-0.230595\n" +
|
||||
"Dense node, ID 1145410964 @ 51.769148,-0.232860\n" +
|
||||
"Dense node, ID 647105130 @ 51.769188,-0.217728\n" +
|
||||
"Dense node, ID 691203049 @ 51.766645,-0.234564\n" +
|
||||
"Dense node, ID 1539682089 @ 51.768368,-0.232938\n" +
|
||||
"Dense node, ID 175698550 @ 51.766911,-0.230809\n" +
|
||||
"Dense node, ID 623540479 @ 51.765560,-0.224961\n" +
|
||||
"Dense node, ID 677439941 @ 51.763240,-0.230472\n" +
|
||||
"Dense node, ID 25365927 @ 51.766333,-0.232681\n" +
|
||||
"Dense node, ID 647105135 @ 51.770431,-0.216476\n" +
|
||||
"Dense node, ID 30983852 @ 51.764773,-0.233577\n" +
|
||||
"Dense node, ID 647105150 @ 51.769938,-0.232265\n" +
|
||||
"Dense node, ID 623624261 @ 51.764407,-0.235985\n" +
|
||||
"Dense node, ID 647105149 @ 51.770024,-0.232212\n" +
|
||||
"Dense node, ID 677439946 @ 51.763219,-0.229690\n" +
|
||||
"Dense node, ID 691203109 @ 51.765671,-0.232912\n" +
|
||||
"Dense node, ID 647105171 @ 51.764248,-0.233242\n" +
|
||||
"Dense node, ID 1709246746 @ 51.766196,-0.230058\n" +
|
||||
"Dense node, ID 175685106 @ 51.764728,-0.230781\n" +
|
||||
"Dense node, ID 663806661 @ 51.765857,-0.228507\n" +
|
||||
"Dense node, ID 677439947 @ 51.764197,-0.228387\n" +
|
||||
"Dense node, ID 647105117 @ 51.767435,-0.226150\n" +
|
||||
"Dense node, ID 647105168 @ 51.762754,-0.235838\n" +
|
||||
"Dense node, ID 623624267 @ 51.764016,-0.233964\n" +
|
||||
"Dense node, ID 1709246737 @ 51.766423,-0.230671\n" +
|
||||
"Dense node, ID 175684462 @ 51.764271,-0.229245\n" +
|
||||
"Dense node, ID 175698551 @ 51.766539,-0.230166\n" +
|
||||
"Dense node, ID 675148 @ 51.768657,-0.232378\n" +
|
||||
"Dense node, ID 676945332 @ 51.764887,-0.229157\n" +
|
||||
"Dense node, ID 675149 @ 51.767913,-0.231459\n" +
|
||||
"Dense node, ID 692945018 @ 51.766178,-0.229758\n" +
|
||||
"Dense node, ID 623540483 @ 51.765155,-0.224456\n" +
|
||||
"Dense node, ID 676945350 @ 51.765533,-0.228712\n" +
|
||||
"Dense node, ID 175698975 @ 51.765729,-0.233577\n" +
|
||||
"Dense node, ID 175685102 @ 51.764176,-0.232069\n" +
|
||||
"Dense node, ID 676945347 @ 51.765417,-0.228572\n" +
|
||||
"Dense node, ID 534873262 @ 51.763775,-0.236889\n" +
|
||||
"Dense node, ID 25365931 @ 51.765437,-0.236066\n" +
|
||||
"Dense node, ID 672663470 @ 51.765668,-0.229614\n" +
|
||||
"Dense node, ID 647105138 @ 51.773941,-0.221418\n" +
|
||||
"Dense node, ID 647105151 @ 51.769819,-0.232340\n" +
|
||||
"Dense node, ID 32953194 @ 51.762232,-0.231263\n" +
|
||||
"Dense node, ID 1685167315 @ 51.766349,-0.235121\n" +
|
||||
"Dense node, ID 1111758071 @ 51.769058,-0.216775\n" +
|
||||
"Dense node, ID 691203098 @ 51.764324,-0.234279\n" +
|
||||
"Dense node, ID 175698553 @ 51.766253,-0.230172\n" +
|
||||
"Dense node, ID 1685167287 @ 51.767572,-0.234395\n" +
|
||||
"Dense node, ID 672663471 @ 51.765452,-0.229359\n" +
|
||||
"Dense node, ID 676945325 @ 51.765209,-0.229575\n" +
|
||||
"Dense node, ID 623624156 @ 51.765622,-0.234693\n" +
|
||||
"Dense node, ID 647105140 @ 51.773198,-0.222341\n" +
|
||||
"Dense node, ID 25365928 @ 51.766333,-0.232198\n" +
|
||||
"Dense node, ID 676945329 @ 51.765389,-0.229634\n" +
|
||||
"Dense node, ID 663806668 @ 51.765337,-0.228533\n" +
|
||||
"Dense node, ID 692944966 @ 51.764977,-0.233985\n" +
|
||||
"Dense node, ID 691203099 @ 51.764162,-0.234157\n" +
|
||||
"Dense node, ID 175685100 @ 51.764091,-0.232103\n" +
|
||||
"Dense node, ID 25365923 @ 51.767521,-0.233449\n" +
|
||||
"Dense node, ID 647105161 @ 51.767973,-0.232169\n" +
|
||||
"Dense node, ID 672663467 @ 51.765478,-0.228989\n" +
|
||||
"Dense node, ID 691202854 @ 51.766818,-0.232419\n" +
|
||||
"Way ID 158788812\n" +
|
||||
" Nodes: 1709246789 1709246746 1709246741 1709246791 \n" +
|
||||
" Key=value pairs: highway=footway \n" +
|
||||
"Way ID 53588781\n" +
|
||||
" Nodes: 676945323 676945327 676945325 676945326 676945331 676945323 \n" +
|
||||
" Key=value pairs: landuse=garages source=survey \n" +
|
||||
"Way ID 158788810\n" +
|
||||
" Nodes: 1709246675 1709246737 1709246734 1709246676 \n" +
|
||||
" Key=value pairs: highway=footway \n" +
|
||||
"Way ID 156255508\n" +
|
||||
" Nodes: 45169425 1685167371 1685167341 1685167287 1685167296 1685167315 1685167387 1685167328 1685167373 1685167290 1685167282 1685167313 1685167381 1685167391 1685167394 1685167304 1685167376 1606957353 \n" +
|
||||
" Key=value pairs: carriageway_ref=A highway=motorway lanes=3 layer=-1 lit=yes maxspeed=national name=Hatfield Tunnel oneway=yes ref=A1(M) source:maxspeed=local_knowledge tunnel=yes \n" +
|
||||
"Way ID 54932035\n" +
|
||||
" Nodes: 691202854 691202855 691202857 \n" +
|
||||
" Key=value pairs: highway=residential name=Jasmine Gardens source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 16946553\n" +
|
||||
" Nodes: 175697671 175697862 175697821 175697824 \n" +
|
||||
" Key=value pairs: highway=residential name=Oak Tree Close \n" +
|
||||
"Way ID 52083876\n" +
|
||||
" Nodes: 663806653 663806656 663806658 \n" +
|
||||
" Key=value pairs: highway=service \n" +
|
||||
"Way ID 55081202\n" +
|
||||
" Nodes: 692944951 692944957 692944963 692944966 692944951 \n" +
|
||||
" Key=value pairs: leisure=common source=yahoo \n" +
|
||||
"Way ID 16946600\n" +
|
||||
" Nodes: 175698430 175698550 691203053 691203054 175698551 1709246675 175698553 1709246789 691203055 \n" +
|
||||
" Key=value pairs: highway=residential name=Harmony Close source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 16946559\n" +
|
||||
" Nodes: 175697862 175697881 \n" +
|
||||
" Key=value pairs: created_by=Potlatch 0.5d highway=residential name=Oak Tree Close \n" +
|
||||
"Way ID 16945846\n" +
|
||||
" Nodes: 175684459 175685100 175685102 175685104 676945189 175685106 676945315 175685109 175685111 175684462 \n" +
|
||||
" Key=value pairs: highway=residential name=Stockbreach Close \n" +
|
||||
"Way ID 54932037\n" +
|
||||
" Nodes: 175698553 691202860 \n" +
|
||||
" Key=value pairs: highway=residential name=Harmony Close source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 16946584\n" +
|
||||
" Nodes: 175698155 175698323 175698430 1709246676 175698324 691203051 \n" +
|
||||
" Key=value pairs: highway=residential name=The Minims source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 8361329\n" +
|
||||
" Nodes: 25365926 25365927 25365928 \n" +
|
||||
" Key=value pairs: highway=residential name=The Paddock source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 16945926\n" +
|
||||
" Nodes: 175686498 175686201 663806661 175686499 \n" +
|
||||
" Key=value pairs: highway=residential name=Wellfield Close \n" +
|
||||
"Way ID 52083878\n" +
|
||||
" Nodes: 663806664 663806666 663806668 663806670 663806672 663806673 663806664 \n" +
|
||||
" Key=value pairs: leisure=common source=yahoo \n" +
|
||||
"Way ID 3084923\n" +
|
||||
" Nodes: 675146 1145410964 1539682123 32950368 241806356 675148 675149 820969139 175698155 675150 390911769 647224486 675151 175685910 14713407 175684463 647057820 647224485 1739780291 \n" +
|
||||
" Key=value pairs: abutters=residential highway=secondary name=Wellfield Road ref=B197 \n" +
|
||||
"Way ID 8361331\n" +
|
||||
" Nodes: 25365925 691203049 25365930 25365931 \n" +
|
||||
" Key=value pairs: highway=residential name=Walsingham Close source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 54932038\n" +
|
||||
" Nodes: 175699187 691202861 \n" +
|
||||
" Key=value pairs: highway=residential name=Middlefield source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 16946620\n" +
|
||||
" Nodes: 175698975 691203109 175699187 691203110 691203111 \n" +
|
||||
" Key=value pairs: highway=residential name=Middlefield source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 157868709\n" +
|
||||
" Nodes: 1701110757 1701110775 \n" +
|
||||
" Key=value pairs: bridge=yes cycleway=track highway=cycleway layer=1 name=Alban Way ncn_ref=61 railway=abandoned \n" +
|
||||
"Way ID 52083877\n" +
|
||||
" Nodes: 663806656 663806661 \n" +
|
||||
" Key=value pairs: highway=service \n" +
|
||||
"Way ID 53588764\n" +
|
||||
" Nodes: 676945267 677438877 677439947 676945292 676945293 676945332 647224613 175686498 \n" +
|
||||
" Key=value pairs: highway=footway \n" +
|
||||
"Way ID 49161822\n" +
|
||||
" Nodes: 30983851 623624257 623624154 623624259 623624261 \n" +
|
||||
" Key=value pairs: highway=residential name=Worcester Road \n" +
|
||||
"Way ID 49161823\n" +
|
||||
" Nodes: 623624259 691203098 691203099 623624267 \n" +
|
||||
" Key=value pairs: highway=residential name=Ely Close \n" +
|
||||
"Way ID 53588782\n" +
|
||||
" Nodes: 676945327 676945329 \n" +
|
||||
" Key=value pairs: bicycle=no highway=footway source=survey \n" +
|
||||
"Way ID 54932044\n" +
|
||||
" Nodes: 691202869 691202855 \n" +
|
||||
" Key=value pairs: highway=residential name=Jasmine Gardens source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 49161817\n" +
|
||||
" Nodes: 623624154 623624155 623624156 \n" +
|
||||
" Key=value pairs: highway=residential name=Malvern Close \n" +
|
||||
"Way ID 53588780\n" +
|
||||
" Nodes: 676945350 676945352 676945334 676945335 676945346 676945347 676945350 \n" +
|
||||
" Key=value pairs: building=yes name=Friendship House source=survey \n" +
|
||||
"Way ID 53588749\n" +
|
||||
" Nodes: 676945199 676945316 676945317 676945195 676945319 676945197 676945199 \n" +
|
||||
" Key=value pairs: landuse=garages source=survey \n" +
|
||||
"Way ID 4673618\n" +
|
||||
" Nodes: 675148 25365921 1539682089 25365922 1539682039 691202838 25365923 25365924 25365925 25365926 175698975 30983851 175697671 30983852 691203106 30983853 240134267 267826070 365548881 32953193 175683944 927070648 647225601 677440300 32953194 673784380 32953195 \n" +
|
||||
" Key=value pairs: highway=tertiary name=Lemsford Road \n" +
|
||||
"Way ID 53638158\n" +
|
||||
" Nodes: 677439941 677439943 677439944 677439946 676945241 175683342 653970876 653970877 1697422651 651594517 676945267 677438877 677439947 647224485 1739780291 1739780285 1739780280 672628083 651652534 651652536 1739780294 623540483 623540479 623540472 623540467 647224465 647057820 175684463 14713407 175685910 675151 692887101 647224486 647105115 647105117 647105119 647105121 647105123 647105125 647105127 647105128 647105129 647105130 647105131 647105132 1111758071 647105133 1111758069 647105134 1111758072 647105135 1111758067 647105136 647105137 647105138 647105139 647105140 647105141 647105047 1692947499 647105142 647105143 647105144 647105145 647105146 647105147 647105148 647105149 647105150 647105151 647105152 647105153 647105154 647105155 647105156 647105157 647105158 647105159 647105160 647105161 647105162 647105163 647105164 647105165 647105166 534874147 534873285 534873274 534873262 534873251 534873208 534873185 534873171 647105167 647105168 647105169 647105170 647105171 647105172 647105102 647225601 677439941 \n" +
|
||||
" Key=value pairs: landuse=residential \n" +
|
||||
"Way ID 53588748\n" +
|
||||
" Nodes: 676945322 676945325 676945327 676945320 676945192 676945315 \n" +
|
||||
" Key=value pairs: bicycle=no highway=footway source=survey \n" +
|
||||
"Way ID 50772651\n" +
|
||||
" Nodes: 175685111 676945322 175685506 647224613 \n" +
|
||||
" Key=value pairs: highway=residential name=Town Fields \n" +
|
||||
"Way ID 158788824\n" +
|
||||
" Nodes: 175685507 1709246749 \n" +
|
||||
" Key=value pairs: highway=footway \n" +
|
||||
"Way ID 54932042\n" +
|
||||
" Nodes: 691202866 691202871 691202873 \n" +
|
||||
" Key=value pairs: highway=residential name=Jasmine Gardens source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 53152061\n" +
|
||||
" Nodes: 672663467 672663468 672663469 672663470 672663471 672663473 672663474 672663476 672663477 672663478 672663467 \n" +
|
||||
" Key=value pairs: amenity=retirement _home building=yes name=Greenacres source:area=yahoo source:name=survey \n" +
|
||||
"Way ID 53638215\n" +
|
||||
" Nodes: 175685506 676945329 175685507 \n" +
|
||||
" Key=value pairs: highway=service source=survey \n" +
|
||||
"Way ID 157868710\n" +
|
||||
" Nodes: 1701110775 287659881 692887118 1709246791 1709246749 240134269 240134268 \n" +
|
||||
" Key=value pairs: cycleway=track highway=cycleway name=Alban Way ncn_ref=61 railway=abandoned \n" +
|
||||
"Way ID 54932036\n" +
|
||||
" Nodes: 25365927 691202858 \n" +
|
||||
" Key=value pairs: highway=residential name=The Paddock source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 54932039\n" +
|
||||
" Nodes: 175697821 691202863 \n" +
|
||||
" Key=value pairs: highway=residential name=Oak Tree Close source=OS_OpenData_StreetView \n" +
|
||||
"Way ID 55081204\n" +
|
||||
" Nodes: 692945016 692945017 692945018 692945019 692945020 692945021 692945022 692945016 \n" +
|
||||
" Key=value pairs: leisure=common \n" +
|
||||
"Way ID 55071941\n" +
|
||||
" Nodes: 692887118 692887101 \n" +
|
||||
" Key=value pairs: foot=yes highway=footway \n" +
|
||||
"Way ID 157868707\n" +
|
||||
" Nodes: 240134268 240134269 1709246749 1709246791 692887118 287659881 \n" +
|
||||
" Key=value pairs: cycleway=track highway=cycleway name=Alban Way ncn_ref=61 \n" +
|
||||
"Got some relations to parse.\n" +
|
||||
"Complete!\n").replace("\n", System.lineSeparator());
|
||||
try (InputStream input = ReadFileTest.class.getResourceAsStream("/sample.pbf");
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter)) {
|
||||
BlockReaderAdapter brad = new TestBinaryParser(printWriter);
|
||||
new BlockInputStream(input, brad).process();
|
||||
Assert.assertEquals(expected, stringWriter.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestBinaryParser extends BinaryParser {
|
||||
|
||||
private final PrintWriter writer;
|
||||
|
||||
private TestBinaryParser(PrintWriter writer) {
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseRelations(List<Relation> rels) {
|
||||
if (!rels.isEmpty())
|
||||
writer.println("Got some relations to parse.");
|
||||
Relation r = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseDense(DenseNodes nodes) {
|
||||
long lastId = 0;
|
||||
long lastLat = 0;
|
||||
long lastLon = 0;
|
||||
|
||||
for (int i = 0; i < nodes.getIdCount(); i++) {
|
||||
lastId += nodes.getId(i);
|
||||
lastLat += nodes.getLat(i);
|
||||
lastLon += nodes.getLon(i);
|
||||
writer.printf("Dense node, ID %d @ %.6f,%.6f%n",
|
||||
lastId, parseLat(lastLat), parseLon(lastLon));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseNodes(List<Node> nodes) {
|
||||
for (Node n : nodes) {
|
||||
writer.printf("Regular node, ID %d @ %.6f,%.6f%n",
|
||||
n.getId(), parseLat(n.getLat()), parseLon(n.getLon()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseWays(List<Way> ways) {
|
||||
for (Way w : ways) {
|
||||
writer.println("Way ID " + w.getId());
|
||||
writer.print(" Nodes: ");
|
||||
long lastRef = 0;
|
||||
for (Long ref : w.getRefsList()) {
|
||||
lastRef += ref;
|
||||
writer.print(lastRef);
|
||||
writer.print(" ");
|
||||
}
|
||||
writer.println();
|
||||
writer.print(" Key=value pairs: ");
|
||||
for (int i = 0; i < w.getKeysCount(); i++) {
|
||||
writer.print(getStringById(w.getKeys(i)));
|
||||
writer.print("=");
|
||||
writer.print(getStringById(w.getVals(i)));
|
||||
writer.print(" ");
|
||||
}
|
||||
writer.println();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(HeaderBlock header) {
|
||||
writer.println("Got header block.");
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
writer.println("Complete!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,240 @@
|
|||
/**
|
||||
* Copyright (c) 2010 Scott A. Crosby. <scott@sacrosby.com>
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package crosby.binary;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import crosby.binary.Osmformat.*;
|
||||
import crosby.binary.Osmformat.StringTable;
|
||||
import crosby.binary.Osmformat.Relation.MemberType;
|
||||
import crosby.binary.file.BlockOutputStream;
|
||||
import crosby.binary.file.FileBlock;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class WriteFileTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleFileBlock1() throws Exception {
|
||||
test("deflate", "/SimpleFileBlock1-deflate.osm.pbf");
|
||||
test("none", "/SimpleFileBlock1-none.osm.pbf");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGranFileBlock1() throws Exception {
|
||||
test("deflate", "/GranFileBlock1-deflate.osm.pbf");
|
||||
test("none", "/GranFileBlock1-none.osm.pbf");
|
||||
}
|
||||
|
||||
private void test(String compress, String resource) throws IOException, URISyntaxException {
|
||||
try (ByteArrayOutputStream bytes = new ByteArrayOutputStream()) {
|
||||
BuildTestFile builder = new BuildTestFile(new BlockOutputStream(bytes), compress);
|
||||
if (resource.startsWith("/SimpleFileBlock1")) {
|
||||
builder.makeSimpleFileBlock1();
|
||||
} else if (resource.startsWith("/GranFileBlock1")) {
|
||||
builder.makeGranFileBlock1();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
byte[] expected = Files.readAllBytes(Paths.get(WriteFileTest.class.getResource(resource).toURI()));
|
||||
Assert.assertArrayEquals(expected, bytes.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BuildTestFile {
|
||||
private final BlockOutputStream output;
|
||||
public static final long BILLION = 1000000000L;
|
||||
|
||||
StringTable makeStringTable(String prefix) {
|
||||
return
|
||||
StringTable.newBuilder()
|
||||
.addS(ByteString.copyFromUtf8("")) // Never used.
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset1"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset2"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset3"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset4"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset5"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset6"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset7"))
|
||||
.addS(ByteString.copyFromUtf8(prefix + "Offset8"))
|
||||
.build();
|
||||
}
|
||||
|
||||
void makeSimpleFileBlock1() throws IOException {
|
||||
PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder();
|
||||
b1.setStringtable(makeStringTable("B1"));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(101).setLat(13 * 10 * 1000 * 1000).setLon(-14 * 10 * 1000 * 1000)
|
||||
.addKeys(1).addVals(2))
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(101).setLat(12345678).setLon(-23456789)) // Should be 1.2345678 degrees lat and -2.3456789 lon.
|
||||
);
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(201)
|
||||
.addRefs(101).addRefs(1).addRefs(-1).addRefs(10).addRefs(-20) // Delta coded. Should be 101, 102, 101, 111, 91.
|
||||
.addKeys(2).addVals(1).addKeys(3).addVals(4))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(-301)
|
||||
.addRefs(211).addRefs(1).addRefs(-1).addRefs(10).addRefs(-300) // Delta coded. Should be 211, 212, 211, 221, -79
|
||||
.addKeys(4).addVals(3).addKeys(5).addVals(6))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(401).addRefs(211).addRefs(1))
|
||||
.addWays(Way.newBuilder()
|
||||
.setId(501))
|
||||
);
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addRelations(Relation.newBuilder()
|
||||
.setId(601)
|
||||
.addTypes(MemberType.NODE).addMemids(50).addRolesSid(2)
|
||||
.addTypes(MemberType.NODE).addMemids(3).addRolesSid(3)
|
||||
.addTypes(MemberType.WAY).addMemids(3).addRolesSid(4)
|
||||
.addTypes(MemberType.RELATION).addMemids(3).addRolesSid(5))
|
||||
.addRelations(Relation.newBuilder()
|
||||
.setId(701)
|
||||
.addTypes(MemberType.RELATION).addMemids(60).addRolesSid(6)
|
||||
.addTypes(MemberType.RELATION).addMemids(5).addRolesSid(7)
|
||||
.addKeys(1).addVals(2)));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.setDense(DenseNodes.newBuilder()
|
||||
.addId(1001).addId(110).addId(-2000).addId(8889)
|
||||
.addLat(12 * 10000000).addLat(1500000).addLat(-12 * 10000000).addLat(-12 * 10000000)
|
||||
.addLon(-12 * 10000000).addLon(2500000).addLon(13 * 10000000).addLon(2 * 10000000)
|
||||
.addKeysVals(1).addKeysVals(2).addKeysVals(0)
|
||||
.addKeysVals(0)
|
||||
.addKeysVals(2).addKeysVals(3).addKeysVals(4).addKeysVals(5).addKeysVals(0)
|
||||
.addKeysVals(3).addKeysVals(3).addKeysVals(0)
|
||||
));
|
||||
|
||||
output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(), null));
|
||||
|
||||
PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder();
|
||||
b2.setLatOffset(10 * BILLION + 109208300)
|
||||
.setLonOffset(20 * BILLION + 901802700)
|
||||
.setGranularity(1200);
|
||||
b2.setStringtable(makeStringTable("B2"));
|
||||
|
||||
// Test out granularity stuff.
|
||||
b2.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder().setId(100000).setLat(0).setLon(0))
|
||||
.addNodes(Node.newBuilder().setId(100001).setLat(1000).setLon(2000))
|
||||
.addNodes(Node.newBuilder().setId(100002).setLat(1001).setLon(2001))
|
||||
.addNodes(Node.newBuilder().setId(100003).setLat(1002).setLon(2002))
|
||||
.addNodes(Node.newBuilder().setId(100004).setLat(1003).setLon(2003))
|
||||
.addNodes(Node.newBuilder().setId(100005).setLat(1004).setLon(2004)));
|
||||
|
||||
|
||||
output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(), null));
|
||||
}
|
||||
|
||||
|
||||
BuildTestFile(BlockOutputStream output, String compress) throws IOException {
|
||||
this.output = output;
|
||||
this.output.setCompress(compress);
|
||||
HeaderBlock.Builder b = HeaderBlock.newBuilder();
|
||||
b.addRequiredFeatures("OsmSchema-V0.6").addRequiredFeatures("DenseNodes").setSource("QuickBrownFox");
|
||||
this.output.write(FileBlock.newInstance("OSMHeader", b.build().toByteString(), null));
|
||||
}
|
||||
|
||||
void makeGranFileBlock1() throws IOException {
|
||||
PrimitiveBlock.Builder b1 = PrimitiveBlock.newBuilder();
|
||||
b1.setLatOffset(10 * BILLION + 109208300)
|
||||
.setLonOffset(20 * BILLION + 901802700)
|
||||
.setGranularity(1200)
|
||||
.setDateGranularity(2500);
|
||||
b1.setStringtable(makeStringTable("C1"));
|
||||
|
||||
b1.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100001)
|
||||
.setLat(1000).setLon(2000)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setTimestamp(1001)
|
||||
.setChangeset(-12)
|
||||
.setUid(21)
|
||||
.setUserSid(6)
|
||||
.build())
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100002)
|
||||
.setLat(1001).setLon(2001)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setVersion(102)
|
||||
.setTimestamp(1002)
|
||||
.setChangeset(12)
|
||||
.setUid(-21)
|
||||
.setUserSid(5)
|
||||
.build())
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100003)
|
||||
.setLat(1003).setLon(2003)
|
||||
.setInfo(Info.newBuilder()
|
||||
.setVersion(103)
|
||||
.setUserSid(4)
|
||||
.build())
|
||||
.build())
|
||||
);
|
||||
|
||||
// The same, but with different granularities.
|
||||
PrimitiveBlock.Builder b2 = PrimitiveBlock.newBuilder();
|
||||
b2.setLatOffset(12 * BILLION + 303)
|
||||
.setLonOffset(22 * BILLION + 404)
|
||||
.setGranularity(1401)
|
||||
.setDateGranularity(3003);
|
||||
b2.setStringtable(makeStringTable("C2"));
|
||||
b2.addPrimitivegroup(
|
||||
PrimitiveGroup.newBuilder()
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100001)
|
||||
.addKeys(1).addVals(2)
|
||||
.addKeys(1).addVals(3) // Support multiple vals for a key.
|
||||
.addKeys(3).addVals(4)
|
||||
.setLat(1000).setLon(2000)
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100002)
|
||||
.setLat(1001).setLon(2001)
|
||||
.build())
|
||||
.addNodes(Node.newBuilder()
|
||||
.setId(100003)
|
||||
.setLat(1003).setLon(2003)
|
||||
.addKeys(5).addVals(6)
|
||||
.build())
|
||||
);
|
||||
output.write(FileBlock.newInstance("OSMData", b1.build().toByteString(), null));
|
||||
output.write(FileBlock.newInstance("OSMData", b2.build().toByteString(), null));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
SET(PROJECT osmpbf-outline)
|
||||
PROJECT(${PROJECT})
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/O3")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-O3 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
|
||||
SET(CPP_SRC osmpbf-outline.cpp)
|
||||
SET(HPP_SRC "")
|
||||
SET(C_SRC "")
|
||||
include_directories("${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
add_executable(${PROJECT} ${HPP_SRC} ${CPP_SRC} ${C_SRC})
|
||||
set_target_properties(${PROJECT} PROPERTIES LINKER_LANGUAGE CXX LANGUAGE CXX)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
INCLUDE (CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES(winsock2.h HAVE_WINSOCK)
|
||||
if(HAVE_WINSOCK)
|
||||
add_definitions( -DD_HAVE_WINSOCK )
|
||||
SET(WINSOCK_LIB ws2_32)
|
||||
endif()
|
||||
|
||||
|
||||
find_package(Threads)
|
||||
target_link_libraries(${PROJECT} ${WINSOCK_LIB} ${ZLIB_LIBRARY} osmpbf ${PROTOBUF_LITE_LIBRARIES})
|
||||
|
||||
INSTALL(TARGETS ${PROJECT} RUNTIME DESTINATION bin)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# these default settings can be overridden by setting environment variables
|
||||
PREFIX ?= /usr/local
|
||||
CXX ?= g++
|
||||
CXXFLAGS ?= -g
|
||||
|
||||
CXXFLAGS += -I../include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -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 -losmpbf
|
||||
|
||||
.PHONY: clean install
|
||||
|
||||
all: osmpbf-outline
|
||||
|
||||
osmpbf-outline: osmpbf-outline.cpp
|
||||
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS)
|
||||
|
||||
install:
|
||||
install -m 755 -d $(DESTDIR)$(PREFIX)/bin
|
||||
install -m 755 -s osmpbf-outline $(DESTDIR)$(PREFIX)/bin
|
||||
|
||||
clean:
|
||||
rm -f osmpbf-outline
|
||||
|
||||
Loading…
Reference in New Issue