#include #include #include #include #include #include #include #include #include #include #include #include namespace { void test_simple_and_valid(const mapnik::geometry::geometry &geom) { // only Boost >= 1.56 has is_valid and is_simple #if BOOST_VERSION >= 105600 BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(geom)); #endif } } int main(int argc, char** argv) { std::vector args; for (int i=1;i geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob, sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]), mapnik::wkbSpatiaLite); // winding order is not correct per OGC so we'll fix it mapnik::geometry::correct(geom); test_simple_and_valid(geom); geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob, sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]), mapnik::wkbAuto); mapnik::geometry::correct(geom); test_simple_and_valid(geom); geom = mapnik::geometry_utils::from_wkb((const char*)sp_invalid_blob, sizeof(sp_invalid_blob) / sizeof(sp_invalid_blob[0]), mapnik::wkbAuto); BOOST_TEST(geom.is()); // returns geometry_empty // sqlite generic wkb blob geom = mapnik::geometry_utils::from_wkb((const char*)sq_valid_blob, sizeof(sq_valid_blob) / sizeof(sq_valid_blob[0]), mapnik::wkbGeneric); test_simple_and_valid(geom); geom = mapnik::geometry_utils::from_wkb( (const char*)sq_valid_blob, sizeof(sq_valid_blob) / sizeof(sq_valid_blob[0]), mapnik::wkbAuto); test_simple_and_valid(geom); geom = mapnik::geometry_utils::from_wkb((const char*)sq_invalid_blob, sizeof(sq_invalid_blob) / sizeof(sq_invalid_blob[0]), mapnik::wkbGeneric); BOOST_TEST(geom.is()); // returns geometry_empty } catch (std::exception const& ex) { BOOST_TEST(false); std::clog << "threw: " << ex.what() << "\n"; } if (!::boost::detail::test_errors()) { if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; else std::clog << "C++ WKB formats test: \x1b[1;32m✓ \x1b[0m\n"; ::boost::detail::report_errors_remind().called_report_errors_function = true; } else { return ::boost::report_errors(); } }