feature_impl update

This commit is contained in:
Artem Pavlenko 2012-01-16 17:55:44 -05:00 committed by Artem Pavlenko
parent 7b8934933e
commit e17c6ec5ff
2 changed files with 12 additions and 8 deletions

View file

@ -66,6 +66,8 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
filter_factor_(filter_factor), filter_factor_(filter_factor),
first_(true) first_(true)
{ {
ctx_ = boost::make_shared<mapnik::context>();
ctx_->push("NODATA");
} }
gdal_featureset::~gdal_featureset() gdal_featureset::~gdal_featureset()
@ -106,14 +108,14 @@ feature_ptr gdal_featureset::next()
feature_ptr gdal_featureset::get_feature(mapnik::query const& q) feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{ {
feature_ptr feature(feature_factory::create(1)); feature_ptr feature = feature_factory::create(ctx_,1);
GDALRasterBand * red = 0; GDALRasterBand * red = 0;
GDALRasterBand * green = 0; GDALRasterBand * green = 0;
GDALRasterBand * blue = 0; GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0; GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0; GDALRasterBand * grey = 0;
/* /*
double tr[6]; double tr[6];
dataset_.GetGeoTransform(tr); dataset_.GetGeoTransform(tr);
@ -244,10 +246,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
imageData, image.width(), image.height(), imageData, image.width(), image.height(),
GDT_Float32, 0, 0); GDT_Float32, 0, 0);
feature->set_raster(mapnik::raster_ptr(boost::make_shared<mapnik::raster>(intersect,image))); feature->set_raster(boost::make_shared<mapnik::raster>(intersect,image));
if (hasNoData) if (hasNoData)
{ {
feature->props()["NODATA"] = nodata; feature->put("NODATA",nodata);
} }
} }
else // working with all bands else // working with all bands
@ -487,12 +489,12 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
if (! hasNoData || value != nodata) if (! hasNoData || value != nodata)
{ {
// construct feature // construct feature
feature_ptr feature(new Feature(1)); feature_ptr feature = feature_factory::create(ctx_,1);
geometry_type * point = new geometry_type(mapnik::Point); geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(pt.x, pt.y); point->move_to(pt.x, pt.y);
feature->add_geometry(point); feature->add_geometry(point);
(*feature)["value"] = value; feature->put("value",value);
return feature; return feature;
} }
} }

View file

@ -24,6 +24,7 @@
#define GDAL_FEATURESET_HPP #define GDAL_FEATURESET_HPP
// mapnik // mapnik
#include <mapnik/feature.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
// boost // boost
@ -56,6 +57,7 @@ private:
void get_overview_meta(GDALRasterBand * band); void get_overview_meta(GDALRasterBand * band);
#endif #endif
GDALDataset & dataset_; GDALDataset & dataset_;
mapnik::context_ptr ctx_;
int band_; int band_;
gdal_query gquery_; gdal_query gquery_;
mapnik::box2d<double> raster_extent_; mapnik::box2d<double> raster_extent_;