use arch independent types for serialised values

This commit is contained in:
artemp 2017-08-15 11:14:11 +01:00
parent c4a1df6e91
commit add410e619
12 changed files with 25 additions and 25 deletions

View file

@ -67,11 +67,11 @@ struct extract_positions
}; };
using box_type = mapnik::box2d<double>; using box_type = mapnik::box2d<double>;
using boxes_type = std::vector<std::pair<box_type, std::pair<std::size_t, std::size_t>>>; using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
using callback_type = extract_positions<grammar::iterator_type, boxes_type>; using callback_type = extract_positions<grammar::iterator_type, boxes_type>;
using box_type_f = mapnik::box2d<float>; using box_type_f = mapnik::box2d<float>;
using boxes_type_f = std::vector<std::pair<box_type_f, std::pair<std::size_t, std::size_t>>>; using boxes_type_f = std::vector<std::pair<box_type_f, std::pair<std::uint64_t, std::uint64_t>>>;
using callback_type_f = extract_positions<grammar::iterator_type, boxes_type_f>; using callback_type_f = extract_positions<grammar::iterator_type, boxes_type_f>;

View file

@ -153,7 +153,7 @@ csv_datasource::csv_datasource(parameters const& params)
if (has_disk_index_ && !extent_initialized_) if (has_disk_index_ && !extent_initialized_)
{ {
// read bounding box from *.index // read bounding box from *.index
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
std::ifstream index(filename_ + ".index", std::ios::binary); std::ifstream index(filename_ + ".index", std::ios::binary);
if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'"); if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'");
extent_ = mapnik::util::spatial_index<value_type, extent_ = mapnik::util::spatial_index<value_type,
@ -283,8 +283,8 @@ csv_datasource::get_geometry_type_impl(std::istream & stream) const
for (std::size_t count = 0; itr !=end && count < 5; ++itr, ++count) for (std::size_t count = 0; itr !=end && count < 5; ++itr, ++count)
{ {
csv_datasource::item_type const& item = *itr; csv_datasource::item_type const& item = *itr;
std::size_t file_offset = item.second.first; std::uint64_t file_offset = item.second.first;
std::size_t size = item.second.second; std::uint64_t size = item.second.second;
stream.seekg(file_offset); stream.seekg(file_offset);
std::vector<char> record; std::vector<char> record;
record.resize(size); record.resize(size);
@ -316,7 +316,7 @@ csv_datasource::get_geometry_type_impl(std::istream & stream) const
else else
{ {
// try reading *.index // try reading *.index
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
std::ifstream index(filename_ + ".index", std::ios::binary); std::ifstream index(filename_ + ".index", std::ios::binary);
if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'"); if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'");

View file

@ -73,7 +73,7 @@ class csv_datasource : public mapnik::datasource,
{ {
public: public:
using box_type = mapnik::box2d<double>; using box_type = mapnik::box2d<double>;
using item_type = std::pair<box_type, std::pair<std::size_t, std::size_t>>; using item_type = std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>;
using spatial_index_type = boost::geometry::index::rtree<item_type,csv_linear<16,4>>; using spatial_index_type = boost::geometry::index::rtree<item_type,csv_linear<16,4>>;
csv_datasource(mapnik::parameters const& params); csv_datasource(mapnik::parameters const& params);

View file

@ -88,8 +88,8 @@ mapnik::feature_ptr csv_featureset::next()
if (index_itr_ != index_end_) if (index_itr_ != index_end_)
{ {
csv_datasource::item_type const& item = *index_itr_++; csv_datasource::item_type const& item = *index_itr_++;
std::size_t file_offset = item.second.first; std::uint64_t file_offset = item.second.first;
std::size_t size = item.second.second; std::uint64_t size = item.second.second;
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
char const* start = (char const*)mapped_region_->get_address() + file_offset; char const* start = (char const*)mapped_region_->get_address() + file_offset;
char const* end = start + size; char const* end = start + size;

View file

@ -40,7 +40,7 @@
class csv_index_featureset : public mapnik::Featureset class csv_index_featureset : public mapnik::Featureset
{ {
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
using locator_type = csv_utils::geometry_column_locator; using locator_type = csv_utils::geometry_column_locator;
public: public:

View file

@ -505,8 +505,8 @@ mapnik::geometry::geometry<double> extract_geometry(std::vector<std::string> con
return geom; return geom;
} }
template void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, std::vector<std::pair<mapnik::box2d<double>, std::pair<std::size_t, std::size_t>>> & boxes); template void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, std::vector<std::pair<mapnik::box2d<double>, std::pair<std::uint64_t, std::uint64_t>>> & boxes);
template void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, std::vector<std::pair<mapnik::box2d<float>, std::pair<std::size_t, std::size_t>>> & boxes); template void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, std::vector<std::pair<mapnik::box2d<float>, std::pair<std::uint64_t, std::uint64_t>>> & boxes);
} // namespace csv_utils } // namespace csv_utils

View file

@ -183,7 +183,7 @@ geojson_datasource::geojson_datasource(parameters const& params)
namespace { namespace {
using box_type = box2d<double>; using box_type = box2d<double>;
using boxes_type = std::vector<std::pair<box_type, std::pair<std::size_t, std::size_t>>>; using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
using base_iterator_type = char const*; using base_iterator_type = char const*;
const mapnik::transcoder geojson_datasource_static_tr("utf8"); const mapnik::transcoder geojson_datasource_static_tr("utf8");
@ -206,7 +206,7 @@ void geojson_datasource::initialise_descriptor(mapnik::feature_ptr const& featur
void geojson_datasource::initialise_disk_index(std::string const& filename) void geojson_datasource::initialise_disk_index(std::string const& filename)
{ {
// read extent // read extent
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
std::ifstream index(filename_ + ".index", std::ios::binary); std::ifstream index(filename_ + ".index", std::ios::binary);
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'"); if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'");
extent_ = mapnik::util::spatial_index<value_type, extent_ = mapnik::util::spatial_index<value_type,
@ -321,7 +321,7 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end)
features_.push_back(std::move(feature)); features_.push_back(std::move(feature));
using values_container = std::vector< std::pair<box_type, std::pair<std::size_t, std::size_t>>>; using values_container = std::vector< std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
values_container values; values_container values;
values.reserve(features_.size()); values.reserve(features_.size());
@ -394,7 +394,7 @@ void geojson_datasource::parse_geojson(Iterator start, Iterator end)
features_.push_back(std::move(feature)); features_.push_back(std::move(feature));
} }
using values_container = std::vector< std::pair<box_type, std::pair<std::size_t, std::size_t>>>; using values_container = std::vector< std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
values_container values; values_container values;
values.reserve(features_.size()); values.reserve(features_.size());
@ -453,7 +453,7 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
int multi_type = 0; int multi_type = 0;
if (has_disk_index_) if (has_disk_index_)
{ {
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
std::ifstream index(filename_ + ".index", std::ios::binary); std::ifstream index(filename_ + ".index", std::ios::binary);
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'"); if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'");
mapnik::filter_in_box filter(extent_); mapnik::filter_in_box filter(extent_);
@ -527,8 +527,8 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
for (std::size_t count = 0; itr !=end && count < num_features_to_query_; ++itr,++count) for (std::size_t count = 0; itr !=end && count < num_features_to_query_; ++itr,++count)
{ {
geojson_datasource::item_type const& item = *itr; geojson_datasource::item_type const& item = *itr;
std::size_t file_offset = item.second.first; std::uint64_t file_offset = item.second.first;
std::size_t size = item.second.second; std::uint64_t size = item.second.second;
std::fseek(file.get(), file_offset, SEEK_SET); std::fseek(file.get(), file_offset, SEEK_SET);
std::vector<char> json; std::vector<char> json;

View file

@ -75,7 +75,7 @@ class geojson_datasource : public mapnik::datasource
{ {
public: public:
using box_type = mapnik::box2d<double>; using box_type = mapnik::box2d<double>;
using item_type = std::pair<box_type, std::pair<std::size_t, std::size_t> >; using item_type = std::pair<box_type, std::pair<std::uint64_t, std::uint64_t> >;
using spatial_index_type = boost::geometry::index::rtree<item_type,geojson_linear<16,4> >; using spatial_index_type = boost::geometry::index::rtree<item_type,geojson_linear<16,4> >;
// constructor // constructor

View file

@ -41,7 +41,7 @@
class geojson_index_featureset : public mapnik::Featureset class geojson_index_featureset : public mapnik::Featureset
{ {
using value_type = std::pair<std::size_t, std::size_t>; using value_type = std::pair<std::uint64_t, std::uint64_t>;
public: public:
geojson_index_featureset(std::string const& filename, mapnik::filter_in_box const& filter); geojson_index_featureset(std::string const& filename, mapnik::filter_in_box const& filter);
virtual ~geojson_index_featureset(); virtual ~geojson_index_featureset();

View file

@ -168,7 +168,7 @@ int main (int argc, char** argv)
std::clog << "split ratio:" << ratio << std::endl; std::clog << "split ratio:" << ratio << std::endl;
using box_type = mapnik::box2d<float>; using box_type = mapnik::box2d<float>;
using item_type = std::pair<box_type, std::pair<std::size_t, std::size_t>>; using item_type = std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>;
for (auto const& filename : files_to_process) for (auto const& filename : files_to_process)
{ {
@ -208,7 +208,7 @@ int main (int argc, char** argv)
{ {
std::clog << extent << std::endl; std::clog << extent << std::endl;
mapnik::box2d<double> extent_d(extent.minx(), extent.miny(), extent.maxx(), extent.maxy()); mapnik::box2d<double> extent_d(extent.minx(), extent.miny(), extent.maxx(), extent.maxy());
mapnik::quad_tree<std::pair<std::size_t, std::size_t>> tree(extent_d, depth, ratio); mapnik::quad_tree<std::pair<std::uint64_t, std::uint64_t>> tree(extent_d, depth, ratio);
for (auto const& item : boxes) for (auto const& item : boxes)
{ {
auto ext_f = std::get<0>(item); auto ext_f = std::get<0>(item);

View file

@ -93,7 +93,7 @@ std::pair<bool,typename T::value_type::first_type> process_csv_file(T & boxes, s
} }
using box_type = mapnik::box2d<float>; using box_type = mapnik::box2d<float>;
using item_type = std::pair<box_type, std::pair<std::size_t, std::size_t>>; using item_type = std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>;
using boxes_type = std::vector<item_type>; using boxes_type = std::vector<item_type>;
template std::pair<bool,box_type> process_csv_file(boxes_type&, std::string const&, std::string const&, char, char); template std::pair<bool,box_type> process_csv_file(boxes_type&, std::string const&, std::string const&, char, char);

View file

@ -213,7 +213,7 @@ bool validate_geojson_feature(mapnik::json::geojson_value & value, Keys const& k
}; };
using box_type = mapnik::box2d<float>; using box_type = mapnik::box2d<float>;
using boxes_type = std::vector<std::pair<box_type, std::pair<std::size_t, std::size_t>>>; using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
using base_iterator_type = char const*; using base_iterator_type = char const*;
auto const& geojson_value = mapnik::json::geojson_grammar(); auto const& geojson_value = mapnik::json::geojson_grammar();