+ implement x/y resolution

This commit is contained in:
Artem Pavlenko 2010-02-03 16:56:42 +00:00
parent c11e35fbc0
commit f4e7a7931f
5 changed files with 309 additions and 300 deletions

View File

@ -30,9 +30,9 @@ using mapnik::box2d;
struct query_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const query& q)
getinitargs(query const& q)
{
return boost::python::make_tuple(q.get_bbox(),q.resolution());
return boost::python::make_tuple(q.get_bbox(),q.resolution());
}
};
@ -41,9 +41,10 @@ void export_query()
using namespace boost::python;
class_<query>("Query", "a spatial query data object",
init<box2d<double>,double>() )
init<box2d<double>,query::resolution_type const&,double>() )
.def_pickle(query_pickle_suite())
.add_property("resolution", &query::resolution)
.add_property("resolution",make_function(&query::resolution,
return_value_policy<copy_const_reference>()))
.add_property("bbox", make_function(&query::get_bbox,
return_value_policy<copy_const_reference>()) )
.add_property("property_names", make_function(&query::property_names,

View File

@ -121,34 +121,34 @@ private:
box2d<double> layer_ext = lay.envelope();
double lx0 = layer_ext.minx();
double ly0 = layer_ext.miny();
double lz0 = 0.0;
double lx1 = layer_ext.maxx();
double ly1 = layer_ext.maxy();
double lz1 = 0.0;
// back project layers extent into main map projection
prj_trans.backward(lx0,ly0,lz0);
prj_trans.backward(lx1,ly1,lz1);
double lx0 = layer_ext.minx();
double ly0 = layer_ext.miny();
double lz0 = 0.0;
double lx1 = layer_ext.maxx();
double ly1 = layer_ext.maxy();
double lz1 = 0.0;
// back project layers extent into main map projection
prj_trans.backward(lx0,ly0,lz0);
prj_trans.backward(lx1,ly1,lz1);
// if no intersection then nothing to do for layer
if ( lx0 > ext.maxx() || lx1 < ext.minx() || ly0 > ext.maxy() || ly1 < ext.miny() )
{
return;
}
// if no intersection then nothing to do for layer
if ( lx0 > ext.maxx() || lx1 < ext.minx() || ly0 > ext.maxy() || ly1 < ext.miny() )
{
return;
}
// clip query bbox
lx0 = std::max(ext.minx(),lx0);
ly0 = std::max(ext.miny(),ly0);
lx1 = std::min(ext.maxx(),lx1);
ly1 = std::min(ext.maxy(),ly1);
// clip query bbox
lx0 = std::max(ext.minx(),lx0);
ly0 = std::max(ext.miny(),ly0);
lx1 = std::min(ext.maxx(),lx1);
ly1 = std::min(ext.maxy(),ly1);
prj_trans.forward(lx0,ly0,lz0);
prj_trans.forward(lx1,ly1,lz1);
box2d<double> bbox(lx0,ly0,lx1,ly1);
double resolution = m_.getWidth()/bbox.width();
query q(bbox,resolution,scale_denom); //BBOX query
prj_trans.forward(lx0,ly0,lz0);
prj_trans.forward(lx1,ly1,lz1);
box2d<double> bbox(lx0,ly0,lx1,ly1);
query::resolution_type res(m_.getWidth()/bbox.width(),m_.getHeight()/bbox.height());
query q(bbox,res,scale_denom); //BBOX query
std::vector<std::string> const& style_names = lay.styles();
std::vector<std::string>::const_iterator stylesIter = style_names.begin();

View File

@ -28,74 +28,81 @@
//mapnik
#include <mapnik/box2d.hpp>
#include <mapnik/feature.hpp>
// boost
#include <boost/tuple/tuple.hpp>
// stl
#include <set>
#include <limits>
namespace mapnik {
class query
{
private:
box2d<double> bbox_;
double resolution_;
double scale_denominator_;
std::set<std::string> names_;
public:
explicit query(const box2d<double>& bbox, double resolution, double scale_denominator)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator)
{}
explicit query(const box2d<double>& bbox, double resolution)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(0.0)
{}
class query
{
public:
typedef boost::tuple<double,double> resolution_type;
private:
box2d<double> bbox_;
resolution_type resolution_;
double scale_denominator_;
std::set<std::string> names_;
public:
explicit query(box2d<double> const& bbox, resolution_type const& resolution, double scale_denominator)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator)
{}
explicit query(box2d<double> const& bbox, resolution_type const& resolution)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(0.0)
{}
query(const query& other)
: bbox_(other.bbox_),
resolution_(other.resolution_),
scale_denominator_(other.scale_denominator_),
names_(other.names_)
{}
query(query const& other)
: bbox_(other.bbox_),
resolution_(other.resolution_),
scale_denominator_(other.scale_denominator_),
names_(other.names_)
{}
query& operator=(const query& other)
{
if (this == &other) return *this;
bbox_=other.bbox_;
resolution_=other.resolution_;
scale_denominator_=other.scale_denominator_;
names_=other.names_;
return *this;
}
query& operator=(query const& other)
{
if (this == &other) return *this;
bbox_=other.bbox_;
resolution_=other.resolution_;
scale_denominator_=other.scale_denominator_;
names_=other.names_;
return *this;
}
double resolution() const
{
return resolution_;
}
double scale_denominator() const
{
return scale_denominator_;
}
query::resolution_type const& resolution() const
{
return resolution_;
}
double scale_denominator() const
{
return scale_denominator_;
}
const box2d<double>& get_bbox() const
{
return bbox_;
}
box2d<double> const& get_bbox() const
{
return bbox_;
}
void add_property_name(const std::string& name)
{
names_.insert(name);
}
void add_property_name(std::string const& name)
{
names_.insert(name);
}
const std::set<std::string>& property_names() const
{
return names_;
}
};
std::set<std::string> const& property_names() const
{
return names_;
}
};
}

View File

@ -38,296 +38,296 @@ using mapnik::geometry2d;
gdal_featureset::gdal_featureset(GDALDataset & dataset, int band, gdal_query q)
: dataset_(dataset),
band_(band),
gquery_(q),
first_(true) {}
: dataset_(dataset),
band_(band),
gquery_(q),
first_(true) {}
gdal_featureset::~gdal_featureset()
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: closing dataset = " << &dataset_ << "\n";
std::clog << "GDAL Plugin: closing dataset = " << &dataset_ << "\n";
#endif
GDALClose(&dataset_);
GDALClose(&dataset_);
}
feature_ptr gdal_featureset::next()
{
if (first_)
{
first_ = false;
if (first_)
{
first_ = false;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: featureset, dataset = " << &dataset_ << "\n";
std::clog << "GDAL Plugin: featureset, dataset = " << &dataset_ << "\n";
#endif
query *q = boost::get<query>(&gquery_);
if(q) {
return get_feature(*q);
} else {
coord2d *p = boost::get<coord2d>(&gquery_);
if(p) {
return get_feature_at_point(*p);
}
}
// should never reach here
}
return feature_ptr();
query *q = boost::get<query>(&gquery_);
if(q) {
return get_feature(*q);
} else {
coord2d *p = boost::get<coord2d>(&gquery_);
if(p) {
return get_feature_at_point(*p);
}
}
// should never reach here
}
return feature_ptr();
}
feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
feature_ptr feature(new Feature(1));
feature_ptr feature(new Feature(1));
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
int nbands = dataset_.GetRasterCount();
int nbands = dataset_.GetRasterCount();
unsigned raster_width = dataset_.GetRasterXSize();
unsigned raster_height = dataset_.GetRasterYSize();
unsigned raster_width = dataset_.GetRasterXSize();
unsigned raster_height = dataset_.GetRasterYSize();
// TODO - pull from class attributes...
double tr[6];
dataset_.GetGeoTransform(tr);
double dx = tr[1];
double dy = tr[5];
double x0 = tr[0]; // minx
double y0 = tr[3]; // miny
double x1 = tr[0] + raster_width * dx + raster_height * tr[2]; // maxx
double y1 = tr[3] + raster_width * tr[4] + raster_height * dy; // maxy
box2d<double> raster_extent(x0,y0,x1,y1);
// TODO - pull from class attributes...
double tr[6];
dataset_.GetGeoTransform(tr);
double dx = tr[1];
double dy = tr[5];
double x0 = tr[0]; // minx
double y0 = tr[3]; // miny
double x1 = tr[0] + raster_width * dx + raster_height * tr[2]; // maxx
double y1 = tr[3] + raster_width * tr[4] + raster_height * dy; // maxy
box2d<double> raster_extent(x0,y0,x1,y1);
CoordTransform t(raster_width,raster_height,raster_extent,0,0);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
box2d<double> box = t.forward(intersect);
CoordTransform t(raster_width,raster_height,raster_extent,0,0);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
box2d<double> box = t.forward(intersect);
// TODO: error check this further...
float x_off_f = (intersect.minx()-raster_extent.minx()) / fabs(dx);
float y_off_f = (raster_extent.maxy()-intersect.maxy()) / fabs(dy);
// TODO: error check this further...
float x_off_f = (intersect.minx()-raster_extent.minx()) / fabs(dx);
float y_off_f = (raster_extent.maxy()-intersect.maxy()) / fabs(dy);
if (x_off_f < 0)
{
x_off_f = 0;
}
if (x_off_f < 0)
{
x_off_f = 0;
}
if (y_off_f < 0)
{
y_off_f = 0;
}
if (y_off_f < 0)
{
y_off_f = 0;
}
int x_off = static_cast<int>(x_off_f + 0.5);
int y_off = static_cast<int>(y_off_f + 0.5);
int x_off = static_cast<int>(x_off_f + 0.5);
int y_off = static_cast<int>(y_off_f + 0.5);
int width = int(box.maxx() + 0.5) - int(box.minx() + 0.5);
int height = int(box.maxy() + 0.5) - int(box.miny() + 0.5);
int width = int(box.maxx() + 0.5) - int(box.minx() + 0.5);
int height = int(box.maxy() + 0.5) - int(box.miny() + 0.5);
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Raster extent=" << raster_extent << "\n";
std::clog << "GDAL Plugin: View extent=" << intersect << "\n";
std::clog << "GDAL Plugin: Query resolution=" << q.resolution() << "\n";
std::clog << boost::format("GDAL Plugin: StartX=%d StartY=%d Width=%d Height=%d \n") % x_off % y_off % width % height;
std::clog << "GDAL Plugin: Raster extent=" << raster_extent << "\n";
std::clog << "GDAL Plugin: View extent=" << intersect << "\n";
std::clog << "GDAL Plugin: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution()) << "\n";
std::clog << boost::format("GDAL Plugin: StartX=%d StartY=%d Width=%d Height=%d \n") % x_off % y_off % width % height;
#endif
if (width > 0 && height > 0)
{
int im_width = int(boost::get<0>(q.resolution()) * intersect.width() + 0.5);
int im_height = int(boost::get<1>(q.resolution()) * intersect.height() + 0.5);
// case where we need to avoid upsampling so that the
// image can be later scaled within raster_symbolizer
if (im_width >= width || im_height >= height)
{
im_width = width;
im_height = height;
}
if (width > 0 && height > 0)
{
int im_width = int(q.resolution() * intersect.width() + 0.5);
int im_height = int(q.resolution() * intersect.height() + 0.5);
// case where we need to avoid upsampling so that the
// image can be later scaled within raster_symbolizer
if (im_width >= width || im_height >= height)
{
im_width = width;
im_height = height;
}
mapnik::image_data_32 image(im_width, im_height);
image.set(0xffffffff);
mapnik::image_data_32 image(im_width, im_height);
image.set(0xffffffff);
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Image Size=(" << im_width << "," << im_height << ")\n";
std::clog << "GDAL Plugin: Reading band " << band_ << "\n";
std::clog << "GDAL Plugin: Image Size=(" << im_width << "," << im_height << ")\n";
std::clog << "GDAL Plugin: Reading band " << band_ << "\n";
#endif
if (band_>0) // we are querying a single band
{
float *imageData = (float*)image.getBytes();
GDALRasterBand * band = dataset_.GetRasterBand(band_);
band->RasterIO(GF_Read, x_off, y_off, width, height,
imageData, image.width(), image.height(),
GDT_Float32, 0, 0);
if (band_>0) // we are querying a single band
{
float *imageData = (float*)image.getBytes();
GDALRasterBand * band = dataset_.GetRasterBand(band_);
band->RasterIO(GF_Read, x_off, y_off, width, height,
imageData, image.width(), image.height(),
GDT_Float32, 0, 0);
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
}
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
}
else // working with all bands
{
for (int i = 0; i < nbands; ++i)
{
GDALRasterBand * band = dataset_.GetRasterBand(i+1);
else // working with all bands
{
for (int i = 0; i < nbands; ++i)
{
GDALRasterBand * band = dataset_.GetRasterBand(i+1);
#ifdef MAPNIK_DEBUG
get_overview_meta(band);
get_overview_meta(band);
#endif
GDALColorInterp color_interp = band->GetColorInterpretation();
switch (color_interp)
{
case GCI_RedBand:
red = band;
GDALColorInterp color_interp = band->GetColorInterpretation();
switch (color_interp)
{
case GCI_RedBand:
red = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found red band" << "\n";
std::clog << "GDAL Plugin: Found red band" << "\n";
#endif
break;
case GCI_GreenBand:
green = band;
break;
case GCI_GreenBand:
green = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found green band" << "\n";
std::clog << "GDAL Plugin: Found green band" << "\n";
#endif
break;
case GCI_BlueBand:
blue = band;
break;
case GCI_BlueBand:
blue = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found blue band" << "\n";
std::clog << "GDAL Plugin: Found blue band" << "\n";
#endif
break;
case GCI_AlphaBand:
alpha = band;
break;
case GCI_AlphaBand:
alpha = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found alpha band" << "\n";
std::clog << "GDAL Plugin: Found alpha band" << "\n";
#endif
break;
case GCI_GrayIndex:
grey = band;
break;
case GCI_GrayIndex:
grey = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found gray band" << "\n";
std::clog << "GDAL Plugin: Found gray band" << "\n";
#endif
break;
case GCI_PaletteIndex:
{
grey = band;
break;
case GCI_PaletteIndex:
{
grey = band;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found gray band, and colortable..." << "\n";
std::clog << "GDAL Plugin: Found gray band, and colortable..." << "\n";
#endif
GDALColorTable *color_table = band->GetColorTable();
GDALColorTable *color_table = band->GetColorTable();
if ( color_table)
{
int count = color_table->GetColorEntryCount();
if ( color_table)
{
int count = color_table->GetColorEntryCount();
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Color Table count = " << count << "\n";
std::clog << "GDAL Plugin: Color Table count = " << count << "\n";
#endif
for ( int i = 0; i < count; i++ )
{
const GDALColorEntry *ce = color_table->GetColorEntry ( i );
if (!ce ) continue;
for ( int i = 0; i < count; i++ )
{
const GDALColorEntry *ce = color_table->GetColorEntry ( i );
if (!ce ) continue;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Color entry RGB (" << ce->c1 << "," <<ce->c2 << "," << ce->c3 << ")\n";
std::clog << "GDAL Plugin: Color entry RGB (" << ce->c1 << "," <<ce->c2 << "," << ce->c3 << ")\n";
#endif
}
}
break;
}
case GCI_Undefined:
}
}
break;
}
case GCI_Undefined:
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Found undefined band (assumming gray band)" << "\n";
std::clog << "GDAL Plugin: Found undefined band (assumming gray band)" << "\n";
#endif
grey = band;
break;
default:
grey = band;
break;
default:
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: band type unknown!" << "\n";
std::clog << "GDAL Plugin: band type unknown!" << "\n";
#endif
break;
}
}
break;
}
}
if (red && green && blue)
{
if (red && green && blue)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing rgb bands..." << "\n";
std::clog << "GDAL Plugin: processing rgb bands..." << "\n";
#endif
red->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 0,
image.width(),image.height(),GDT_Byte,4,4*image.width());
green->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 1,
image.width(),image.height(),GDT_Byte,4,4*image.width());
blue->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 2,
image.width(),image.height(),GDT_Byte,4,4*image.width());
}
else if (grey)
{
red->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 0,
image.width(),image.height(),GDT_Byte,4,4*image.width());
green->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 1,
image.width(),image.height(),GDT_Byte,4,4*image.width());
blue->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 2,
image.width(),image.height(),GDT_Byte,4,4*image.width());
}
else if (grey)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing gray band..." << "\n";
std::clog << "GDAL Plugin: processing gray band..." << "\n";
#endif
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 0,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 1,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 2,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
}
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 0,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 1,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
grey->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 2,
image.width(),image.height(),GDT_Byte, 4, 4 * image.width());
}
if (alpha)
{
if (alpha)
{
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: processing alpha band..." << "\n";
std::clog << "GDAL Plugin: processing alpha band..." << "\n";
#endif
alpha->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 3,
image.width(),image.height(),GDT_Byte,4,4*image.width());
}
alpha->RasterIO(GF_Read,x_off,y_off,width,height,image.getBytes() + 3,
image.width(),image.height(),GDT_Byte,4,4*image.width());
}
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
}
return feature;
}
return feature_ptr();
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
}
return feature;
}
return feature_ptr();
}
feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
{
if (band_>0) {
if (band_>0) {
unsigned raster_xsize = dataset_.GetRasterXSize();
unsigned raster_ysize = dataset_.GetRasterYSize();
unsigned raster_xsize = dataset_.GetRasterXSize();
unsigned raster_ysize = dataset_.GetRasterYSize();
double gt[6];
dataset_.GetGeoTransform(gt);
double gt[6];
dataset_.GetGeoTransform(gt);
double det = gt[1]*gt[5] - gt[2]*gt[4];
// subtract half a pixel width & height because gdal coord reference
// is the top-left corner of a pixel, not the center.
double X = pt.x - gt[0] - gt[1]/2;
double Y = pt.y - gt[3] - gt[5]/2;
double det1 = gt[1]*Y + gt[4]*X;
double det2 = gt[2]*Y + gt[5]*X;
unsigned x = det2/det, y = det1/det;
double det = gt[1]*gt[5] - gt[2]*gt[4];
// subtract half a pixel width & height because gdal coord reference
// is the top-left corner of a pixel, not the center.
double X = pt.x - gt[0] - gt[1]/2;
double Y = pt.y - gt[3] - gt[5]/2;
double det1 = gt[1]*Y + gt[4]*X;
double det2 = gt[2]*Y + gt[5]*X;
unsigned x = det2/det, y = det1/det;
if(0<=x && x<raster_xsize && 0<=y && y<raster_ysize) {
if(0<=x && x<raster_xsize && 0<=y && y<raster_ysize) {
#ifdef MAPNIK_DEBUG
std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f\n") % pt.x % pt.y;
std::clog << boost::format("GDAL Plugin: x=%f y=%f\n") % x % y;
std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f\n") % pt.x % pt.y;
std::clog << boost::format("GDAL Plugin: x=%f y=%f\n") % x % y;
#endif
GDALRasterBand * band = dataset_.GetRasterBand(band_);
int hasNoData;
double nodata = band->GetNoDataValue(&hasNoData);
double value;
band->RasterIO(GF_Read, x, y, 1, 1, &value, 1, 1, GDT_Float64, 0, 0);
if(!hasNoData || value!=nodata) {
// construct feature
feature_ptr feature(new Feature(1));
geometry2d * point = new point_impl;
point->move_to(pt.x, pt.y);
feature->add_geometry(point);
(*feature)["value"] = value;
return feature;
}
}
}
return feature_ptr();
GDALRasterBand * band = dataset_.GetRasterBand(band_);
int hasNoData;
double nodata = band->GetNoDataValue(&hasNoData);
double value;
band->RasterIO(GF_Read, x, y, 1, 1, &value, 1, 1, GDT_Float64, 0, 0);
if(!hasNoData || value!=nodata) {
// construct feature
feature_ptr feature(new Feature(1));
geometry2d * point = new point_impl;
point->move_to(pt.x, pt.y);
feature->add_geometry(point);
(*feature)["value"] = value;
return feature;
}
}
}
return feature_ptr();
}
void gdal_featureset::get_overview_meta(GDALRasterBand * band)
@ -340,7 +340,7 @@ void gdal_featureset::get_overview_meta(GDALRasterBand * band)
{
GDALRasterBand * overview = band->GetOverview (b);
std::clog << boost::format("GDAL Plugin: Overview=%d Width=%d Height=%d \n")
% b % overview->GetXSize() % overview->GetYSize();
% b % overview->GetXSize() % overview->GetYSize();
}
}
else
@ -353,6 +353,6 @@ void gdal_featureset::get_overview_meta(GDALRasterBand * band)
band->GetBlockSize(&bsx,&bsy);
scale = band->GetScale();
std::clog << boost::format("GDAL Plugin: Block=%dx%d Scale=%f Type=%s Color=%s \n") % bsx % bsy % scale
% GDALGetDataTypeName(band->GetRasterDataType())
% GDALGetColorInterpretationName(band->GetColorInterpretation());
% GDALGetDataTypeName(band->GetRasterDataType())
% GDALGetColorInterpretationName(band->GetColorInterpretation());
}

View File

@ -91,8 +91,8 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
box2d<double> raster_extent(x0,y0,x1,y1);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
int width = static_cast<int>(q.resolution() * intersect.width() + 0.5);
int height = static_cast<int>(q.resolution() * intersect.height() + 0.5);
int width = static_cast<int>(boost::get<0>(q.resolution()) * intersect.width() + 0.5);
int height = static_cast<int>(boost::get<0>(q.resolution()) * intersect.height() + 0.5);
double pixel_size = (intersect.width() >= intersect.height()) ?
(intersect.width() / (double) width) : (intersect.height() / (double) height);
@ -101,7 +101,8 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
std::clog << "Rasterlite Plugin: Raster extent=" << raster_extent << "\n";
std::clog << "Rasterlite Plugin: View extent=" << q.get_bbox() << "\n";
std::clog << "Rasterlite Plugin: Intersect extent=" << intersect << "\n";
std::clog << "Rasterlite Plugin: Query resolution=" << q.resolution() << "\n";
std::clog << "Rasterlite Plugin: Query resolution=" << boost::get<0>(q.resolution())
<< "," << boost::get<1>(q.resolution()) << "\n";
std::clog << "Rasterlite Plugin: Size=" << width << " " << height << "\n";
std::clog << "Rasterlite Plugin: Pixel Size=" << pixel_size << "\n";
#endif