int main() { mapnik::projection merc("+init=epsg:3857",true); mapnik::proj_transform prj_trans(merc,merc); // no-op unsigned tile_size = 256; mapnik::vector_tile_impl::spherical_mercator merc_tiler(tile_size); double minx,miny,maxx,maxy; merc_tiler.xyz(9664,20435,15,minx,miny,maxx,maxy); mapnik::box2d<double> z15_extent(minx,miny,maxx,maxy); mapnik::view_transform tr(tile_size,tile_size,z15_extent,0,0); std::string geojson_file("./test/data/poly.geojson"); mapnik::util::file input(geojson_file); if (!input.open()) { throw std::runtime_error("failed to open geojson"); } mapnik::geometry::geometry<double> geom; std::string json_string(input.data().get(), input.size()); if (!mapnik::json::from_geojson(json_string, geom)) { throw std::runtime_error("failed to parse geojson"); } mapnik::geometry::correct(geom); unsigned count = 0; unsigned count2 = 0; { mapnik::vector_tile_impl::vector_tile_strategy vs(prj_trans, tr, 16); mapnik::progress_timer __stats__(std::clog, "boost::geometry::transform"); for (unsigned i=0;i<10000;++i) { mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::geometry::transform<std::int64_t>(geom, vs); auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(new_geom); count += poly.size(); } } { mapnik::vector_tile_impl::vector_tile_strategy vs(prj_trans, tr, 16); mapnik::progress_timer __stats__(std::clog, "transform_visitor with reserve"); mapnik::vector_tile_impl::transform_visitor transit(vs); for (unsigned i=0;i<10000;++i) { mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::util::apply_visitor(transit,geom); auto const& poly = mapnik::util::get<mapnik::geometry::multi_polygon<std::int64_t>>(new_geom); count2 += poly.size(); } if (count != count2) { std::clog << "tests did not run as expected!\n"; return -1; } } return 0; }
std::shared_ptr<ResultSet> executeQuery(std::string const& sql, int type = 0) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("postgis_connection::execute_query ") + sql); #endif PGresult* result = 0; if ( executeAsyncQuery(sql, type) ) { // fetch multiple times until NULL is returned, // to handle multi-statement queries while ( PGresult *tmp = getResult() ) { if ( result ) PQclear(result); result = tmp; } } if (! result || (PQresultStatus(result) != PGRES_TUPLES_OK)) { std::string err_msg = "Postgis Plugin: "; err_msg += status(); err_msg += "in executeQuery Full sql was: '"; err_msg += sql; err_msg += "'\n"; if ( result ) PQclear(result); throw mapnik::datasource_exception(err_msg); } return std::make_shared<ResultSet>(result); }
MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_mode_e mode, float opacity, int dx, int dy #ifdef MAPNIK_STATS_RENDER , std::ostream * log_stream #endif ) { #ifdef MAPNIK_STATS_RENDER boost::optional<std::string> mode_name = comp_op_to_string(mode); std::stringstream ss; ss << "comp-op" << ' ' << (mode_name ? *mode_name : "unknown") << ' ' << std::to_string(src.width()) << "x" << std::to_string(src.height()) << " -> " << std::to_string(dst.width()) << "x" << std::to_string(dst.height()); log_render lr(ss.str(), log_stream ? *log_stream : std::clog); timer_with_action<log_render> __stats__(lr); #endif #ifdef MAPNIK_DEBUG if (!src.get_premultiplied()) { throw std::runtime_error("SOURCE MUST BE PREMULTIPLIED FOR COMPOSITING!"); } if (!dst.get_premultiplied()) { throw std::runtime_error("DESTINATION MUST BE PREMULTIPLIED FOR COMPOSITING!"); } #endif unsigned jobs = util::jobs_by_image_size(src.width(), src.height()); composite_functor comp_func{ dst, src, mode, opacity, dx, dy }; util::parallelize(comp_func, jobs, src.height()); }
int execute_with_code(std::string const& sql) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute_with_code ") + sql); #endif const int rc = sqlite3_exec(db_, sql.c_str(), 0, 0, 0); return rc; }
void execute(std::string const& sql) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute ") + sql); #endif const int rc = sqlite3_exec(db_, sql.c_str(), 0, 0, 0); if (rc != SQLITE_OK) { throw_sqlite_error(sql); } }
std::shared_ptr<sqlite_resultset> execute_query(std::string const& sql) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute_query ") + sql); #endif sqlite3_stmt* stmt = 0; const int rc = sqlite3_prepare_v2 (db_, sql.c_str(), -1, &stmt, 0); if (rc != SQLITE_OK) { throw_sqlite_error(sql); } return std::make_shared<sqlite_resultset>(stmt); }
bool execute(std::string const& sql) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("postgis_connection::execute ") + sql); #endif if ( ! executeAsyncQuery(sql) ) return false; PGresult *result = 0; // fetch multiple times until NULL is returned, // to handle multi-statement queries while ( PGresult *tmp = getResult() ) { if ( result ) PQclear(result); result = tmp; } bool ok = (result && (PQresultStatus(result) == PGRES_COMMAND_OK)); if ( result ) PQclear(result); return ok; }