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_(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_fields_(0),
record_length_(0),
@ -64,7 +64,7 @@ dbf_file::dbf_file(std::string const& file_name)
{
#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)
{
mapped_region_ = *memory;

View file

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

View file

@ -64,6 +64,7 @@ shape_datasource::shape_datasource(parameters const& params)
file_length_(0),
indexed_(false),
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"))
{
#ifdef MAPNIK_STATS

View file

@ -72,6 +72,7 @@ private:
box2d<double> extent_;
bool indexed_;
const int row_limit_;
const bool update_cache_;
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::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),
shp_(shape_name + SHP),
shx_(shape_name + SHX),
dbf_(shape_name + DBF),
shp_(shape_name + SHP, update_cache),
shx_(shape_name + SHX, update_cache),
dbf_(shape_name + DBF, update_cache),
reclength_(0),
id_(0)
{

View file

@ -57,7 +57,7 @@ public:
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_file& shp();

View file

@ -159,7 +159,7 @@ public:
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)
file_()
#elif defined (_WINDOWS)
@ -170,7 +170,7 @@ public:
{
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
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)
{