shape.input - add 'update-cache' optional parameter (default:true)

This commit is contained in:
artemp 2016-02-18 17:34:03 +01:00
parent 085a2afe40
commit f65c799475
7 changed files with 12 additions and 10 deletions

View file

@ -49,7 +49,7 @@ dbf_file::dbf_file()
record_length_(0), record_length_(0),
record_(0) {} record_(0) {}
dbf_file::dbf_file(std::string const& file_name) dbf_file::dbf_file(std::string const& file_name, bool update_cache)
:num_records_(0), :num_records_(0),
num_fields_(0), num_fields_(0),
record_length_(0), record_length_(0),
@ -64,7 +64,7 @@ dbf_file::dbf_file(std::string const& file_name)
{ {
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(file_name,true); boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(file_name, update_cache);
if (memory) if (memory)
{ {
mapped_region_ = *memory; mapped_region_ = *memory;

View file

@ -69,7 +69,7 @@ private:
char* record_; char* record_;
public: public:
dbf_file(); dbf_file();
dbf_file(std::string const& file_name); dbf_file(std::string const& file_name, bool update_cache = true);
~dbf_file(); ~dbf_file();
bool is_open(); bool is_open();
int num_records() const; int num_records() const;

View file

@ -64,6 +64,7 @@ shape_datasource::shape_datasource(parameters const& params)
file_length_(0), file_length_(0),
indexed_(false), indexed_(false),
row_limit_(*params.get<mapnik::value_integer>("row_limit",0)), row_limit_(*params.get<mapnik::value_integer>("row_limit",0)),
update_cache_(*params.get<mapnik::value_bool>("update-cache", true)),
desc_(shape_datasource::name(), *params.get<std::string>("encoding","utf-8")) desc_(shape_datasource::name(), *params.get<std::string>("encoding","utf-8"))
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS

View file

@ -72,6 +72,7 @@ private:
box2d<double> extent_; box2d<double> extent_;
bool indexed_; bool indexed_;
const int row_limit_; const int row_limit_;
const bool update_cache_;
layer_descriptor desc_; layer_descriptor desc_;
}; };

View file

@ -35,11 +35,11 @@ const std::string shape_io::SHX = ".shx";
const std::string shape_io::DBF = ".dbf"; const std::string shape_io::DBF = ".dbf";
const std::string shape_io::INDEX = ".index"; const std::string shape_io::INDEX = ".index";
shape_io::shape_io(std::string const& shape_name, bool open_index) shape_io::shape_io(std::string const& shape_name, bool open_index, bool update_cache)
: type_(shape_null), : type_(shape_null),
shp_(shape_name + SHP), shp_(shape_name + SHP, update_cache),
shx_(shape_name + SHX), shx_(shape_name + SHX, update_cache),
dbf_(shape_name + DBF), dbf_(shape_name + DBF, update_cache),
reclength_(0), reclength_(0),
id_(0) id_(0)
{ {

View file

@ -57,7 +57,7 @@ public:
shape_multipatch = 31 shape_multipatch = 31
}; };
shape_io(std::string const& shape_name, bool open_index=true); shape_io(std::string const& shape_name, bool open_index = true, bool update_cache = true);
~shape_io(); ~shape_io();
shape_file& shp(); shape_file& shp();

View file

@ -159,7 +159,7 @@ public:
shape_file() {} shape_file() {}
shape_file(std::string const& file_name) : shape_file(std::string const& file_name, bool update_cache = true) :
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
file_() file_()
#elif defined (_WINDOWS) #elif defined (_WINDOWS)
@ -170,7 +170,7 @@ public:
{ {
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = boost::optional<mapnik::mapped_region_ptr> memory =
mapnik::mapped_memory_cache::instance().find(file_name,true); mapnik::mapped_memory_cache::instance().find(file_name, update_cache);
if (memory) if (memory)
{ {