add proj_transform forward/backward box2d implementation
This commit is contained in:
parent
daf5cff723
commit
383d8a3f15
3 changed files with 39 additions and 16 deletions
|
@ -61,26 +61,16 @@ mapnik::coord2d backward_transform_c(mapnik::proj_transform& t, mapnik::coord2d
|
||||||
|
|
||||||
mapnik::box2d<double> forward_transform_env(mapnik::proj_transform& t, mapnik::box2d<double> const & box)
|
mapnik::box2d<double> forward_transform_env(mapnik::proj_transform& t, mapnik::box2d<double> const & box)
|
||||||
{
|
{
|
||||||
double minx = box.minx();
|
mapnik::box2d<double> new_box = box;
|
||||||
double miny = box.miny();
|
t.forward(new_box);
|
||||||
double maxx = box.maxx();
|
return new_box;
|
||||||
double maxy = box.maxy();
|
|
||||||
double z = 0.0;
|
|
||||||
t.forward(minx,miny,z);
|
|
||||||
t.forward(maxx,maxy,z);
|
|
||||||
return mapnik::box2d<double>(minx,miny,maxx,maxy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnik::box2d<double> backward_transform_env(mapnik::proj_transform& t, mapnik::box2d<double> const & box)
|
mapnik::box2d<double> backward_transform_env(mapnik::proj_transform& t, mapnik::box2d<double> const & box)
|
||||||
{
|
{
|
||||||
double minx = box.minx();
|
mapnik::box2d<double> new_box = box;
|
||||||
double miny = box.miny();
|
t.backward(new_box);
|
||||||
double maxx = box.maxx();
|
return new_box;
|
||||||
double maxy = box.maxy();
|
|
||||||
double z = 0.0;
|
|
||||||
t.backward(minx,miny,z);
|
|
||||||
t.backward(maxx,maxy,z);
|
|
||||||
return mapnik::box2d<double>(minx,miny,maxx,maxy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
bool equal() const;
|
bool equal() const;
|
||||||
bool forward (double& x, double& y , double& z) const;
|
bool forward (double& x, double& y , double& z) const;
|
||||||
bool backward (double& x, double& y , double& z) const;
|
bool backward (double& x, double& y , double& z) const;
|
||||||
|
bool forward (box2d<double> & box) const;
|
||||||
|
bool backward (box2d<double> & box) const;
|
||||||
mapnik::projection const& source() const;
|
mapnik::projection const& source() const;
|
||||||
mapnik::projection const& dest() const;
|
mapnik::projection const& dest() const;
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,37 @@ bool proj_transform::backward (double & x, double & y , double & z) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool proj_transform::forward (box2d<double> & box) const
|
||||||
|
{
|
||||||
|
if (is_source_equal_dest_)
|
||||||
|
return true;
|
||||||
|
double minx = box.minx();
|
||||||
|
double miny = box.miny();
|
||||||
|
double maxx = box.maxx();
|
||||||
|
double maxy = box.maxy();
|
||||||
|
double z = 0.0;
|
||||||
|
bool ok0 = forward(minx,miny,z);
|
||||||
|
bool ok1 = forward(maxx,maxy,z);
|
||||||
|
box.init(minx,miny,maxx,maxy);
|
||||||
|
return ok0 & ok1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool proj_transform::backward (box2d<double> & box) const
|
||||||
|
{
|
||||||
|
if (is_source_equal_dest_)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
double minx = box.minx();
|
||||||
|
double miny = box.miny();
|
||||||
|
double maxx = box.maxx();
|
||||||
|
double maxy = box.maxy();
|
||||||
|
double z = 0.0;
|
||||||
|
bool ok0 = backward(minx,miny,z);
|
||||||
|
bool ok1 = backward(maxx,maxy,z);
|
||||||
|
box.init(minx,miny,maxx,maxy);
|
||||||
|
return ok0 & ok1;
|
||||||
|
}
|
||||||
|
|
||||||
mapnik::projection const& proj_transform::source() const
|
mapnik::projection const& proj_transform::source() const
|
||||||
{
|
{
|
||||||
return source_;
|
return source_;
|
||||||
|
|
Loading…
Reference in a new issue