Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (4)
New upstream version 2.15.0
· 23e0c56e
Bas Couwenberg
authored
Dec 08, 2018
23e0c56e
Merge tag 'upstream/2.15.0'
· d4d95406
Bas Couwenberg
authored
Dec 08, 2018
Upstream version 2.15.0
d4d95406
New upstream release.
· 3f6e5164
Bas Couwenberg
authored
Dec 08, 2018
3f6e5164
Set distribution to unstable.
· c177123c
Bas Couwenberg
authored
Dec 08, 2018
c177123c
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
c177123c
...
...
@@ -6,9 +6,7 @@
language
:
generic
sudo
:
false
dist
:
trusty
dist
:
xenial
#-----------------------------------------------------------------------------
...
...
@@ -32,182 +30,138 @@ addons_shortcuts:
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-3.5'
]
addons_clang38
:
&clang38
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-3.8'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-3.8'
]
addons_clang39
:
&clang39
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-3.9'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-3.9'
]
addons_clang50
:
&clang50
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
,
'
llvm-toolchain-trusty-5.0'
]
packages
:
[
'
libboost
1.55
-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-5.0'
,
'
g++-6'
,
'
gcc-6'
]
sources
:
[
'
ubuntu-toolchain-r-test'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-5.0'
,
'
g++-6'
,
'
gcc-6'
]
addons_clang60
:
&clang60
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
,
'
llvm-toolchain-trusty-6.0'
]
packages
:
[
'
libboost
1.55
-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-6.0'
,
'
g++-6'
,
'
gcc-6'
]
sources
:
[
'
ubuntu-toolchain-r-test'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
clang-6.0'
,
'
g++-6'
,
'
gcc-6'
]
addons_gcc48
:
&gcc48
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-4.8'
,
'
gcc-4.8'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-4.8'
,
'
gcc-4.8'
]
addons_gcc49
:
&gcc49
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-4.9'
,
'
gcc-4.9'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-4.9'
,
'
gcc-4.9'
]
addons_gcc5
:
&gcc5
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-5'
,
'
gcc-5'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-5'
,
'
gcc-5'
]
addons_gcc6
:
&gcc6
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
boost-latest'
]
packages
:
[
'
libboost1.55-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-6'
,
'
gcc-6'
]
sources
:
[
'
ubuntu-toolchain-r-test'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-6'
,
'
gcc-6'
]
addons_gcc7
:
&gcc7
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
]
packages
:
[
'
libboost-all-dev'
,
'
libgdal-dev'
,
'
libproj-dev'
,
'
libsparsehash-dev'
,
'
spatialite-bin'
,
'
g++-7'
,
'
gcc-7'
]
#-----------------------------------------------------------------------------
matrix
:
include
:
# 1/ Linux Clang Builds
-
os
:
linux
compiler
:
linux-clang35-release
env
:
CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Release'
addons
:
*clang35
# Linux Clang Builds
-
os
:
linux
compiler
:
linux-clang35-dev
env
:
CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Dev'
addons
:
*clang35
-
os
:
linux
compiler
:
linux-clang38-release
env
:
CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Release'
addons
:
*clang38
dist
:
trusty
-
os
:
linux
compiler
:
linux-clang38-dev
env
:
CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Dev'
addons
:
*clang38
-
os
:
linux
compiler
:
linux-clang39-release
env
:
CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Release'
addons
:
*clang39
-
os
:
linux
compiler
:
linux-clang39-dev
env
:
CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Dev'
addons
:
*clang39
-
os
:
linux
compiler
:
linux-clang50-release
env
:
CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Release'
addons
:
*clang50
-
os
:
linux
compiler
:
linux-clang50-dev
env
:
CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Dev'
addons
:
*clang50
-
os
:
linux
compiler
:
linux-clang60-
release
env
:
CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='
Release
'
compiler
:
linux-clang60-
dev
env
:
CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='
Dev
'
addons
:
*clang60
-
os
:
linux
compiler
:
linux-clang60-dev
env
:
CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Dev'
compiler
:
linux-clang60-debug
env
:
CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Debug'
CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer"
LDFLAGS="-fsanitize=address,undefined,integer"
addons
:
*clang60
# Disabled because it creates false-positives on the old travis systems
# - os: linux
# compiler: linux-clang50-debug
# env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Debug'
# CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer"
# LDFLAGS="-fsanitize=address,undefined,integer"
# # LSAN doesn't work on container-based system
# sudo: required
# addons: *clang50
# 2/ Linux GCC Builds
-
os
:
linux
compiler
:
linux-gcc48-release
env
:
CC='gcc-4.8' CXX='g++-4.8' BUILD_TYPE='Release'
CXXFLAGS='-Wno-return-type'
addons
:
*gcc48
compiler
:
linux-clang60-release
env
:
CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Release'
addons
:
*clang60
# Linux GCC Builds
-
os
:
linux
compiler
:
linux-gcc48-dev
env
:
CC='gcc-4.8' CXX='g++-4.8' BUILD_TYPE='Dev'
CXXFLAGS='-Wno-return-type'
addons
:
*gcc48
-
os
:
linux
compiler
:
linux-gcc49-release
env
:
CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Release'
addons
:
*gcc49
-
os
:
linux
compiler
:
linux-gcc49-dev
env
:
CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Dev'
addons
:
*gcc49
-
os
:
linux
compiler
:
linux-gcc5-release
env
:
CC='gcc-5' CXX='g++-5' BUILD_TYPE='Release'
addons
:
*gcc5
-
os
:
linux
compiler
:
linux-gcc5-dev
env
:
CC='gcc-5' CXX='g++-5' BUILD_TYPE='Dev'
addons
:
*gcc5
-
os
:
linux
compiler
:
linux-gcc6-release
env
:
CC='gcc-6' CXX='g++-6' BUILD_TYPE='Release'
addons
:
*gcc6
-
os
:
linux
compiler
:
linux-gcc6-dev
env
:
CC='gcc-6' CXX='g++-6' BUILD_TYPE='Dev'
addons
:
*gcc6
-
os
:
linux
compiler
:
linux-gcc
6-coverage
env
:
CC='gcc-
6
' CXX='g++-
6
' BUILD_TYPE='
Coverage
'
addons
:
*gcc
6
compiler
:
linux-gcc
7-dev
env
:
CC='gcc-
7
' CXX='g++-
7
' BUILD_TYPE='
Dev
'
addons
:
*gcc
7
# 3/ OSX Clang Builds
-
os
:
osx
osx_image
:
xcode6.4
compiler
:
xcode64-clang-release
env
:
CC='clang' CXX='clang++' BUILD_TYPE='Release'
-
os
:
linux
compiler
:
linux-gcc7-coverage
env
:
CC='gcc-7' CXX='g++-7' BUILD_TYPE='Coverage'
addons
:
*gcc7
-
os
:
linux
compiler
:
linux-gcc7-release
env
:
CC='gcc-7' CXX='g++-7' BUILD_TYPE='Release'
addons
:
*gcc7
# OSX Clang Builds
-
os
:
osx
osx_image
:
xcode
6.4
compiler
:
xcode
64
-clang-dev
osx_image
:
xcode
8.3
compiler
:
xcode
83
-clang-dev
env
:
CC='clang' CXX='clang++' BUILD_TYPE='Dev'
-
os
:
osx
osx_image
:
xcode
7
compiler
:
xcode
7
-clang-
release
env
:
CC='clang' CXX='clang++' BUILD_TYPE='
Release
'
osx_image
:
xcode
9.4
compiler
:
xcode
94
-clang-
dev
env
:
CC='clang' CXX='clang++' BUILD_TYPE='
Dev
'
-
os
:
osx
osx_image
:
xcode
7
compiler
:
xcode
7
-clang-dev
osx_image
:
xcode
10.1
compiler
:
xcode
10
-clang-dev
env
:
CC='clang' CXX='clang++' BUILD_TYPE='Dev'
-
os
:
osx
osx_image
:
xcode
8.3
compiler
:
xcode
8
-clang-release
osx_image
:
xcode
10.1
compiler
:
xcode
10
-clang-release
env
:
CC='clang' CXX='clang++' BUILD_TYPE='Release'
-
os
:
osx
osx_image
:
xcode8.3
compiler
:
xcode8-clang-dev
env
:
CC='clang' CXX='clang++' BUILD_TYPE='Dev'
install
:
-
git clone --quiet --depth 1 https://github.com/mapbox/protozero.git ../protozero
...
...
CHANGELOG.md
View file @
c177123c
...
...
@@ -13,6 +13,34 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Fixed
## [2.15.0] - 2018-12-07
### Added
*
Function
`dump_as_array()`
to dump sparse array indexes.
*
Set the
`xml_josm_upload`
header option when reading XML files.
*
New function
`OSMObject::remove_tags()`
marks tags on OSM objects as
removed.
*
More tests.
### Changed
*
When reading OSM files Libosmium now has less memory overhead, especially
when reading PBF files. This works by using more, but smaller buffers.
*
The
`TagsFilter`
class is now based on the
`TagsFilterBase`
template
class which allows setting the result type. This allows the filter to
return more data depending on the rule that matched.
*
Use enums for many constants instead of (static) const(expr) variables.
*
Make
`chunk_bits`
in
`IdSetDense`
configurable.
*
Hardcode
`%lld`
format instead of using
`<cinttypes>`
PRI macro.
*
Update included gdalcpp to version 1.2.0.
### Fixed
*
The gzip/bzip2 compression code was overhauled and is better tested now.
This fixes some bugs on Windows.
## [2.14.2] - 2018-07-23
### Fixed
...
...
@@ -869,7 +897,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
Doxygen (up to version 1.8.8). This version contains a workaround to fix
this.
[
unreleased
]:
https://github.com/osmcode/libosmium/compare/v2.14.2...HEAD
[
unreleased
]:
https://github.com/osmcode/libosmium/compare/v2.15.0...HEAD
[
2.15.0
]:
https://github.com/osmcode/libosmium/compare/v2.14.2...v2.15.0
[
2.14.2
]:
https://github.com/osmcode/libosmium/compare/v2.14.1...v2.14.2
[
2.14.1
]:
https://github.com/osmcode/libosmium/compare/v2.14.0...v2.14.1
[
2.14.0
]:
https://github.com/osmcode/libosmium/compare/v2.13.1...v2.14.0
...
...
CMakeLists.txt
View file @
c177123c
...
...
@@ -12,20 +12,35 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#-----------------------------------------------------------------------------
#
#
Project vers
ion
#
Configurat
ion
s
#
#-----------------------------------------------------------------------------
set
(
CMAKE_CXX_FLAGS_COVERAGE
"-g -O0 -fno-inline-functions -fno-inline --coverage
${
extra_coverage_flags_
}
"
CACHE STRING
"Flags used by the compiler during coverage builds."
)
set
(
CMAKE_EXE_LINKER_FLAGS_COVERAGE
"--coverage"
CACHE STRING
"Flags used by the linker during coverage builds."
)
set
(
CMAKE_CONFIGURATION_TYPES
"Debug;Release;RelWithDebInfo;MinSizeRel;Dev;Coverage"
CACHE STRING
"List of available configuration types"
FORCE
)
#-----------------------------------------------------------------------------
#
# Project version
#
#-----------------------------------------------------------------------------
project
(
libosmium
)
set
(
LIBOSMIUM_VERSION_MAJOR 2
)
set
(
LIBOSMIUM_VERSION_MINOR 1
4
)
set
(
LIBOSMIUM_VERSION_PATCH
2
)
set
(
LIBOSMIUM_VERSION_MINOR 1
5
)
set
(
LIBOSMIUM_VERSION_PATCH
0
)
set
(
LIBOSMIUM_VERSION
"
${
LIBOSMIUM_VERSION_MAJOR
}
.
${
LIBOSMIUM_VERSION_MINOR
}
.
${
LIBOSMIUM_VERSION_PATCH
}
"
)
...
...
@@ -100,14 +115,6 @@ endif()
# set(extra_coverage_flags_ "-fkeep-inline-functions")
#endif()
set
(
CMAKE_CXX_FLAGS_COVERAGE
"-g -O0 -fno-inline-functions -fno-inline --coverage
${
extra_coverage_flags_
}
"
CACHE STRING
"Flags used by the compiler during coverage builds."
)
set
(
CMAKE_EXE_LINKER_FLAGS_COVERAGE
"--coverage"
CACHE STRING
"Flags used by the linker during coverage builds."
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Coverage"
)
if
(
BUILD_EXAMPLES OR BUILD_HEADERS OR BUILD_BENCHMARKS
)
message
(
WARNING
"Coverage builds don't work for anything but the tests"
)
...
...
README.md
View file @
c177123c
...
...
@@ -68,7 +68,7 @@ cmake:
This will build the examples and tests. Call
`ctest`
to run the tests.
For more detals see the
For more deta
i
ls see the
[
Building Libosmium
](
https://osmcode.org/libosmium/manual.html#building-libosmium
)
chapter in the manual.
...
...
appveyor.yml
View file @
c177123c
...
...
@@ -4,6 +4,14 @@
#
#-----------------------------------------------------------------------------
os
:
Visual Studio
2017
platform
:
x64
clone_depth
:
1
#-----------------------------------------------------------------------------
environment
:
matrix
:
-
config
:
MSYS2
...
...
@@ -17,12 +25,7 @@ environment:
-
config
:
Release
autocrlf
:
false
clone_depth
:
1
# Operating system (build VM template)
os
:
Visual Studio
2015
platform
:
x64
#-----------------------------------------------------------------------------
# scripts that are called at very beginning, before repo cloning
init
:
...
...
build-appveyor.bat
View file @
c177123c
...
...
@@ -46,7 +46,7 @@ SET CMAKE_CMD=cmake .. -LA -G "Visual Studio 14 Win64" ^
-DOsmium
_DEBUG
=
TRUE
^
-DCMAKE
_BUILD_TYPE
=
%config%
^
-DBUILD
_HEADERS
=
OFF
^
-DBOOST
_ROOT
=
C
:/Libraries/boost_1_6
3
_0
^
-DBOOST
_ROOT
=
C
:/Libraries/boost_1_6
7
_0
^
-DZLIB
_INCLUDE_DIR
=
C
:/projects/zlib
-vc
140
-static
-
64
.1.2.11/lib/native/include
^
-DZLIB
_LIBRARY
=
C
:/projects/zlib
-vc
140
-static
-
64
.1.2.11/lib/native/libs/x64/static/
%config%
/zlibstatic
.lib
^
-DEXPAT
_INCLUDE_DIR
=
C
:/projects/expat.v140.2.2.5/build/native/include
^
...
...
@@ -68,7 +68,7 @@ msbuild libosmium.sln ^
/p
:PlatformToolset
=
v140
%avlogger%
IF
%ERRORLEVEL%
NEQ
0
GOTO
ERROR
ctest
--output-on-failure -C
%config%
-E
testdata
-overview
ctest
--output-on-failure -C
%config%
IF
%ERRORLEVEL%
NEQ
0
GOTO
ERROR
GOTO
DONE
...
...
cmake/FindOsmium.cmake
View file @
c177123c
...
...
@@ -71,6 +71,9 @@ find_path(OSMIUM_INCLUDE_DIR osmium/version.hpp
# Check libosmium version number
if
(
Osmium_FIND_VERSION
)
if
(
NOT EXISTS
"
${
OSMIUM_INCLUDE_DIR
}
/osmium/version.hpp"
)
message
(
FATAL_ERROR
"Missing
${
OSMIUM_INCLUDE_DIR
}
/osmium/version.hpp. Either your libosmium version is too old, or libosmium wasn't found in the place you said."
)
endif
()
file
(
STRINGS
"
${
OSMIUM_INCLUDE_DIR
}
/osmium/version.hpp"
_libosmium_version_define REGEX
"#define LIBOSMIUM_VERSION_STRING"
)
if
(
"
${
_libosmium_version_define
}
"
MATCHES
"#define LIBOSMIUM_VERSION_STRING
\"
([0-9.]+)
\"
"
)
set
(
_libosmium_version
"
${
CMAKE_MATCH_1
}
"
)
...
...
debian/changelog
View file @
c177123c
libosmium (2.1
4.2-3) UNRELEASED
; urgency=medium
libosmium (2.1
5.0-1) unstable
; urgency=medium
* New upstream release.
* Bump Standards-Version to 4.2.1, no changes.
* Update watch file to limit matches to archive path.
-- Bas Couwenberg <sebastic@debian.org> Sat, 0
4 Aug
2018
14:46:45
+0
2
00
-- Bas Couwenberg <sebastic@debian.org> Sat, 0
8 Dec
2018
09:55:16
+0
1
00
libosmium (2.14.2-2) unstable; urgency=medium
...
...
include/gdalcpp.hpp
View file @
c177123c
...
...
@@ -5,11 +5,11 @@
C++11 wrapper classes for GDAL/OGR.
Version 1.
1.1
Version 1.
2.0
https://github.com/joto/gdalcpp
Copyright 2015 Jochen Topf <jochen@topf.org>
Copyright 2015
-2018
Jochen Topf <jochen@topf.org>
Boost Software License - Version 1.0 - August 17th, 2003
...
...
@@ -37,17 +37,19 @@ DEALINGS IN THE SOFTWARE.
*/
#include
<gdal_priv.h>
#include
<gdal_version.h>
#include
<ogr_api.h>
#include
<ogrsf_frmts.h>
#include
<cstdint>
#include
<algorithm>
#include
<memory>
#include
<stdexcept>
#include
<string>
#include
<utility>
#include
<vector>
#include
<gdal_priv.h>
#include
<gdal_version.h>
#include
<ogr_api.h>
#include
<ogrsf_frmts.h>
namespace
gdalcpp
{
#if GDAL_VERSION_MAJOR >= 2
...
...
@@ -85,23 +87,23 @@ namespace gdalcpp {
m_error
(
error
)
{
}
const
std
::
string
&
driver
()
const
{
const
std
::
string
&
driver
()
const
noexcept
{
return
m_driver
;
}
const
std
::
string
&
dataset
()
const
{
const
std
::
string
&
dataset
()
const
noexcept
{
return
m_dataset
;
}
const
std
::
string
&
layer
()
const
{
const
std
::
string
&
layer
()
const
noexcept
{
return
m_layer
;
}
const
std
::
string
&
field
()
const
{
const
std
::
string
&
field
()
const
noexcept
{
return
m_field
;
}
OGRErr
error
()
const
{
OGRErr
error
()
const
noexcept
{
return
m_error
;
}
...
...
@@ -111,18 +113,26 @@ namespace gdalcpp {
struct
init_wrapper
{
#if GDAL_VERSION_MAJOR >= 2
init_wrapper
()
{
GDALAllRegister
();
}
init_wrapper
()
noexcept
{
GDALAllRegister
();
}
#else
init_wrapper
()
{
OGRRegisterAll
();
}
~
init_wrapper
()
{
OGRCleanupAll
();
}
init_wrapper
()
noexcept
{
OGRRegisterAll
();
}
~
init_wrapper
()
noexcept
{
OGRCleanupAll
();
}
#endif
};
};
// struct init_wrapper
struct
init_library
{
init_library
()
{
static
init_wrapper
iw
;
}
};
};
// struct init_library
class
Driver
:
private
init_library
{
...
...
@@ -138,11 +148,13 @@ namespace gdalcpp {
m_driver
(
OGRSFDriverRegistrar
::
GetRegistrar
()
->
GetDriverByName
(
driver_name
.
c_str
()))
{
#endif
if
(
!
m_driver
)
{
throw
gdal_error
(
std
::
string
(
"unknown driver: '"
)
+
driver_name
+
"'"
,
OGRERR_NONE
,
driver_name
);
throw
gdal_error
{
std
::
string
{
"unknown driver: '"
}
+
driver_name
+
"'"
,
OGRERR_NONE
,
driver_name
};
}
}
gdal_driver_type
&
get
()
const
{
gdal_driver_type
&
get
()
const
noexcept
{
return
*
m_driver
;
}
...
...
@@ -155,14 +167,14 @@ namespace gdalcpp {
Options
(
const
std
::
vector
<
std
::
string
>&
options
)
:
m_options
(
options
),
m_ptrs
(
new
const
char
*
[
options
.
size
()
+
1
])
{
m_ptrs
(
new
const
char
*
[
options
.
size
()
+
1
])
{
std
::
transform
(
m_options
.
begin
(),
m_options
.
end
(),
m_ptrs
.
get
(),
[
&
](
const
std
::
string
&
s
)
{
return
s
.
data
();
});
m_ptrs
[
options
.
size
()]
=
nullptr
;
}
char
**
get
()
const
{
char
**
get
()
const
noexcept
{
return
const_cast
<
char
**>
(
m_ptrs
.
get
());
}
...
...
@@ -178,33 +190,37 @@ namespace gdalcpp {
SRS
()
:
m_spatial_reference
()
{
auto
result
=
m_spatial_reference
.
SetWellKnownGeogCS
(
"WGS84"
);
const
auto
result
=
m_spatial_reference
.
SetWellKnownGeogCS
(
"WGS84"
);
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"can not initialize spatial reference system WGS84"
),
result
);
throw
gdal_error
{
std
::
string
{
"can not initialize spatial reference system WGS84"
},
result
};
}
}
explicit
SRS
(
int
epsg
)
:
m_spatial_reference
()
{
auto
result
=
m_spatial_reference
.
importFromEPSG
(
epsg
);
const
auto
result
=
m_spatial_reference
.
importFromEPSG
(
epsg
);
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"can not initialize spatial reference system for EPSG:"
)
+
std
::
to_string
(
epsg
),
result
);
throw
gdal_error
{
std
::
string
{
"can not initialize spatial reference system for EPSG:"
}
+
std
::
to_string
(
epsg
),
result
};
}
}
explicit
SRS
(
const
char
*
name
)
:
m_spatial_reference
()
{
auto
result
=
m_spatial_reference
.
importFromProj4
(
name
);
const
auto
result
=
m_spatial_reference
.
importFromProj4
(
name
);
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"can not initialize spatial reference system '"
)
+
name
+
"'"
,
result
);
throw
gdal_error
{
std
::
string
{
"can not initialize spatial reference system '"
}
+
name
+
"'"
,
result
};
}
}
explicit
SRS
(
const
std
::
string
&
name
)
:
m_spatial_reference
()
{
auto
result
=
m_spatial_reference
.
importFromProj4
(
name
.
c_str
());
const
auto
result
=
m_spatial_reference
.
importFromProj4
(
name
.
c_str
());
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"can not initialize spatial reference system '"
)
+
name
+
"'"
,
result
);
throw
gdal_error
{
std
::
string
{
"can not initialize spatial reference system '"
}
+
name
+
"'"
,
result
};
}
}
...
...
@@ -212,11 +228,11 @@ namespace gdalcpp {
m_spatial_reference
(
spatial_reference
)
{
}
OGRSpatialReference
&
get
()
{
OGRSpatialReference
&
get
()
noexcept
{
return
m_spatial_reference
;
}
const
OGRSpatialReference
&
get
()
const
{
const
OGRSpatialReference
&
get
()
const
noexcept
{
return
m_spatial_reference
;
}
...
...
@@ -257,11 +273,14 @@ namespace gdalcpp {
m_dataset
(
detail
::
Driver
(
driver_name
).
get
().
CreateDataSource
(
dataset_name
.
c_str
(),
m_options
.
get
()))
{
#endif
if
(
!
m_dataset
)
{
throw
gdal_error
(
std
::
string
(
"failed to create dataset '"
)
+
dataset_name
+
"'"
,
OGRERR_NONE
,
driver_name
,
dataset_name
);
throw
gdal_error
{
std
::
string
{
"failed to create dataset '"
}
+
dataset_name
+
"'"
,
OGRERR_NONE
,
driver_name
,
dataset_name
};
}
}
~
Dataset
()
{
~
Dataset
()
noexcept
{
try
{
if
(
m_edit_count
>
0
)
{
commit_transaction
();
...
...
@@ -270,24 +289,24 @@ namespace gdalcpp {
}
}
const
std
::
string
&
driver_name
()
const
{
const
std
::
string
&
driver_name
()
const
noexcept
{
return
m_driver_name
;
}
const
std
::
string
&
dataset_name
()
const
{
const
std
::
string
&
dataset_name
()
const
noexcept
{
return
m_dataset_name
;
}
gdal_dataset_type
&
get
()
const
{
gdal_dataset_type
&
get
()
const
noexcept
{
return
*
m_dataset
;
}
SRS
&
srs
()
{
SRS
&
srs
()
noexcept
{
return
m_srs
;
}
void
exec
(
const
char
*
sql
)
{
auto
result
=
m_dataset
->
ExecuteSQL
(
sql
,
nullptr
,
nullptr
);
const
auto
result
=
m_dataset
->
ExecuteSQL
(
sql
,
nullptr
,
nullptr
);
if
(
result
)
{
m_dataset
->
ReleaseResultSet
(
result
);
}
...
...
@@ -334,7 +353,7 @@ namespace gdalcpp {
}
}
Dataset
&
enable_auto_transactions
(
uint64_t
edits
=
100000
)
{
Dataset
&
enable_auto_transactions
(
uint64_t
edits
=
100000
)
noexcept
{
m_max_edit_count
=
edits
;
return
*
this
;
}
...
...
@@ -362,20 +381,23 @@ namespace gdalcpp {
m_dataset
(
dataset
),
m_layer
(
dataset
.
get
().
CreateLayer
(
layer_name
.
c_str
(),
&
dataset
.
srs
().
get
(),
type
,
m_options
.
get
()))
{
if
(
!
m_layer
)
{
throw
gdal_error
(
std
::
string
(
"failed to create layer '"
)
+
layer_name
+
"'"
,
OGRERR_NONE
,
dataset
.
driver_name
(),
dataset
.
dataset_name
(),
layer_name
);
throw
gdal_error
{
std
::
string
{
"failed to create layer '"
}
+
layer_name
+
"'"
,
OGRERR_NONE
,
dataset
.
driver_name
(),
dataset
.
dataset_name
(),
layer_name
};
}
}
OGRLayer
&
get
()
{
OGRLayer
&
get
()
noexcept
{
return
*
m_layer
;
}
const
OGRLayer
&
get
()
const
{
const
OGRLayer
&
get
()
const
noexcept
{
return
*
m_layer
;
}
Dataset
&
dataset
()
const
{
Dataset
&
dataset
()
const
noexcept
{
return
m_dataset
;
}
...
...
@@ -389,8 +411,12 @@ namespace gdalcpp {
field
.
SetPrecision
(
precision
);
if
(
m_layer
->
CreateField
(
&
field
)
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"failed to create field '"
)
+
field_name
+
"' in layer '"
+
name
()
+
"'"
,
OGRERR_NONE
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
(),
field_name
);
throw
gdal_error
{
std
::
string
{
"failed to create field '"
}
+
field_name
+
"' in layer '"
+
name
()
+
"'"
,
OGRERR_NONE
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
(),
field_name
};
}
return
*
this
;
...
...
@@ -398,18 +424,25 @@ namespace gdalcpp {
void
create_feature
(
OGRFeature
*
feature
)
{
dataset
().
prepare_edit
();
OGRErr
result
=
m_layer
->
CreateFeature
(
feature
);
const
auto
result
=
m_layer
->
CreateFeature
(
feature
);
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"creating feature in layer '"
)
+
name
()
+
"' failed"
,
result
,
dataset
().
driver_name
(),
dataset
().
dataset_name
());
throw
gdal_error
{
std
::
string
{
"creating feature in layer '"
}
+
name
()
+
"' failed"
,
result
,
dataset
().
driver_name
(),
dataset
().
dataset_name
()};
}
dataset
().
finalize_edit
();
}
Layer
&
start_transaction
()
{
#if GDAL_VERSION_MAJOR < 2
OGRErr
result
=
m_layer
->
StartTransaction
();
const
auto
result
=
m_layer
->
StartTransaction
();
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"starting transaction on layer '"
)
+
name
()
+
"' failed"
,
result
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
());
throw
gdal_error
{
std
::
string
{
"starting transaction on layer '"
}
+
name
()
+
"' failed"
,
result
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
()};
}
#endif
return
*
this
;
...
...
@@ -417,9 +450,13 @@ namespace gdalcpp {
Layer
&
commit_transaction
()
{
#if GDAL_VERSION_MAJOR < 2
OGRErr
result
=
m_layer
->
CommitTransaction
();
const
auto
result
=
m_layer
->
CommitTransaction
();
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"committing transaction on layer '"
)
+
name
()
+
"' failed"
,
result
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
());
throw
gdal_error
{
std
::
string
{
"committing transaction on layer '"
}
+
name
()
+
"' failed"
,
result
,
m_dataset
.
driver_name
(),
m_dataset
.
dataset_name
(),
name
()};
}
#endif
return
*
this
;
...
...
@@ -446,11 +483,14 @@ namespace gdalcpp {
m_layer
(
layer
),
m_feature
(
OGRFeature
::
CreateFeature
(
m_layer
.
get
().
GetLayerDefn
()))
{
if
(
!
m_feature
)
{
throw
std
::
bad_alloc
()
;
throw
std
::
bad_alloc
{}
;
}
OGRErr
result
=
m_feature
->
SetGeometryDirectly
(
geometry
.
release
());
const
auto
result
=
m_feature
->
SetGeometryDirectly
(
geometry
.
release
());
if
(
result
!=
OGRERR_NONE
)
{
throw
gdal_error
(
std
::
string
(
"setting feature geometry in layer '"
)
+
m_layer
.
name
()
+
"' failed"
,
result
,
m_layer
.
dataset
().
driver_name
(),
m_layer
.
dataset
().
dataset_name
());
throw
gdal_error
{
std
::
string
{
"setting feature geometry in layer '"
}
+
m_layer
.
name
()
+
"' failed"
,
result
,
m_layer
.
dataset
().
driver_name
(),
m_layer
.
dataset
().
dataset_name
()};
}
}
...
...
@@ -458,13 +498,13 @@ namespace gdalcpp {
m_layer
.
create_feature
(
m_feature
.
get
());
}
template
<
class
T
>
template
<
typename
T
>
Feature
&
set_field
(
int
n
,
T
&&
arg
)
{
m_feature
->
SetField
(
n
,
std
::
forward
<
T
>
(
arg
));
return
*
this
;
}
template
<
class
T
>
template
<
typename
T
>
Feature
&
set_field
(
const
char
*
name
,
T
&&
arg
)
{
m_feature
->
SetField
(
name
,
std
::
forward
<
T
>
(
arg
));
return
*
this
;
...
...
include/osmium/area/detail/basic_assembler.hpp
View file @
c177123c
...
...
@@ -105,7 +105,9 @@ namespace osmium {
struct
slocation
{
static
constexpr
const
uint32_t
invalid_item
=
1u
<<
30u
;
enum
{
invalid_item
=
1u
<<
30u
};
uint32_t
item
:
31
;
uint32_t
reverse
:
1
;
...
...
include/osmium/area/detail/segment_list.hpp
View file @
c177123c
...
...
@@ -147,14 +147,14 @@ namespace osmium {
m_debug
(
debug
)
{
}
~
SegmentList
()
noexcept
=
default
;
SegmentList
(
const
SegmentList
&
)
=
delete
;
SegmentList
(
SegmentList
&&
)
=
delete
;
SegmentList
&
operator
=
(
const
SegmentList
&
)
=
delete
;
SegmentList
&
operator
=
(
SegmentList
&&
)
=
delete
;
~
SegmentList
()
noexcept
=
default
;
/// The number of segments in the list.
std
::
size_t
size
()
const
noexcept
{
return
m_segments
.
size
();
...
...
@@ -181,7 +181,7 @@ namespace osmium {
return
m_segments
[
n
];
}
NodeRefSegment
&
operator
[](
std
::
size_t
n
)
noexcept
{
NodeRefSegment
&
operator
[](
const
std
::
size_t
n
)
noexcept
{
assert
(
n
<
m_segments
.
size
());
return
m_segments
[
n
];
}
...
...
@@ -206,7 +206,7 @@ namespace osmium {
* Enable or disable debug output to stderr. This is used
* for debugging libosmium itself.
*/
void
enable_debug_output
(
bool
debug
=
true
)
noexcept
{
void
enable_debug_output
(
const
bool
debug
=
true
)
noexcept
{
m_debug
=
debug
;
}
...
...
include/osmium/area/geom_assembler.hpp
View file @
c177123c
...
...
@@ -68,8 +68,6 @@ namespace osmium {
detail
::
BasicAssembler
(
config
)
{
}
~
GeomAssembler
()
noexcept
=
default
;
/**
* Assemble an area from the given way.
*
...
...
include/osmium/area/multipolygon_collector.hpp
View file @
c177123c
...
...
@@ -85,8 +85,13 @@ namespace osmium {
area_stats
m_stats
;
static
constexpr
size_t
initial_output_buffer_size
=
1024
*
1024
;
static
constexpr
size_t
max_buffer_size_for_flush
=
100
*
1024
;
enum
{
initial_output_buffer_size
=
1024ul
*
1024ul
};
enum
{
max_buffer_size_for_flush
=
100ul
*
1024ul
};
void
flush_output_buffer
()
{
if
(
this
->
callback
())
{
...
...
include/osmium/builder/attr.hpp
View file @
c177123c
...
...
@@ -764,7 +764,7 @@ namespace osmium {
template
<
typename
TBuilder
,
typename
THandler
,
typename
...
TArgs
>
inline
typename
std
::
enable_if
<
is_handled_by
<
THandler
,
TArgs
...
>::
value
>::
type
add_list
(
osmium
::
builder
::
Builder
&
parent
,
const
TArgs
&
...
args
)
{
TBuilder
builder
(
parent
.
buffer
(),
&
parent
)
;
TBuilder
builder
{
parent
.
buffer
(),
&
parent
}
;
(
void
)
std
::
initializer_list
<
int
>
{
(
THandler
::
set_value
(
builder
,
args
),
0
)...
};
...
...
@@ -792,7 +792,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
any_node_handlers
,
TArgs
...
>::
value
,
"Attribute not allowed in add_node()"
);
{
NodeBuilder
builder
(
buffer
)
;
NodeBuilder
builder
{
buffer
}
;
detail
::
add_basic
<
detail
::
node_handler
>
(
builder
,
args
...);
detail
::
add_user
(
builder
,
args
...);
...
...
@@ -815,7 +815,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
any_way_handlers
,
TArgs
...
>::
value
,
"Attribute not allowed in add_way()"
);
{
WayBuilder
builder
(
buffer
)
;
WayBuilder
builder
{
buffer
}
;
detail
::
add_basic
<
detail
::
object_handler
>
(
builder
,
args
...);
detail
::
add_user
(
builder
,
args
...);
...
...
@@ -839,7 +839,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
any_relation_handlers
,
TArgs
...
>::
value
,
"Attribute not allowed in add_relation()"
);
{
RelationBuilder
builder
(
buffer
)
;
RelationBuilder
builder
{
buffer
}
;
detail
::
add_basic
<
detail
::
object_handler
>
(
builder
,
args
...);
detail
::
add_user
(
builder
,
args
...);
...
...
@@ -863,7 +863,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
any_changeset_handlers
,
TArgs
...
>::
value
,
"Attribute not allowed in add_changeset()"
);
{
ChangesetBuilder
builder
(
buffer
)
;
ChangesetBuilder
builder
{
buffer
}
;
detail
::
add_basic
<
detail
::
changeset_handler
>
(
builder
,
args
...);
detail
::
add_user
(
builder
,
args
...);
...
...
@@ -887,7 +887,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
any_area_handlers
,
TArgs
...
>::
value
,
"Attribute not allowed in add_area()"
);
{
AreaBuilder
builder
(
buffer
)
;
AreaBuilder
builder
{
buffer
}
;
detail
::
add_basic
<
detail
::
object_handler
>
(
builder
,
args
...);
detail
::
add_user
(
builder
,
args
...);
...
...
@@ -914,7 +914,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
nodes_handler
,
TArgs
...
>::
value
,
"Attribute not allowed in add_way_node_list()"
);
{
WayNodeListBuilder
builder
(
buffer
)
;
WayNodeListBuilder
builder
{
buffer
}
;
(
void
)
std
::
initializer_list
<
int
>
{
(
detail
::
nodes_handler
::
set_value
(
builder
,
args
),
0
)...
};
...
...
@@ -936,7 +936,7 @@ namespace osmium {
static_assert
(
detail
::
are_all_handled_by
<
detail
::
tags_handler
,
TArgs
...
>::
value
,
"Attribute not allowed in add_tag_list()"
);
{
TagListBuilder
builder
(
buffer
)
;
TagListBuilder
builder
{
buffer
}
;
(
void
)
std
::
initializer_list
<
int
>
{
(
detail
::
tags_handler
::
set_value
(
builder
,
args
),
0
)...
};
...
...
include/osmium/builder/builder.hpp
View file @
c177123c
...
...
@@ -65,7 +65,7 @@ namespace osmium {
explicit
Builder
(
osmium
::
memory
::
Buffer
&
buffer
,
Builder
*
parent
,
osmium
::
memory
::
item_size_type
size
)
:
m_buffer
(
buffer
),
m_parent
(
parent
),
m_item_offset
(
buffer
.
written
())
{
m_item_offset
(
buffer
.
written
()
-
buffer
.
committed
()
)
{
reserve_space
(
size
);
assert
(
buffer
.
is_aligned
());
if
(
m_parent
)
{
...
...
@@ -80,7 +80,7 @@ namespace osmium {
}
#ifdef NDEBUG
~
Builder
()
=
default
;
~
Builder
()
noexcept
=
default
;
#else
~
Builder
()
noexcept
{
m_buffer
.
decrement_builder_count
();
...
...
@@ -88,7 +88,7 @@ namespace osmium {
#endif
osmium
::
memory
::
Item
&
item
()
const
{
return
*
reinterpret_cast
<
osmium
::
memory
::
Item
*>
(
m_buffer
.
data
()
+
m_item_offset
);
return
*
reinterpret_cast
<
osmium
::
memory
::
Item
*>
(
m_buffer
.
data
()
+
m_buffer
.
committed
()
+
m_item_offset
);
}
unsigned
char
*
reserve_space
(
std
::
size_t
size
)
{
...
...
include/osmium/geom/tile.hpp
View file @
c177123c
...
...
@@ -98,6 +98,10 @@ namespace osmium {
*/
struct
Tile
{
enum
{
max_zoom
=
30u
};
/// x coordinate
uint32_t
x
;
...
...
@@ -119,7 +123,7 @@ namespace osmium {
x
(
tx
),
y
(
ty
),
z
(
zoom
)
{
assert
(
zoom
<=
30u
);
assert
(
zoom
<=
max_zoom
);
assert
(
x
<
num_tiles_in_zoom
(
zoom
));
assert
(
y
<
num_tiles_in_zoom
(
zoom
));
}
...
...
@@ -134,7 +138,7 @@ namespace osmium {
*/
explicit
Tile
(
uint32_t
zoom
,
const
osmium
::
Location
&
location
)
:
z
(
zoom
)
{
assert
(
zoom
<=
30u
);
assert
(
zoom
<=
max_zoom
);
assert
(
location
.
valid
());
const
auto
coordinates
=
lonlat_to_mercator
(
location
);
x
=
mercx_to_tilex
(
zoom
,
coordinates
.
x
);
...
...
@@ -151,7 +155,7 @@ namespace osmium {
*/
explicit
Tile
(
uint32_t
zoom
,
const
osmium
::
geom
::
Coordinates
&
coordinates
)
:
z
(
zoom
)
{
assert
(
zoom
<=
30u
);
assert
(
zoom
<=
max_zoom
);
x
=
mercx_to_tilex
(
zoom
,
coordinates
.
x
);
y
=
mercy_to_tiley
(
zoom
,
coordinates
.
y
);
}
...
...
@@ -162,7 +166,7 @@ namespace osmium {
* each be between 0 and 2^zoom-1.
*/
bool
valid
()
const
noexcept
{
if
(
z
>
30
)
{
if
(
z
>
max_zoom
)
{
return
false
;
}
const
auto
max
=
num_tiles_in_zoom
(
z
);
...
...
include/osmium/index/detail/mmap_vector_base.hpp
View file @
c177123c
...
...
@@ -46,7 +46,9 @@ namespace osmium {
namespace
detail
{
constexpr
size_t
mmap_vector_size_increment
=
1024
*
1024
;
enum
{
mmap_vector_size_increment
=
1024ul
*
1024ul
};
/**
* This is a base class for implementing classes that look like
...
...
@@ -58,12 +60,12 @@ namespace osmium {
protected:
size_t
m_size
=
0
;
std
::
size_t
m_size
=
0
;
osmium
::
TypedMemoryMapping
<
T
>
m_mapping
;
public:
mmap_vector_base
(
int
fd
,
size_t
capacity
,
size_t
size
=
0
)
:
mmap_vector_base
(
const
int
fd
,
const
std
::
size_t
capacity
,
const
std
::
size_t
size
=
0
)
:
m_size
(
size
),
m_mapping
(
capacity
,
osmium
::
MemoryMapping
::
mapping_mode
::
write_shared
,
fd
)
{
assert
(
size
<=
capacity
);
...
...
@@ -71,7 +73,7 @@ namespace osmium {
shrink_to_fit
();
}
explicit
mmap_vector_base
(
size_t
capacity
=
mmap_vector_size_increment
)
:
explicit
mmap_vector_base
(
const
std
::
size_t
capacity
=
mmap_vector_size_increment
)
:
m_mapping
(
capacity
)
{
std
::
fill_n
(
data
(),
capacity
,
osmium
::
index
::
empty_value
<
T
>
());
}
...
...
@@ -88,11 +90,11 @@ namespace osmium {
m_mapping
.
unmap
();
}
size_t
capacity
()
const
noexcept
{
std
::
size_t
capacity
()
const
noexcept
{
return
m_mapping
.
size
();
}
size_t
size
()
const
noexcept
{
std
::
size_t
size
()
const
noexcept
{
return
m_size
;
}
...
...
@@ -108,17 +110,17 @@ namespace osmium {
return
m_mapping
.
begin
();
}
const_reference
operator
[](
size_t
n
)
const
{
const_reference
operator
[](
const
std
::
size_t
n
)
const
{
assert
(
n
<
m_size
);
return
data
()[
n
];
}
reference
operator
[](
size_t
n
)
{
reference
operator
[](
const
std
::
size_t
n
)
{
assert
(
n
<
m_size
);
return
data
()[
n
];
}
value_type
at
(
size_t
n
)
const
{
value_type
at
(
const
std
::
size_t
n
)
const
{
if
(
n
>=
m_size
)
{
throw
std
::
out_of_range
{
"out of range"
};
}
...
...
@@ -140,17 +142,17 @@ namespace osmium {
data
()[
m_size
-
1
]
=
value
;
}
void
reserve
(
size_t
new_capacity
)
{
void
reserve
(
const
std
::
size_t
new_capacity
)
{
if
(
new_capacity
>
capacity
())
{
const
size_t
old_capacity
=
capacity
();
const
std
::
size_t
old_capacity
=
capacity
();
m_mapping
.
resize
(
new_capacity
);
std
::
fill
(
data
()
+
old_capacity
,
data
()
+
new_capacity
,
osmium
::
index
::
empty_value
<
value_type
>
());
}
}
void
resize
(
size_t
new_size
)
{
void
resize
(
const
std
::
size_t
new_size
)
{
if
(
new_size
>
capacity
())
{
reserve
(
new_size
+
osmium
::
detail
::
mmap_vector_size_increment
);
reserve
(
new_size
+
mmap_vector_size_increment
);
}
m_size
=
new_size
;
}
...
...
include/osmium/index/detail/mmap_vector_file.hpp
View file @
c177123c
...
...
@@ -53,7 +53,7 @@ namespace osmium {
template
<
typename
T
>
class
mmap_vector_file
:
public
mmap_vector_base
<
T
>
{
static
std
::
size_t
filesize
(
int
fd
)
{
static
std
::
size_t
filesize
(
const
int
fd
)
{
const
auto
size
=
osmium
::
file_size
(
fd
);
if
(
size
%
sizeof
(
T
)
!=
0
)
{
...
...
@@ -71,10 +71,10 @@ namespace osmium {
osmium
::
detail
::
mmap_vector_size_increment
)
{
}
explicit
mmap_vector_file
(
int
fd
)
:
explicit
mmap_vector_file
(
const
int
fd
)
:
mmap_vector_base
<
T
>
(
fd
,
std
::
max
(
osmium
::
detail
::
mmap_vector_size_increment
,
filesize
(
fd
)),
std
::
max
(
static_cast
<
std
::
size_t
>
(
mmap_vector_size_increment
)
,
filesize
(
fd
)),
filesize
(
fd
))
{
}
...
...
include/osmium/index/detail/vector_map.hpp
View file @
c177123c
...
...
@@ -39,8 +39,10 @@ DEALINGS IN THE SOFTWARE.
#include
<algorithm>
#include
<cstddef>
#include
<memory>
#include
<utility>
namespace
osmium
{
namespace
index
{
...
...
@@ -221,6 +223,26 @@ namespace osmium {
std
::
sort
(
m_vector
.
begin
(),
m_vector
.
end
());
}
void
dump_as_array
(
const
int
fd
)
final
{
constexpr
const
size_t
value_size
=
sizeof
(
TValue
);
constexpr
const
size_t
buffer_size
=
(
10L
*
1024L
*
1024L
)
/
value_size
;
std
::
unique_ptr
<
TValue
[]
>
output_buffer
{
new
TValue
[
buffer_size
]};
size_t
buffer_start_id
=
0
;
for
(
auto
it
=
cbegin
();
it
!=
cend
();)
{
std
::
fill_n
(
output_buffer
.
get
(),
buffer_size
,
osmium
::
index
::
empty_value
<
TValue
>
());
size_t
offset
=
0
;
for
(;
offset
<
buffer_size
&&
it
!=
end
();
++
offset
)
{
if
(
buffer_start_id
+
offset
==
it
->
first
)
{
output_buffer
[
offset
]
=
it
->
second
;
++
it
;
}
}
osmium
::
io
::
detail
::
reliable_write
(
fd
,
reinterpret_cast
<
const
unsigned
char
*>
(
output_buffer
.
get
()),
offset
*
value_size
);
buffer_start_id
+=
buffer_size
;
}
}
void
dump_as_list
(
const
int
fd
)
final
{
osmium
::
io
::
detail
::
reliable_write
(
fd
,
reinterpret_cast
<
const
char
*>
(
m_vector
.
data
()),
byte_size
());
}
...
...
include/osmium/index/id_set.hpp
View file @
c177123c
...
...
@@ -95,30 +95,44 @@ namespace osmium {
};
// class IdSet
template
<
typename
T
>
namespace
detail
{
// This value is a compromise. For node Ids it could be bigger
// which would mean less (but larger) memory allocations. For
// relations Ids it could be smaller, because they would all fit
// into a smaller allocation.
enum
:
std
::
size_t
{
default_chunk_bits
=
22u
};
}
// namespace detail
template
<
typename
T
,
std
::
size_t
chunk_bits
=
detail
::
default_chunk_bits
>
class
IdSetDense
;
/**
* Const_iterator for iterating over a IdSetDense.
*/
template
<
typename
T
>
template
<
typename
T
,
std
::
size_t
chunk_bits
>
class
IdSetDenseIterator
{
static_assert
(
std
::
is_unsigned
<
T
>::
value
,
"Needs unsigned type"
);
static_assert
(
sizeof
(
T
)
>=
4
,
"Needs at least 32bit type"
);
const
IdSetDense
<
T
>*
m_set
;
using
id_set
=
IdSetDense
<
T
,
chunk_bits
>
;
const
id_set
*
m_set
;
T
m_value
;
T
m_last
;
void
next
()
noexcept
{
while
(
m_value
!=
m_last
&&
!
m_set
->
get
(
m_value
))
{
const
T
cid
=
IdSetDense
<
T
>
::
chunk_id
(
m_value
);
const
T
cid
=
id_set
::
chunk_id
(
m_value
);
assert
(
cid
<
m_set
->
m_data
.
size
());
if
(
!
m_set
->
m_data
[
cid
])
{
m_value
=
(
cid
+
1
)
<<
(
IdSetDense
<
T
>::
chunk_bits
+
3
);
m_value
=
(
cid
+
1
)
<<
(
chunk_bits
+
3
);
}
else
{
const
auto
slot
=
m_set
->
m_data
[
cid
][
IdSetDense
<
T
>
::
offset
(
m_value
)];
const
auto
slot
=
m_set
->
m_data
[
cid
][
id_set
::
offset
(
m_value
)];
if
(
slot
==
0
)
{
m_value
+=
8
;
m_value
&=
~
0x7ull
;
...
...
@@ -136,14 +150,14 @@ namespace osmium {
using
pointer
=
value_type
*
;
using
reference
=
value_type
&
;
IdSetDenseIterator
(
const
IdSetDense
<
T
>
*
set
,
T
value
,
T
last
)
noexcept
:
IdSetDenseIterator
(
const
id_set
*
set
,
T
value
,
T
last
)
noexcept
:
m_set
(
set
),
m_value
(
value
),
m_last
(
last
)
{
next
();
}
IdSetDenseIterator
<
T
>
&
operator
++
()
noexcept
{
IdSetDenseIterator
&
operator
++
()
noexcept
{
if
(
m_value
!=
m_last
)
{
++
m_value
;
next
();
...
...
@@ -151,17 +165,17 @@ namespace osmium {
return
*
this
;
}
IdSetDenseIterator
<
T
>
operator
++
(
int
)
noexcept
{
IdSetDenseIterator
<
T
>
tmp
{
*
this
};
IdSetDenseIterator
operator
++
(
int
)
noexcept
{
IdSetDenseIterator
tmp
{
*
this
};
operator
++
();
return
tmp
;
}
bool
operator
==
(
const
IdSetDenseIterator
<
T
>
&
rhs
)
const
noexcept
{
bool
operator
==
(
const
IdSetDenseIterator
&
rhs
)
const
noexcept
{
return
m_set
==
rhs
.
m_set
&&
m_value
==
rhs
.
m_value
;
}
bool
operator
!=
(
const
IdSetDenseIterator
<
T
>
&
rhs
)
const
noexcept
{
bool
operator
!=
(
const
IdSetDenseIterator
&
rhs
)
const
noexcept
{
return
!
(
*
this
==
rhs
);
}
...
...
@@ -179,20 +193,17 @@ namespace osmium {
* and larger Id sets. If it is not used, no memory is allocated at
* all.
*/
template
<
typename
T
>
template
<
typename
T
,
std
::
size_t
chunk_bits
>
class
IdSetDense
:
public
IdSet
<
T
>
{
static_assert
(
std
::
is_unsigned
<
T
>::
value
,
"Needs unsigned type"
);
static_assert
(
sizeof
(
T
)
>=
4
,
"Needs at least 32bit type"
);
friend
class
IdSetDenseIterator
<
T
>
;
friend
class
IdSetDenseIterator
<
T
,
chunk_bits
>
;
// This value is a compromise. For node Ids it could be bigger
// which would mean less (but larger) memory allocations. For
// relations Ids it could be smaller, because they would all fit
// into a smaller allocation.
constexpr
static
const
std
::
size_t
chunk_bits
=
22u
;
constexpr
static
const
std
::
size_t
chunk_size
=
1u
<<
chunk_bits
;
enum
:
std
::
size_t
{
chunk_size
=
1u
<<
chunk_bits
};
std
::
vector
<
std
::
unique_ptr
<
unsigned
char
[]
>>
m_data
;
T
m_size
=
0
;
...
...
@@ -230,7 +241,7 @@ namespace osmium {
public
:
using
const_iterator
=
IdSetDenseIterator
<
T
>
;
using
const_iterator
=
IdSetDenseIterator
<
T
,
chunk_bits
>
;
IdSetDense
()
=
default
;
...
...
@@ -284,7 +295,7 @@ namespace osmium {
if
(
chunk_id
(
id
)
>=
m_data
.
size
())
{
return
false
;
}
auto
*
r
=
m_data
[
chunk_id
(
id
)].
get
();
const
auto
*
r
=
m_data
[
chunk_id
(
id
)].
get
();
if
(
!
r
)
{
return
false
;
}
...
...
@@ -317,11 +328,11 @@ namespace osmium {
return
m_data
.
size
()
*
chunk_size
;
}
IdSetDenseI
terator
<
T
>
begin
()
const
{
const_i
terator
begin
()
const
{
return
{
this
,
0
,
last
()};
}
IdSetDenseI
terator
<
T
>
end
()
const
{
const_i
terator
end
()
const
{
return
{
this
,
last
(),
last
()};
}
...
...
Prev
1
2
3
4
5
Next