Merge commit '6eb4f090f98f6b17a23c57768c16b7716b6c9cbd' as 'third_party/libosmium'
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
class TestHandler100 : public osmium::handler::Handler {
|
||||
|
||||
public:
|
||||
|
||||
TestHandler100() :
|
||||
osmium::handler::Handler() {
|
||||
}
|
||||
|
||||
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.uid() == 1);
|
||||
REQUIRE(!std::strcmp(node.user(), "test"));
|
||||
REQUIRE(node.changeset() == 1);
|
||||
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"};
|
||||
}
|
||||
}
|
||||
|
||||
}; // class TestHandler100
|
||||
|
||||
TEST_CASE("100") {
|
||||
|
||||
SECTION("test 100") {
|
||||
osmium::io::Reader reader{dirname + "/1/100/data.osm"};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
class TestHandler101 : public osmium::handler::Handler {
|
||||
|
||||
public:
|
||||
|
||||
TestHandler101() :
|
||||
osmium::handler::Handler() {
|
||||
}
|
||||
|
||||
void node(const osmium::Node& node) {
|
||||
constexpr const double epsilon = 0.00000001;
|
||||
if (node.id() == 101000) {
|
||||
REQUIRE(node.version() == 1);
|
||||
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(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"};
|
||||
}
|
||||
}
|
||||
|
||||
}; // class TestHandler101
|
||||
|
||||
TEST_CASE("101") {
|
||||
|
||||
SECTION("test 101") {
|
||||
osmium::io::Reader reader{dirname + "/1/101/data.osm"};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
class TestHandler110 : public osmium::handler::Handler {
|
||||
|
||||
public:
|
||||
|
||||
TestHandler110() :
|
||||
osmium::handler::Handler() {
|
||||
}
|
||||
|
||||
void node(const osmium::Node& node) {
|
||||
constexpr const double epsilon = 0.00000001;
|
||||
if (node.id() == 110000) {
|
||||
REQUIRE(std::abs(node.location().lon() - 1.02) < epsilon);
|
||||
REQUIRE(std::abs(node.location().lat() - 1.12) < epsilon);
|
||||
} else if (node.id() == 110001) {
|
||||
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"};
|
||||
}
|
||||
}
|
||||
|
||||
void way(const osmium::Way& way) {
|
||||
if (way.id() == 110800) {
|
||||
REQUIRE(way.version() == 1);
|
||||
REQUIRE(way.nodes().size() == 2);
|
||||
REQUIRE(!way.is_closed());
|
||||
|
||||
const char *test_id = way.tags().get_value_by_key("test:id");
|
||||
REQUIRE(test_id);
|
||||
REQUIRE(!std::strcmp(test_id, "110"));
|
||||
} else {
|
||||
throw std::runtime_error{"Unknown ID"};
|
||||
}
|
||||
}
|
||||
|
||||
}; // class TestHandler110
|
||||
|
||||
TEST_CASE("110") {
|
||||
|
||||
SECTION("test 110") {
|
||||
osmium::io::Reader reader(dirname + "/1/110/data.osm");
|
||||
|
||||
index_pos_type index_pos;
|
||||
index_neg_type index_neg;
|
||||
location_handler_type location_handler(index_pos, index_neg);
|
||||
location_handler.ignore_errors();
|
||||
|
||||
CheckBasicsHandler check_basics_handler(110, 2, 1, 0);
|
||||
CheckWKTHandler check_wkt_handler(dirname, 110);
|
||||
TestHandler110 test_handler;
|
||||
|
||||
osmium::apply(reader, location_handler, check_basics_handler, check_wkt_handler, test_handler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user