diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index 0140201ae..face79aca 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -131,7 +131,7 @@ private: boost::optional font_directory_; freetype_engine::font_file_mapping_type font_file_mapping_; freetype_engine::font_memory_cache_type font_memory_cache_; - proj_cache_type proj_cache_; + mutable proj_cache_type proj_cache_; public: using const_style_iterator = std::map::const_iterator; @@ -287,6 +287,12 @@ public: */ 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. * @param index layer number. */ @@ -297,6 +303,11 @@ public: */ std::vector const& layers() const; + /*! \brief Get all layers. + * @return Non-constant layers. + */ + std::vector & layers(); + /*! \brief Remove all layers and styles from the map. */ void remove_all(); diff --git a/src/map.cpp b/src/map.cpp index 43e121e93..a0ca76bf5 100644 --- a/src/map.cpp +++ b/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{}); if (itr == proj_cache_.end()) { - throw std::runtime_error("Failed to initialise projection transform:" + - key.first.to_string() + " -> " + key.second.to_string()); + mapnik::projection srs1(source, true); + mapnik::projection srs2(dest, true); + return proj_cache_.emplace(std::make_pair(source, dest), + std::make_unique(srs1, srs2)).first->second.get(); } return itr->second.get(); } @@ -387,11 +389,21 @@ layer const& Map::get_layer(size_t index) const return layers_[index]; } +layer& Map::get_layer(size_t index) +{ + return layers_[index]; +} + std::vector const& Map::layers() const { return layers_; } +std::vector & Map::layers() +{ + return layers_; +} + unsigned Map::width() const { return width_;