Map::mapnik - restore non-const access to layers + create proj_transform and cache in get_proj_transform
+ declare proj_cache_
mutable
This commit is contained in:
parent
fb325f527b
commit
7cbbd7305b
2 changed files with 26 additions and 3 deletions
|
@ -131,7 +131,7 @@ private:
|
||||||
boost::optional<std::string> font_directory_;
|
boost::optional<std::string> font_directory_;
|
||||||
freetype_engine::font_file_mapping_type font_file_mapping_;
|
freetype_engine::font_file_mapping_type font_file_mapping_;
|
||||||
freetype_engine::font_memory_cache_type font_memory_cache_;
|
freetype_engine::font_memory_cache_type font_memory_cache_;
|
||||||
proj_cache_type proj_cache_;
|
mutable proj_cache_type proj_cache_;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using const_style_iterator = std::map<std::string,feature_type_style>::const_iterator;
|
using const_style_iterator = std::map<std::string,feature_type_style>::const_iterator;
|
||||||
|
@ -287,6 +287,12 @@ public:
|
||||||
*/
|
*/
|
||||||
layer const& get_layer(size_t index) const;
|
layer const& get_layer(size_t index) const;
|
||||||
|
|
||||||
|
/*! \brief Get a layer.
|
||||||
|
* @param index layer number.
|
||||||
|
* @return Non-constant layer.
|
||||||
|
*/
|
||||||
|
layer& get_layer(size_t index);
|
||||||
|
|
||||||
/*! \brief Remove a layer.
|
/*! \brief Remove a layer.
|
||||||
* @param index layer number.
|
* @param index layer number.
|
||||||
*/
|
*/
|
||||||
|
@ -297,6 +303,11 @@ public:
|
||||||
*/
|
*/
|
||||||
std::vector<layer> const& layers() const;
|
std::vector<layer> const& layers() const;
|
||||||
|
|
||||||
|
/*! \brief Get all layers.
|
||||||
|
* @return Non-constant layers.
|
||||||
|
*/
|
||||||
|
std::vector<layer> & layers();
|
||||||
|
|
||||||
/*! \brief Remove all layers and styles from the map.
|
/*! \brief Remove all layers and styles from the map.
|
||||||
*/
|
*/
|
||||||
void remove_all();
|
void remove_all();
|
||||||
|
|
16
src/map.cpp
16
src/map.cpp
|
@ -333,8 +333,10 @@ proj_transform * Map::get_proj_transform(std::string const& source, std::string
|
||||||
auto itr = proj_cache_.find(key, compatible_hash{}, compatible_predicate{});
|
auto itr = proj_cache_.find(key, compatible_hash{}, compatible_predicate{});
|
||||||
if (itr == proj_cache_.end())
|
if (itr == proj_cache_.end())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Failed to initialise projection transform:" +
|
mapnik::projection srs1(source, true);
|
||||||
key.first.to_string() + " -> " + key.second.to_string());
|
mapnik::projection srs2(dest, true);
|
||||||
|
return proj_cache_.emplace(std::make_pair(source, dest),
|
||||||
|
std::make_unique<proj_transform>(srs1, srs2)).first->second.get();
|
||||||
}
|
}
|
||||||
return itr->second.get();
|
return itr->second.get();
|
||||||
}
|
}
|
||||||
|
@ -387,11 +389,21 @@ layer const& Map::get_layer(size_t index) const
|
||||||
return layers_[index];
|
return layers_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layer& Map::get_layer(size_t index)
|
||||||
|
{
|
||||||
|
return layers_[index];
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<layer> const& Map::layers() const
|
std::vector<layer> const& Map::layers() const
|
||||||
{
|
{
|
||||||
return layers_;
|
return layers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<layer> & Map::layers()
|
||||||
|
{
|
||||||
|
return layers_;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Map::width() const
|
unsigned Map::width() const
|
||||||
{
|
{
|
||||||
return width_;
|
return width_;
|
||||||
|
|
Loading…
Reference in a new issue