1.removed named_style_cache
2.styles moved to Map object
This commit is contained in:
parent
95d26be572
commit
2a858bcd19
10 changed files with 44 additions and 135 deletions
|
@ -91,6 +91,8 @@ void export_map()
|
|||
.def("pan",&Map::pan)
|
||||
.def("zoom",&Map::zoom)
|
||||
.def("pan_and_zoom",&Map::pan_and_zoom)
|
||||
.def("append_style",&Map::insert_style)
|
||||
.def("remove_style",&Map::remove_style)
|
||||
.add_property("layers",make_function
|
||||
(&Map::layers,return_value_policy<reference_existing_object>()))
|
||||
.def_pickle(map_pickle_suite())
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#include "mapnik.hpp"
|
||||
|
||||
using mapnik::feature_type_style;
|
||||
using mapnik::named_style_cache;
|
||||
using mapnik::singleton;
|
||||
using mapnik::CreateStatic;
|
||||
using mapnik::rules;
|
||||
|
||||
void export_style()
|
||||
|
@ -40,18 +37,5 @@ void export_style()
|
|||
(&feature_type_style::get_rules,return_value_policy<reference_existing_object>()))
|
||||
;
|
||||
|
||||
class_<singleton<named_style_cache,CreateStatic>,boost::noncopyable>("singleton",no_init)
|
||||
.def("instance",&singleton<named_style_cache,CreateStatic>::instance,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.staticmethod("instance")
|
||||
;
|
||||
|
||||
class_<named_style_cache,bases<singleton<named_style_cache,CreateStatic> >,
|
||||
boost::noncopyable>("style_cache",no_init)
|
||||
.def("insert",&named_style_cache::insert)
|
||||
.staticmethod("insert")
|
||||
.def("remove",&named_style_cache::remove)
|
||||
.staticmethod("remove")
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include "feature_type_style.hpp"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -46,6 +47,7 @@ namespace mapnik
|
|||
unsigned height_;
|
||||
int srid_;
|
||||
Color background_;
|
||||
std::map<std::string,feature_type_style> styles_;
|
||||
std::vector<Layer> layers_;
|
||||
Envelope<double> currentExtent_;
|
||||
public:
|
||||
|
@ -53,11 +55,15 @@ namespace mapnik
|
|||
Map(int width,int height,int srid=-1);
|
||||
Map(const Map& rhs);
|
||||
Map& operator=(const Map& rhs);
|
||||
|
||||
bool insert_style(std::string const& name,feature_type_style const& style);
|
||||
void remove_style(const std::string& name);
|
||||
feature_type_style find_style(std::string const& name) const;
|
||||
|
||||
size_t layerCount() const;
|
||||
void addLayer(const Layer& l);
|
||||
const Layer& getLayer(size_t index) const;
|
||||
void removeLayer(size_t index);
|
||||
void removeLayer(const char* lName);
|
||||
std::vector<Layer> const& layers() const;
|
||||
unsigned getWidth() const;
|
||||
unsigned getHeight() const;
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include "wkb.hpp"
|
||||
#include "map.hpp"
|
||||
#include "feature_type_style.hpp"
|
||||
#include "named_style_cache.hpp"
|
||||
#include "feature_factory.hpp"
|
||||
#include "math_expr.hpp"
|
||||
#include "value.hpp"
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
* Copyright (C) 2005 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
//$Id: style_cache.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
||||
|
||||
#ifndef STYLE_CACHE_HPP
|
||||
#define STYLE_CACHE_HPP
|
||||
|
||||
#include "utils.hpp"
|
||||
#include <map>
|
||||
#include "feature_type_style.hpp"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class named_style_cache : public singleton <named_style_cache,CreateStatic>
|
||||
{
|
||||
friend class CreateStatic<named_style_cache>;
|
||||
private:
|
||||
static std::map<std::string,feature_type_style> styles_;
|
||||
named_style_cache();
|
||||
~named_style_cache();
|
||||
named_style_cache(const named_style_cache&);
|
||||
named_style_cache& operator=(const named_style_cache&);
|
||||
public:
|
||||
static bool insert(const std::string& name,const feature_type_style& style);
|
||||
static void remove(const std::string& name);
|
||||
static feature_type_style find(const std::string& name);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //STYLE_CACHE_HPP
|
|
@ -36,7 +36,7 @@ namespace mapnik
|
|||
static void render(const Map& map,Image& image);
|
||||
private:
|
||||
Renderer();
|
||||
static void render_vector_layer(datasource_p const& ds,
|
||||
static void render_vector_layer(datasource_p const& ds,Map const& map,
|
||||
std::vector<std::string> const& ,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
|
|
|
@ -41,7 +41,6 @@ source = Split(
|
|||
plugin.cpp
|
||||
png_reader.cpp
|
||||
render.cpp
|
||||
named_style_cache.cpp
|
||||
text.cpp
|
||||
tiff_reader.cpp
|
||||
wkb.cpp
|
||||
|
|
25
src/map.cpp
25
src/map.cpp
|
@ -40,6 +40,7 @@ namespace mapnik
|
|||
height_(rhs.height_),
|
||||
srid_(rhs.srid_),
|
||||
background_(rhs.background_),
|
||||
styles_(rhs.styles_),
|
||||
layers_(rhs.layers_),
|
||||
currentExtent_(rhs.currentExtent_) {}
|
||||
|
||||
|
@ -50,10 +51,29 @@ namespace mapnik
|
|||
height_=rhs.height_;
|
||||
srid_=rhs.srid_;
|
||||
background_=rhs.background_;
|
||||
styles_=rhs.styles_;
|
||||
layers_=rhs.layers_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Map::insert_style(std::string const& name,feature_type_style const& style)
|
||||
{
|
||||
return styles_.insert(make_pair(name,style)).second;
|
||||
}
|
||||
|
||||
void Map::remove_style(std::string const& name)
|
||||
{
|
||||
styles_.erase(name);
|
||||
}
|
||||
|
||||
feature_type_style Map::find_style(std::string const& name) const
|
||||
{
|
||||
std::map<std::string,feature_type_style>::const_iterator itr=styles_.find(name);
|
||||
if (itr!=styles_.end())
|
||||
return itr->second;
|
||||
return feature_type_style();
|
||||
}
|
||||
|
||||
size_t Map::layerCount() const
|
||||
{
|
||||
return layers_.size();
|
||||
|
@ -67,10 +87,7 @@ namespace mapnik
|
|||
{
|
||||
layers_.erase(layers_.begin()+index);
|
||||
}
|
||||
void Map::removeLayer(const char* lName)
|
||||
{
|
||||
//todo
|
||||
}
|
||||
|
||||
const Layer& Map::getLayer(size_t index) const
|
||||
{
|
||||
return layers_[index];
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
* Copyright (C) 2005 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
//$Id: style_cache.cpp 37 2005-04-07 17:09:38Z pavlenko $
|
||||
|
||||
#include "named_style_cache.hpp"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
named_style_cache::named_style_cache() {}
|
||||
named_style_cache::~named_style_cache() {}
|
||||
|
||||
std::map<std::string,feature_type_style> named_style_cache::styles_;
|
||||
|
||||
bool named_style_cache::insert(const std::string& name,const feature_type_style& style)
|
||||
{
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
return styles_.insert(make_pair(name,style)).second;
|
||||
}
|
||||
|
||||
void named_style_cache::remove(const std::string& name)
|
||||
{
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
styles_.erase(name);
|
||||
}
|
||||
|
||||
feature_type_style named_style_cache::find(const std::string& name)
|
||||
{
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
std::map<std::string,feature_type_style>::iterator itr=styles_.find(name);
|
||||
if (itr!=styles_.end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
return feature_type_style();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#include "render.hpp"
|
||||
#include "image_util.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "named_style_cache.hpp"
|
||||
#include "symbolizer.hpp"
|
||||
#include "query.hpp"
|
||||
#include "feature_layer_desc.hpp"
|
||||
|
@ -36,7 +35,7 @@ namespace mapnik
|
|||
{
|
||||
|
||||
template <typename Image>
|
||||
void Renderer<Image>::render_vector_layer(datasource_p const& ds,
|
||||
void Renderer<Image>::render_vector_layer(datasource_p const& ds,Map const& map,
|
||||
std::vector<std::string> const& namedStyles,
|
||||
unsigned width,unsigned height,
|
||||
const Envelope<double>& bbox,Image& image)
|
||||
|
@ -45,7 +44,7 @@ namespace mapnik
|
|||
std::vector<std::string>::const_iterator stylesIter=namedStyles.begin();
|
||||
while (stylesIter!=namedStyles.end())
|
||||
{
|
||||
feature_type_style style=named_style_cache::instance()->find(*stylesIter++);
|
||||
//feature_type_style style=named_style_cache::instance()->find(*stylesIter++);
|
||||
|
||||
std::set<std::string> names;
|
||||
attribute_collector<Feature> collector(names);
|
||||
|
@ -56,6 +55,9 @@ namespace mapnik
|
|||
std::vector<rule_type*> else_rules;
|
||||
|
||||
bool active_rules=false;
|
||||
|
||||
feature_type_style style=map.find_style(*stylesIter++);
|
||||
|
||||
const std::vector<rule_type>& rules=style.get_rules();
|
||||
std::vector<rule_type>::const_iterator ruleIter=rules.begin();
|
||||
|
||||
|
@ -182,7 +184,7 @@ namespace mapnik
|
|||
if (!ds) continue;
|
||||
if (ds->type() == datasource::Vector)
|
||||
{
|
||||
render_vector_layer(ds,l.styles(),width,height,extent,image);
|
||||
render_vector_layer(ds,map,l.styles(),width,height,extent,image);
|
||||
}
|
||||
else if (ds->type() == datasource::Raster)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue