Re-use proj_transform
as creating a new one is extremely expensive on libproj >= 6 (NOTE: epsg:4326
and epsg:3857
are special cases which use internal implementations and are not expensive to create on stack).
This commit is contained in:
parent
199e609a79
commit
9c7e21fa47
1 changed files with 7 additions and 7 deletions
|
@ -9,7 +9,7 @@ class test : public benchmark::test_case
|
|||
std::string dest_;
|
||||
mapnik::box2d<double> from_;
|
||||
mapnik::box2d<double> to_;
|
||||
bool defer_proj4_init_;
|
||||
bool defer_proj_init_;
|
||||
public:
|
||||
test(mapnik::parameters const& params,
|
||||
std::string const& src,
|
||||
|
@ -22,11 +22,11 @@ public:
|
|||
dest_(dest),
|
||||
from_(from),
|
||||
to_(to),
|
||||
defer_proj4_init_(defer_proj) {}
|
||||
defer_proj_init_(defer_proj) {}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::projection src(src_,defer_proj4_init_);
|
||||
mapnik::projection dest(dest_,defer_proj4_init_);
|
||||
mapnik::projection src(src_,defer_proj_init_);
|
||||
mapnik::projection dest(dest_,defer_proj_init_);
|
||||
mapnik::proj_transform tr(src,dest);
|
||||
mapnik::box2d<double> bbox = from_;
|
||||
if (!tr.forward(bbox)) return false;
|
||||
|
@ -38,15 +38,15 @@ public:
|
|||
}
|
||||
bool operator()() const
|
||||
{
|
||||
mapnik::projection src(src_,defer_proj_init_);
|
||||
mapnik::projection dest(dest_,defer_proj_init_);
|
||||
mapnik::proj_transform tr(src,dest);
|
||||
for (std::size_t i=0;i<iterations_;++i)
|
||||
{
|
||||
for (int j=-180;j<180;j=j+5)
|
||||
{
|
||||
for (int k=-85;k<85;k=k+5)
|
||||
{
|
||||
mapnik::projection src(src_,defer_proj4_init_);
|
||||
mapnik::projection dest(dest_,defer_proj4_init_);
|
||||
mapnik::proj_transform tr(src,dest);
|
||||
mapnik::box2d<double> box(j,k,j,k);
|
||||
if (!tr.forward(box)) throw std::runtime_error("could not transform coords");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue