2013-02-21 04:52:54 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2016-12-20 17:57:22 +01:00
|
|
|
* Copyright (C) 2016 Artem Pavlenko
|
2013-02-21 04:52:54 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/request.hpp>
|
|
|
|
|
|
|
|
namespace mapnik
|
|
|
|
{
|
|
|
|
|
2013-02-26 01:33:08 +01:00
|
|
|
request::request(unsigned width,
|
|
|
|
unsigned height,
|
|
|
|
box2d<double> const& extent)
|
2013-02-21 04:52:54 +01:00
|
|
|
: width_(width),
|
|
|
|
height_(height),
|
2013-02-26 01:33:08 +01:00
|
|
|
extent_(extent),
|
2013-02-21 04:52:54 +01:00
|
|
|
buffer_size_(0) {}
|
|
|
|
|
|
|
|
request::~request() {}
|
|
|
|
|
|
|
|
unsigned request::width() const
|
|
|
|
{
|
|
|
|
return width_;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned request::height() const
|
|
|
|
{
|
|
|
|
return height_;
|
|
|
|
}
|
|
|
|
|
2013-02-26 01:33:08 +01:00
|
|
|
void request::set_buffer_size(int buffer_size)
|
2013-02-21 04:52:54 +01:00
|
|
|
{
|
|
|
|
buffer_size_ = buffer_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
int request::buffer_size() const
|
|
|
|
{
|
|
|
|
return buffer_size_;
|
|
|
|
}
|
|
|
|
|
2013-02-26 01:33:08 +01:00
|
|
|
void request::set_extent(box2d<double> const& box)
|
2013-02-21 04:52:54 +01:00
|
|
|
{
|
2013-02-26 01:33:08 +01:00
|
|
|
extent_ = box;
|
2013-02-21 04:52:54 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 01:33:08 +01:00
|
|
|
box2d<double> const& request::extent() const
|
2013-02-21 04:52:54 +01:00
|
|
|
{
|
2013-02-26 01:33:08 +01:00
|
|
|
return extent_;
|
2013-02-21 04:52:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
box2d<double> request::get_buffered_extent() const
|
|
|
|
{
|
|
|
|
double extra = 2.0 * scale() * buffer_size_;
|
2013-02-26 01:33:08 +01:00
|
|
|
box2d<double> ext(extent_);
|
|
|
|
ext.width(extent_.width() + extra);
|
|
|
|
ext.height(extent_.height() + extra);
|
2013-02-21 04:52:54 +01:00
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
double request::scale() const
|
|
|
|
{
|
|
|
|
if (width_>0)
|
2013-02-26 01:33:08 +01:00
|
|
|
return extent_.width()/width_;
|
|
|
|
return extent_.width();
|
2013-02-21 04:52:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|