#include #include #include #include #include #include #include #include #include #include #include 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); BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(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); BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(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); BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(geom)); geom = mapnik::geometry_utils::from_wkb( (const char*)sq_valid_blob, sizeof(sq_valid_blob) / sizeof(sq_valid_blob[0]), mapnik::wkbAuto); BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(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(); } }