Merge branch 'master' into twkb-direct
This commit is contained in:
commit
d0e3f39c3c
3 changed files with 18 additions and 20 deletions
|
@ -38,7 +38,8 @@
|
|||
namespace mapnik { namespace json {
|
||||
|
||||
using position_type = mapnik::geometry::point<double>;
|
||||
using boxes_type = std::vector<std::pair<box2d<double>, std::pair<std::size_t, std::size_t>>>;
|
||||
using box_type = box2d<double>;
|
||||
using boxes_type = std::vector<std::pair<box_type, std::pair<std::size_t, std::size_t>>>;
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
||||
|
@ -74,20 +75,20 @@ struct push_box_impl
|
|||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename ErrorHandler = error_handler<Iterator> >
|
||||
template <typename Iterator, typename Boxes = boxes_type, typename ErrorHandler = error_handler<Iterator> >
|
||||
struct extract_bounding_box_grammar :
|
||||
qi::grammar<Iterator, void(boxes_type&), space_type>
|
||||
qi::grammar<Iterator, void(Boxes&), space_type>
|
||||
{
|
||||
extract_bounding_box_grammar();
|
||||
// rules
|
||||
qi::rule<Iterator, void(boxes_type&), space_type> start;
|
||||
qi::rule<Iterator, qi::locals<Iterator>, void(boxes_type&), space_type> features;
|
||||
qi::rule<Iterator, qi::locals<int, box2d<double>>, void(boxes_type&, Iterator const&), space_type> feature;
|
||||
qi::rule<Iterator, qi::locals<box2d<double>>, box2d<double>(), space_type> coords;
|
||||
qi::rule<Iterator, qi::locals<int, box_type>, void(boxes_type&, Iterator const&), space_type> feature;
|
||||
qi::rule<Iterator, qi::locals<box_type>, box_type(), space_type> coords;
|
||||
qi::rule<Iterator, boost::optional<position_type>(), space_type> pos;
|
||||
qi::rule<Iterator, void(box2d<double>&), space_type> ring;
|
||||
qi::rule<Iterator, void(box2d<double>&), space_type> rings;
|
||||
qi::rule<Iterator, void(box2d<double>&), space_type> rings_array;
|
||||
qi::rule<Iterator, void(box_type&), space_type> ring;
|
||||
qi::rule<Iterator, void(box_type&), space_type> rings;
|
||||
qi::rule<Iterator, void(box_type&), space_type> rings_array;
|
||||
// generic JSON support
|
||||
json::generic_json<Iterator> json;
|
||||
// phoenix functions
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace mapnik { namespace json {
|
|||
|
||||
namespace repo = boost::spirit::repository;
|
||||
|
||||
template <typename Iterator, typename ErrorHandler>
|
||||
extract_bounding_box_grammar<Iterator, ErrorHandler>::extract_bounding_box_grammar()
|
||||
: extract_bounding_box_grammar::base_type(start,"bounding boxes")
|
||||
template <typename Iterator, typename Boxes, typename ErrorHandler>
|
||||
extract_bounding_box_grammar<Iterator, Boxes, ErrorHandler>::extract_bounding_box_grammar()
|
||||
: extract_bounding_box_grammar::base_type(start, "GeoJSON bounding boxes")
|
||||
{
|
||||
qi::lit_type lit;
|
||||
qi::double_type double_;
|
||||
|
|
|
@ -183,17 +183,16 @@ mapnik::raster_ptr read_data_band(mapnik::box2d<double> const& bbox,
|
|||
{
|
||||
mapnik::image_gray32f image(width, height);
|
||||
float* data = image.data();
|
||||
double val;
|
||||
val = reader(); // nodata value, need to read anyway
|
||||
double nodataval = reader();
|
||||
for (int y=0; y<height; ++y) {
|
||||
for (int x=0; x<width; ++x) {
|
||||
val = reader();
|
||||
double val = reader();
|
||||
int off = y * width + x;
|
||||
data[off] = val;
|
||||
}
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(bbox, image, 1.0);
|
||||
if ( hasnodata ) raster->set_nodata(val);
|
||||
if ( hasnodata ) raster->set_nodata(nodataval);
|
||||
return raster;
|
||||
}
|
||||
|
||||
|
@ -270,15 +269,13 @@ mapnik::raster_ptr read_grayscale_band(mapnik::box2d<double> const& bbox,
|
|||
image.set(0xffffffff);
|
||||
|
||||
|
||||
int val;
|
||||
int nodataval;
|
||||
uint8_t * data = image.bytes();
|
||||
int ps = 4; // sizeof(image::pixel_type)
|
||||
int off;
|
||||
nodataval = reader(); // nodata value, need to read anyway
|
||||
int nodataval = reader();
|
||||
for (int y=0; y<height; ++y) {
|
||||
for (int x=0; x<width; ++x) {
|
||||
val = reader();
|
||||
int val = reader();
|
||||
// Apply harsh type clipping rules ala GDAL
|
||||
if ( val < 0 ) val = 0;
|
||||
if ( val > 255 ) val = 255;
|
||||
|
@ -298,7 +295,7 @@ mapnik::raster_ptr read_grayscale_band(mapnik::box2d<double> const& bbox,
|
|||
}
|
||||
}
|
||||
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(bbox, image, 1.0);
|
||||
if ( hasnodata ) raster->set_nodata(val);
|
||||
if ( hasnodata ) raster->set_nodata(nodataval);
|
||||
return raster;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue