[libosmium] 01/04: Imported Upstream version 2.12.1
Bas Couwenberg
sebastic at debian.org
Mon Apr 10 18:07:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch experimental
in repository libosmium.
commit 17c6b8893068761f6fa809d91ea43f8afd2eb123
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Mon Apr 10 19:53:34 2017 +0200
Imported Upstream version 2.12.1
---
CHANGELOG.md | 28 ++++++++++++++++++-
CMakeLists.txt | 8 ++++--
examples/osmium_change_tags.cpp | 2 +-
examples/osmium_dump_internal.cpp | 2 +-
examples/osmium_index_lookup.cpp | 6 ++--
include/osmium/handler/check_order.hpp | 41 +++++++++++++++++----------
include/osmium/io/writer.hpp | 5 ++++
include/osmium/memory/buffer.hpp | 20 +++++++------
include/osmium/object_pointer_collection.hpp | 3 +-
include/osmium/relations/collector.hpp | 5 ++++
include/osmium/tags/tags_filter.hpp | 8 ++++++
include/osmium/util/options.hpp | 5 ++--
include/osmium/version.hpp | 4 +--
test/data-tests/testcases/test-100.cpp | 23 +++++++++------
test/data-tests/testcases/test-101.cpp | 22 +++++++++------
test/data-tests/testcases/test-110.cpp | 19 ++++++++-----
test/t/geom/test_projection.cpp | 42 +++++++++++++++-------------
test/t/memory/test_buffer_basics.cpp | 24 ++++++++++++++--
18 files changed, 184 insertions(+), 83 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 011a169..02cda06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,31 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
+## [2.12.1] - 2017-04-10
+
+### Added
+
+- New `TagsFilter::set_default_result()` function.
+
+### Changed
+
+- Use larger capacity for `Buffer` if necessary for alignment instead of
+ throwing an exception. Minimum buffer size is now 64 bytes.
+- Check order of input data in relations collector. The relations collector
+ can not deal with history data or a changes file. This was documented as a
+ requirement, but often lead to problems, because this was ignored by users.
+ So it now checks that the input data it gets is ordered and throws an
+ exception otherwise.
+- When writing an OSM file, set generator to libosmium if not set by app.
+
+### Fixed
+
+- Infinite loop in `Buffer::reserve_space()`. (Issue #202.)
+- `ObjectPointerCollection::unique()` now removes elements at end.
+- Tests comparing double using `==` operator.
+- Build on Cygwin.
+
+
## [2.12.0] - 2017-03-07
### Added
@@ -581,7 +606,8 @@ This project adheres to [Semantic Versioning](http://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.12.0...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v2.12.1...HEAD
+[2.12.1]: https://github.com/osmcode/libosmium/compare/v2.12.0...v2.12.1
[2.12.0]: https://github.com/osmcode/libosmium/compare/v2.11.0...v2.12.0
[2.11.0]: https://github.com/osmcode/libosmium/compare/v2.10.3...v2.11.0
[2.10.3]: https://github.com/osmcode/libosmium/compare/v2.10.2...v2.10.3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13de6a2..c570fb3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ project(libosmium)
set(LIBOSMIUM_VERSION_MAJOR 2)
set(LIBOSMIUM_VERSION_MINOR 12)
-set(LIBOSMIUM_VERSION_PATCH 0)
+set(LIBOSMIUM_VERSION_PATCH 1)
set(LIBOSMIUM_VERSION
"${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
@@ -184,7 +184,11 @@ endif()
#-----------------------------------------------------------------------------
if(NOT MSVC)
if(NOT USE_CPP_VERSION)
- set(USE_CPP_VERSION c++11)
+ if(CYGWIN)
+ set(USE_CPP_VERSION gnu++11)
+ else()
+ set(USE_CPP_VERSION c++11)
+ endif()
endif()
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
# following only available from cmake 2.8.12:
diff --git a/examples/osmium_change_tags.cpp b/examples/osmium_change_tags.cpp
index a7c1904..216d730 100644
--- a/examples/osmium_change_tags.cpp
+++ b/examples/osmium_change_tags.cpp
@@ -91,7 +91,7 @@ class RewriteHandler : public osmium::handler::Handler {
public:
// Constructor. New data will be added to the given buffer.
- RewriteHandler(osmium::memory::Buffer& buffer) :
+ explicit RewriteHandler(osmium::memory::Buffer& buffer) :
m_buffer(buffer) {
}
diff --git a/examples/osmium_dump_internal.cpp b/examples/osmium_dump_internal.cpp
index dbc50db..e1656ef 100644
--- a/examples/osmium_dump_internal.cpp
+++ b/examples/osmium_dump_internal.cpp
@@ -66,7 +66,7 @@ class IndexFile {
public:
- IndexFile(const std::string& filename) :
+ explicit IndexFile(const std::string& filename) :
m_fd(::open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666)) {
if (m_fd < 0) {
std::cerr << "Can't open index file '" << filename << "': " << std::strerror(errno) << "\n";
diff --git a/examples/osmium_index_lookup.cpp b/examples/osmium_index_lookup.cpp
index 01d7e36..c7f2bb4 100644
--- a/examples/osmium_index_lookup.cpp
+++ b/examples/osmium_index_lookup.cpp
@@ -52,7 +52,7 @@ class IndexAccess {
public:
- IndexAccess(int fd) :
+ explicit IndexAccess(int fd) :
m_fd(fd) {
}
@@ -83,7 +83,7 @@ class IndexAccessDense : public IndexAccess<TValue> {
public:
- IndexAccessDense(int fd) :
+ explicit IndexAccessDense(int fd) :
IndexAccess<TValue>(fd) {
}
@@ -122,7 +122,7 @@ class IndexAccessSparse : public IndexAccess<TValue> {
public:
- IndexAccessSparse(int fd) :
+ explicit IndexAccessSparse(int fd) :
IndexAccess<TValue>(fd) {
}
diff --git a/include/osmium/handler/check_order.hpp b/include/osmium/handler/check_order.hpp
index 11995d7..46411da 100644
--- a/include/osmium/handler/check_order.hpp
+++ b/include/osmium/handler/check_order.hpp
@@ -51,12 +51,16 @@ namespace osmium {
*/
struct out_of_order_error : public std::runtime_error {
- explicit out_of_order_error(const std::string& what) :
- std::runtime_error(what) {
+ osmium::object_id_type object_id;
+
+ explicit out_of_order_error(const std::string& what, osmium::object_id_type id) :
+ std::runtime_error(what),
+ object_id(id) {
}
- explicit out_of_order_error(const char* what) :
- std::runtime_error(what) {
+ explicit out_of_order_error(const char* what, osmium::object_id_type id) :
+ std::runtime_error(what),
+ object_id(id) {
}
}; // struct out_of_order_error
@@ -72,7 +76,7 @@ namespace osmium {
* IDs have to be unique for each type. This check will fail for
* history files.
*
- * To use this add a CheckOrder member variable to your handler and
+ * To use this, add a CheckOrder member variable to your handler and
* call the node(), way(), and relation() methods from your node(),
* way(), and relations() handlers, respectively. An out_of_order_error
* exception will be thrown when the input is not in order.
@@ -87,32 +91,41 @@ namespace osmium {
void node(const osmium::Node& node) {
if (m_max_way_id > 0) {
- throw out_of_order_error("Found a node after a way.");
+ throw out_of_order_error{"Found a node after a way.", node.id()};
}
if (m_max_relation_id > 0) {
- throw out_of_order_error("Found a node after a relation.");
+ throw out_of_order_error{"Found a node after a relation.", node.id()};
}
- if (m_max_node_id >= node.id()) {
- throw out_of_order_error("Node IDs out of order.");
+ if (m_max_node_id == node.id()) {
+ throw out_of_order_error{"Node ID twice in input. Maybe you are using a history or changes file?", node.id()};
+ }
+ if (m_max_node_id > node.id()) {
+ throw out_of_order_error{"Node IDs out of order.", node.id()};
}
m_max_node_id = node.id();
}
void way(const osmium::Way& way) {
if (m_max_relation_id > 0) {
- throw out_of_order_error("Found a way after a relation.");
+ throw out_of_order_error{"Found a way after a relation.", way.id()};
}
- if (m_max_way_id >= way.id()) {
- throw out_of_order_error("Way IDs out of order.");
+ if (m_max_way_id == way.id()) {
+ throw out_of_order_error{"Way ID twice in input. Maybe you are using a history or changes file?", way.id()};
+ }
+ if (m_max_way_id > way.id()) {
+ throw out_of_order_error{"Way IDs out of order.", way.id()};
}
m_max_way_id = way.id();
}
void relation(const osmium::Relation& relation) {
- if (m_max_relation_id >= relation.id()) {
- throw out_of_order_error("Relation IDs out of order.");
+ if (m_max_relation_id == relation.id()) {
+ throw out_of_order_error{"Relation ID twice in input. Maybe you are using a history or changes file?", relation.id()};
+ }
+ if (m_max_relation_id > relation.id()) {
+ throw out_of_order_error{"Relation IDs out of order.", relation.id()};
}
m_max_relation_id = relation.id();
}
diff --git a/include/osmium/io/writer.hpp b/include/osmium/io/writer.hpp
index 043f68f..f38a706 100644
--- a/include/osmium/io/writer.hpp
+++ b/include/osmium/io/writer.hpp
@@ -55,6 +55,7 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/memory/buffer.hpp>
#include <osmium/thread/util.hpp>
#include <osmium/util/config.hpp>
+#include <osmium/version.hpp>
namespace osmium {
@@ -224,6 +225,10 @@ namespace osmium {
(set_option(options, args), 0)...
};
+ if (options.header.get("generator") == "") {
+ options.header.set("generator", "libosmium/" LIBOSMIUM_VERSION_STRING);
+ }
+
std::unique_ptr<osmium::io::Compressor> compressor =
CompressionFactory::instance().create_compressor(file.compression(),
osmium::io::detail::open_for_writing(m_file.filename(), options.allow_overwrite),
diff --git a/include/osmium/memory/buffer.hpp b/include/osmium/memory/buffer.hpp
index 370d01e..48d8409 100644
--- a/include/osmium/memory/buffer.hpp
+++ b/include/osmium/memory/buffer.hpp
@@ -119,6 +119,15 @@ namespace osmium {
auto_grow m_auto_grow{auto_grow::no};
std::function<void(Buffer&)> m_full;
+ static size_t calculate_capacity(size_t capacity) noexcept {
+ // The majority of all Nodes will fit into this size.
+ constexpr static const size_t min_capacity = 64;
+ if (capacity < min_capacity) {
+ return min_capacity;
+ }
+ return padded_length(capacity);
+ }
+
public:
/**
@@ -191,22 +200,17 @@ namespace osmium {
* is destroyed.
*
* @param capacity The (initial) size of the memory for this buffer.
+ * Actual capacity might be larger tue to alignment.
* @param auto_grow Should this buffer automatically grow when it
* becomes to small?
- *
- * @throws std::invalid_argument if the capacity isn't a multiple
- * of the alignment.
*/
explicit Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes) :
- m_memory(new unsigned char[capacity]),
+ m_memory(new unsigned char[calculate_capacity(capacity)]),
m_data(m_memory.get()),
- m_capacity(capacity),
+ m_capacity(calculate_capacity(capacity)),
m_written(0),
m_committed(0),
m_auto_grow(auto_grow) {
- if (capacity % align_bytes != 0) {
- throw std::invalid_argument("buffer capacity needs to be multiple of alignment");
- }
}
// buffers can not be copied
diff --git a/include/osmium/object_pointer_collection.hpp b/include/osmium/object_pointer_collection.hpp
index 7f79ebf..bc94ec6 100644
--- a/include/osmium/object_pointer_collection.hpp
+++ b/include/osmium/object_pointer_collection.hpp
@@ -98,7 +98,8 @@ namespace osmium {
*/
template <typename TEqual>
void unique(TEqual&& equal) {
- std::unique(m_objects.begin(), m_objects.end(), std::forward<TEqual>(equal));
+ const auto last = std::unique(m_objects.begin(), m_objects.end(), std::forward<TEqual>(equal));
+ m_objects.erase(last, m_objects.end());
}
/**
diff --git a/include/osmium/relations/collector.hpp b/include/osmium/relations/collector.hpp
index ee17d47..dfb6da8 100644
--- a/include/osmium/relations/collector.hpp
+++ b/include/osmium/relations/collector.hpp
@@ -48,6 +48,7 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/relation.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/handler.hpp>
+#include <osmium/handler/check_order.hpp>
#include <osmium/memory/buffer.hpp>
#include <osmium/util/iterator.hpp>
#include <osmium/visitor.hpp>
@@ -124,6 +125,7 @@ namespace osmium {
*/
class HandlerPass2 : public osmium::handler::Handler {
+ osmium::handler::CheckOrder m_check_order;
TCollector& m_collector;
public:
@@ -134,6 +136,7 @@ namespace osmium {
void node(const osmium::Node& node) {
if (TNodes) {
+ m_check_order.node(node);
if (! m_collector.find_and_add_object(node)) {
m_collector.node_not_in_any_relation(node);
}
@@ -142,6 +145,7 @@ namespace osmium {
void way(const osmium::Way& way) {
if (TWays) {
+ m_check_order.way(way);
if (! m_collector.find_and_add_object(way)) {
m_collector.way_not_in_any_relation(way);
}
@@ -150,6 +154,7 @@ namespace osmium {
void relation(const osmium::Relation& relation) {
if (TRelations) {
+ m_check_order.relation(relation);
if (! m_collector.find_and_add_object(relation)) {
m_collector.relation_not_in_any_relation(relation);
}
diff --git a/include/osmium/tags/tags_filter.hpp b/include/osmium/tags/tags_filter.hpp
index f91c589..85d763e 100644
--- a/include/osmium/tags/tags_filter.hpp
+++ b/include/osmium/tags/tags_filter.hpp
@@ -79,6 +79,14 @@ namespace osmium {
}
/**
+ * Set the default result, the result the matching function will
+ * return if none of the rules matched.
+ */
+ void set_default_result(bool default_result) noexcept {
+ m_default_result = default_result;
+ }
+
+ /**
* Add a rule to the filter.
*
* @param result The result returned when this rule matches.
diff --git a/include/osmium/util/options.hpp b/include/osmium/util/options.hpp
index ddc1138..7b23652 100644
--- a/include/osmium/util/options.hpp
+++ b/include/osmium/util/options.hpp
@@ -107,14 +107,13 @@ namespace osmium {
* contains no equal sign, the whole string is the key and it will
* be set to "true".
*/
- void set(std::string data) {
+ void set(const std::string& data) {
const size_t pos = data.find_first_of('=');
if (pos == std::string::npos) {
m_options[data] = "true";
} else {
std::string value = data.substr(pos+1);
- data.erase(pos);
- set(data, value);
+ set(data.substr(0, pos), value);
}
}
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index c5e8204..d5f88b5 100644
--- a/include/osmium/version.hpp
+++ b/include/osmium/version.hpp
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
#define LIBOSMIUM_VERSION_MAJOR 2
#define LIBOSMIUM_VERSION_MINOR 12
-#define LIBOSMIUM_VERSION_PATCH 0
+#define LIBOSMIUM_VERSION_PATCH 1
-#define LIBOSMIUM_VERSION_STRING "2.12.0"
+#define LIBOSMIUM_VERSION_STRING "2.12.1"
#endif // OSMIUM_VERSION_HPP
diff --git a/test/data-tests/testcases/test-100.cpp b/test/data-tests/testcases/test-100.cpp
index feafe77..df61642 100644
--- a/test/data-tests/testcases/test-100.cpp
+++ b/test/data-tests/testcases/test-100.cpp
@@ -1,4 +1,8 @@
+#include <cmath>
+#include <cstring>
+#include <stdexcept>
+
#include "common.hpp"
class TestHandler100 : public osmium::handler::Handler {
@@ -9,17 +13,18 @@ public:
osmium::handler::Handler() {
}
- void node(osmium::Node& node) {
+ void node(const osmium::Node& node) {
+ constexpr const double epsilon = 0.00000001;
if (node.id() == 100000) {
REQUIRE(node.version() == 1);
- REQUIRE(node.timestamp() == osmium::Timestamp("2014-01-01T00:00:00Z"));
+ REQUIRE(node.timestamp() == osmium::Timestamp{"2014-01-01T00:00:00Z"});
REQUIRE(node.uid() == 1);
- REQUIRE(!strcmp(node.user(), "test"));
+ REQUIRE(!std::strcmp(node.user(), "test"));
REQUIRE(node.changeset() == 1);
- REQUIRE(node.location().lon() == 1.02);
- REQUIRE(node.location().lat() == 1.02);
+ REQUIRE(std::abs(node.location().lon() - 1.02) < epsilon);
+ REQUIRE(std::abs(node.location().lat() - 1.02) < epsilon);
} else {
- throw std::runtime_error("Unknown ID");
+ throw std::runtime_error{"Unknown ID"};
}
}
@@ -28,10 +33,10 @@ public:
TEST_CASE("100") {
SECTION("test 100") {
- osmium::io::Reader reader(dirname + "/1/100/data.osm");
+ osmium::io::Reader reader{dirname + "/1/100/data.osm"};
- CheckBasicsHandler check_basics_handler(100, 1, 0, 0);
- CheckWKTHandler check_wkt_handler(dirname, 100);
+ CheckBasicsHandler check_basics_handler{100, 1, 0, 0};
+ CheckWKTHandler check_wkt_handler{dirname, 100};
TestHandler100 test_handler;
osmium::apply(reader, check_basics_handler, check_wkt_handler, test_handler);
diff --git a/test/data-tests/testcases/test-101.cpp b/test/data-tests/testcases/test-101.cpp
index de2a5fd..1693a71 100644
--- a/test/data-tests/testcases/test-101.cpp
+++ b/test/data-tests/testcases/test-101.cpp
@@ -1,4 +1,7 @@
+#include <cmath>
+#include <stdexcept>
+
#include "common.hpp"
class TestHandler101 : public osmium::handler::Handler {
@@ -9,19 +12,20 @@ public:
osmium::handler::Handler() {
}
- void node(osmium::Node& node) {
+ void node(const osmium::Node& node) {
+ constexpr const double epsilon = 0.00000001;
if (node.id() == 101000) {
REQUIRE(node.version() == 1);
- REQUIRE(node.location().lon() == 1.12);
- REQUIRE(node.location().lat() == 1.02);
+ REQUIRE(std::abs(node.location().lon() - 1.12) < epsilon);
+ REQUIRE(std::abs(node.location().lat() - 1.02) < epsilon);
} else if (node.id() == 101001) {
REQUIRE(node.version() == 1);
- REQUIRE(node.location().lon() == 1.12);
- REQUIRE(node.location().lat() == 1.03);
+ REQUIRE(std::abs(node.location().lon() - 1.12) < epsilon);
+ REQUIRE(std::abs(node.location().lat() - 1.03) < epsilon);
} else if (node.id() == 101002) {
} else if (node.id() == 101003) {
} else {
- throw std::runtime_error("Unknown ID");
+ throw std::runtime_error{"Unknown ID"};
}
}
@@ -30,10 +34,10 @@ public:
TEST_CASE("101") {
SECTION("test 101") {
- osmium::io::Reader reader(dirname + "/1/101/data.osm");
+ osmium::io::Reader reader{dirname + "/1/101/data.osm"};
- CheckBasicsHandler check_basics_handler(101, 4, 0, 0);
- CheckWKTHandler check_wkt_handler(dirname, 101);
+ CheckBasicsHandler check_basics_handler{101, 4, 0, 0};
+ CheckWKTHandler check_wkt_handler{dirname, 101};
TestHandler101 test_handler;
osmium::apply(reader, check_basics_handler, check_wkt_handler, test_handler);
diff --git a/test/data-tests/testcases/test-110.cpp b/test/data-tests/testcases/test-110.cpp
index 16b039b..72fbb4d 100644
--- a/test/data-tests/testcases/test-110.cpp
+++ b/test/data-tests/testcases/test-110.cpp
@@ -1,4 +1,8 @@
+#include <cmath>
+#include <cstring>
+#include <stdexcept>
+
#include "common.hpp"
class TestHandler110 : public osmium::handler::Handler {
@@ -10,14 +14,15 @@ public:
}
void node(const osmium::Node& node) {
+ constexpr const double epsilon = 0.00000001;
if (node.id() == 110000) {
- REQUIRE(node.location().lon() == 1.02);
- REQUIRE(node.location().lat() == 1.12);
+ REQUIRE(std::abs(node.location().lon() - 1.02) < epsilon);
+ REQUIRE(std::abs(node.location().lat() - 1.12) < epsilon);
} else if (node.id() == 110001) {
- REQUIRE(node.location().lon() == 1.07);
- REQUIRE(node.location().lat() == 1.13);
+ REQUIRE(std::abs(node.location().lon() - 1.07) < epsilon);
+ REQUIRE(std::abs(node.location().lat() - 1.13) < epsilon);
} else {
- throw std::runtime_error("Unknown ID");
+ throw std::runtime_error{"Unknown ID"};
}
}
@@ -29,9 +34,9 @@ public:
const char *test_id = way.tags().get_value_by_key("test:id");
REQUIRE(test_id);
- REQUIRE(!strcmp(test_id, "110"));
+ REQUIRE(!std::strcmp(test_id, "110"));
} else {
- throw std::runtime_error("Unknown ID");
+ throw std::runtime_error{"Unknown ID"};
}
}
diff --git a/test/t/geom/test_projection.cpp b/test/t/geom/test_projection.cpp
index ab6a004..df5c095 100644
--- a/test/t/geom/test_projection.cpp
+++ b/test/t/geom/test_projection.cpp
@@ -19,7 +19,8 @@ TEST_CASE("Projection 4326") {
const osmium::Location loc{1.0, 2.0};
const osmium::geom::Coordinates c{1.0, 2.0};
- REQUIRE(c == projection(loc));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
TEST_CASE("Projection 4326 from init string") {
@@ -29,7 +30,8 @@ TEST_CASE("Projection 4326 from init string") {
const osmium::Location loc{1.0, 2.0};
const osmium::geom::Coordinates c{1.0, 2.0};
- REQUIRE(c == projection(loc));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
TEST_CASE("Creating projection from unknown init string") {
@@ -48,29 +50,29 @@ TEST_CASE("Projection 3857") {
SECTION("Zero coordinates") {
const osmium::Location loc{0.0, 0.0};
const osmium::geom::Coordinates c{0.0, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Max longitude") {
const osmium::Location loc{180.0, 0.0};
const osmium::geom::Coordinates c{20037508.34, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Min longitude") {
const osmium::Location loc{-180.0, 0.0};
const osmium::geom::Coordinates c{-20037508.34, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Max latitude") {
const osmium::Location loc{0.0, 85.0511288};
const osmium::geom::Coordinates c{0.0, 20037508.34};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
}
@@ -80,29 +82,29 @@ TEST_CASE("MercatorProjection") {
SECTION("Zero coordinates") {
const osmium::Location loc{0.0, 0.0};
const osmium::geom::Coordinates c{0.0, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Max longitude") {
const osmium::Location loc{180.0, 0.0};
const osmium::geom::Coordinates c{20037508.34, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Min longitude") {
const osmium::Location loc{-180.0, 0.0};
const osmium::geom::Coordinates c{-20037508.34, 0.0};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
SECTION("Max latitude") {
const osmium::Location loc{0.0, 85.0511288};
const osmium::geom::Coordinates c{0.0, 20037508.34};
- REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.1));
- REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.1));
+ REQUIRE(projection(loc).x == Approx(c.x).epsilon(0.00001));
+ REQUIRE(projection(loc).y == Approx(c.y).epsilon(0.00001));
}
}
@@ -118,8 +120,8 @@ TEST_CASE("Compare mercator implementations") {
for (int n = 0; n < 10000; ++n) {
const osmium::Location loc{dis_x(gen), dis_y(gen)};
- REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.1));
- REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.1));
+ REQUIRE(projection_merc(loc).x == Approx(projection_3857(loc).x).epsilon(0.00001));
+ REQUIRE(projection_merc(loc).y == Approx(projection_3857(loc).y).epsilon(0.00001));
}
}
diff --git a/test/t/memory/test_buffer_basics.cpp b/test/t/memory/test_buffer_basics.cpp
index ffe7251..9e230de 100644
--- a/test/t/memory/test_buffer_basics.cpp
+++ b/test/t/memory/test_buffer_basics.cpp
@@ -6,8 +6,8 @@ TEST_CASE("Buffer basics") {
osmium::memory::Buffer invalid_buffer1;
osmium::memory::Buffer invalid_buffer2;
- osmium::memory::Buffer empty_buffer1(1024);
- osmium::memory::Buffer empty_buffer2(2048);
+ osmium::memory::Buffer empty_buffer1{1024};
+ osmium::memory::Buffer empty_buffer2{2048};
REQUIRE(!invalid_buffer1);
REQUIRE(!invalid_buffer2);
@@ -32,3 +32,23 @@ TEST_CASE("Buffer basics") {
}
+TEST_CASE("Buffer with zero size") {
+ osmium::memory::Buffer buffer{0};
+ REQUIRE(buffer.capacity() == 64);
+}
+
+TEST_CASE("Buffer with less than minimum size") {
+ osmium::memory::Buffer buffer{63};
+ REQUIRE(buffer.capacity() == 64);
+}
+
+TEST_CASE("Buffer with minimum size") {
+ osmium::memory::Buffer buffer{64};
+ REQUIRE(buffer.capacity() == 64);
+}
+
+TEST_CASE("Buffer with non-aligned size") {
+ osmium::memory::Buffer buffer{65};
+ REQUIRE(buffer.capacity() > 65);
+}
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/libosmium.git
More information about the Pkg-grass-devel
mailing list