2013-04-09 08:38:48 +02:00
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include <mapnik/params.hpp>
|
|
|
|
#include <mapnik/wkb.hpp>
|
|
|
|
#include <mapnik/feature.hpp>
|
|
|
|
#include <mapnik/feature_factory.hpp>
|
2013-05-25 02:21:55 +02:00
|
|
|
#include <vector>
|
2013-05-26 01:04:40 +02:00
|
|
|
#include <algorithm>
|
2013-04-09 08:38:48 +02:00
|
|
|
|
|
|
|
|
2013-05-25 02:21:55 +02:00
|
|
|
int main(int argc, char** argv)
|
2013-04-09 08:38:48 +02:00
|
|
|
{
|
2013-05-25 02:21:55 +02:00
|
|
|
std::vector<std::string> args;
|
|
|
|
for (int i=1;i<argc;++i)
|
|
|
|
{
|
|
|
|
args.push_back(argv[i]);
|
|
|
|
}
|
|
|
|
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
|
|
|
|
2013-04-09 08:38:48 +02:00
|
|
|
unsigned char sp_valid_blob[] = {
|
|
|
|
0x0, 0x1, 0xBC, 0xB, 0x0, 0x0, 0x1F, 0x12, 0xDB, 0xCF, 0xC3, 0xA2, 0x41, 0x41, 0x9D, 0x74, 0xB0, 0x31, 0xE6, 0x34, 0x53, 0x41, 0xDB,
|
|
|
|
0x1B, 0xB6, 0x7C, 0xD9, 0xA2, 0x41, 0x41, 0x67, 0xA7, 0xB6, 0xF, 0xF6, 0x34, 0x53, 0x41, 0x7C, 0x6, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0,
|
|
|
|
0x0, 0x69, 0x3, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x12, 0x0, 0x0, 0x0, 0xBB, 0x4B, 0x9C, 0x59, 0xD2, 0xA2, 0x41, 0x41, 0x3A, 0xAA,
|
|
|
|
0x3F, 0xAE, 0xEB, 0x34, 0x53, 0x41, 0xA2, 0xC2, 0xE4, 0xC6, 0xD1, 0xA2, 0x41, 0x41, 0x4C, 0xFE, 0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5, 0xA2, 0x41, 0x41, 0xC8, 0x5D, 0x86, 0xF1, 0xE9, 0x34, 0x53, 0x41,
|
|
|
|
0x19, 0xF4, 0x73, 0x63, 0xD7, 0xA2, 0x41, 0x41, 0x7, 0xB1, 0x14, 0x36, 0xE8, 0x34, 0x53, 0x41, 0xDB, 0x1B, 0xB6, 0x7C, 0xD9, 0xA2,
|
|
|
|
0x41, 0x41, 0x98, 0xB5, 0xE0, 0x74, 0xE6, 0x34, 0x53, 0x41, 0xC0, 0x3F, 0xC6, 0xAC, 0xD8, 0xA2, 0x41, 0x41, 0x9D, 0x74, 0xB0, 0x31,
|
|
|
|
0xE6, 0x34, 0x53, 0x41, 0xF0, 0xB5, 0xB1, 0x53, 0xD5, 0xA2, 0x41, 0x41, 0x97, 0x47, 0xAD, 0x36, 0xE9, 0x34, 0x53, 0x41, 0xBB, 0x4B,
|
|
|
|
0x9C, 0x59, 0xD2, 0xA2, 0x41, 0x41, 0x3A, 0xAA, 0x3F, 0xAE, 0xEB, 0x34, 0x53, 0x41 };
|
|
|
|
|
|
|
|
unsigned char sq_valid_blob[] = {
|
|
|
|
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x40 };
|
|
|
|
|
|
|
|
unsigned char sq_invalid_blob[] = {
|
|
|
|
0x23, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x40, 0x23 };
|
|
|
|
|
|
|
|
mapnik::context_ptr ctx(new mapnik::context_type);
|
|
|
|
mapnik::feature_ptr feature = mapnik::feature_factory::create(ctx, 1);
|
|
|
|
|
|
|
|
// test of parsing wks geometries
|
|
|
|
try {
|
|
|
|
|
|
|
|
// spatialite blob
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sp_valid_blob,
|
|
|
|
sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]),
|
|
|
|
mapnik::wkbSpatiaLite)
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sp_valid_blob,
|
|
|
|
sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]),
|
|
|
|
mapnik::wkbAuto)
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sp_invalid_blob,
|
|
|
|
sizeof(sp_invalid_blob) / sizeof(sp_invalid_blob[0]),
|
|
|
|
mapnik::wkbAuto) == false
|
|
|
|
);
|
|
|
|
|
|
|
|
// sqlite generic wkb blob
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sq_valid_blob,
|
|
|
|
sizeof(sq_valid_blob) / sizeof(sq_valid_blob[0]),
|
|
|
|
mapnik::wkbGeneric)
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sq_valid_blob,
|
|
|
|
sizeof(sq_valid_blob) / sizeof(sq_valid_blob[0]),
|
|
|
|
mapnik::wkbAuto)
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOST_TEST(
|
|
|
|
mapnik::geometry_utils::from_wkb(feature->paths(),
|
|
|
|
(const char*)sq_invalid_blob,
|
|
|
|
sizeof(sq_invalid_blob) / sizeof(sq_invalid_blob[0]),
|
|
|
|
mapnik::wkbGeneric) == false
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (std::exception const& ex) {
|
|
|
|
BOOST_TEST(false);
|
|
|
|
std::clog << "threw: " << ex.what() << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!::boost::detail::test_errors()) {
|
2013-05-25 02:21:55 +02:00
|
|
|
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
|
|
|
else std::clog << "C++ CSV parse: \x1b[1;32m✓ \x1b[0m\n";
|
2013-04-09 08:38:48 +02:00
|
|
|
::boost::detail::report_errors_remind().called_report_errors_function = true;
|
|
|
|
} else {
|
|
|
|
return ::boost::report_errors();
|
|
|
|
}
|
|
|
|
}
|