gdal: protect from passing wrong number of bands to gdal
This commit is contained in:
parent
3549fea396
commit
8e708a8160
1 changed files with 3 additions and 0 deletions
|
@ -35,6 +35,7 @@ using mapnik::feature_ptr;
|
||||||
using mapnik::CoordTransform;
|
using mapnik::CoordTransform;
|
||||||
using mapnik::point_impl;
|
using mapnik::point_impl;
|
||||||
using mapnik::geometry2d;
|
using mapnik::geometry2d;
|
||||||
|
using mapnik::datasource_exception;
|
||||||
|
|
||||||
|
|
||||||
gdal_featureset::gdal_featureset(GDALDataset & dataset, int band, gdal_query q,
|
gdal_featureset::gdal_featureset(GDALDataset & dataset, int band, gdal_query q,
|
||||||
|
@ -187,6 +188,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
||||||
|
|
||||||
if (band_>0) // we are querying a single band
|
if (band_>0) // we are querying a single band
|
||||||
{
|
{
|
||||||
|
if (band_ > nbands_)
|
||||||
|
throw datasource_exception((boost::format("GDAL Plugin: '%d' is an invalid band, dataset only has '%d' bands\n") % band_ % nbands_).str());
|
||||||
float *imageData = (float*)image.getBytes();
|
float *imageData = (float*)image.getBytes();
|
||||||
GDALRasterBand * band = dataset_.GetRasterBand(band_);
|
GDALRasterBand * band = dataset_.GetRasterBand(band_);
|
||||||
band->RasterIO(GF_Read, x_off, y_off, width, height,
|
band->RasterIO(GF_Read, x_off, y_off, width, height,
|
||||||
|
|
Loading…
Add table
Reference in a new issue