1.added serialization support
2.some class names changes
This commit is contained in:
parent
a6191fade0
commit
6f9528c2e3
23 changed files with 260 additions and 120 deletions
|
@ -41,11 +41,11 @@ build_prefix = build_dir+'/'+str(platform)
|
||||||
|
|
||||||
env = Environment(ENV=os.environ, options=opts)
|
env = Environment(ENV=os.environ, options=opts)
|
||||||
|
|
||||||
cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
cxx_debug='-Wall -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
||||||
cxx_release='-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG'
|
cxx_release='-Wall -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG '
|
||||||
|
|
||||||
release_env = env.Copy(CXXFLAGS = cxx_release)
|
#release_env = env.Copy(CXXFLAGS = cxx_release)
|
||||||
debug_env = env.Copy(CXXFLAGS = cxx_debug)
|
#debug_env = env.Copy(CXXFLAGS = cxx_debug)
|
||||||
|
|
||||||
if ARGUMENTS.get('debug',0):
|
if ARGUMENTS.get('debug',0):
|
||||||
env.Append(CXXFLAGS = cxx_debug)
|
env.Append(CXXFLAGS = cxx_debug)
|
||||||
|
|
|
@ -24,16 +24,23 @@ Import('env')
|
||||||
prefix = env['PREFIX']
|
prefix = env['PREFIX']
|
||||||
boost_root = env['BOOST_ROOT']
|
boost_root = env['BOOST_ROOT']
|
||||||
|
|
||||||
# boost filesystem
|
#boost filesystem
|
||||||
filesystem_src_dir = boost_root + '/libs/filesystem/src/'
|
filesystem_src_dir = boost_root + '/libs/filesystem/src/'
|
||||||
boost_fs_src= glob.glob(filesystem_src_dir + '*.cpp')
|
boost_fs_src= glob.glob(filesystem_src_dir + '*.cpp')
|
||||||
lib_boost_filesystem = env.SharedLibrary('libboost-filesystem',boost_fs_src,LIBS=[],CPPPATH=boost_root)
|
lib_boost_filesystem = env.SharedLibrary('libboost-filesystem',boost_fs_src,LIBS=[],CPPPATH=boost_root)
|
||||||
env.Install(prefix+'/lib',lib_boost_filesystem)
|
env.Install(prefix+'/lib',lib_boost_filesystem)
|
||||||
|
|
||||||
#boost regex
|
#boost regex
|
||||||
regex_src_dir = boost_root + '/libs/regex/src/'
|
regex_src_dir = boost_root + '/libs/regex/src/'
|
||||||
boost_regex_src = glob.glob(regex_src_dir+ '*.cpp')
|
boost_regex_src = glob.glob(regex_src_dir+ '*.cpp')
|
||||||
lib_boost_regex = env.SharedLibrary('libboost-regex',boost_regex_src,LIBS=[],CPPPATH=boost_root)
|
lib_boost_regex = env.SharedLibrary('libboost-regex',boost_regex_src,LIBS=[],CPPPATH=boost_root)
|
||||||
|
|
||||||
env.Install(prefix+'/lib',lib_boost_regex)
|
env.Install(prefix+'/lib',lib_boost_regex)
|
||||||
|
|
||||||
|
#boost serialization
|
||||||
|
serialization_src_dir = boost_root + '/libs/serialization/src/'
|
||||||
|
boost_serialization_src = glob.glob(serialization_src_dir+ '*.cpp')
|
||||||
|
#cxxflags = env['CXXFLAGS'] + " -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy"
|
||||||
|
#lib_boost_serialization = env.SharedLibrary('libboost-serialization',boost_serialization_src,CXXFLAGS=cxxflags,LIBS=[],CPPPATH=boost_root)
|
||||||
|
lib_boost_serialization = env.SharedLibrary('libboost-serialization',boost_serialization_src,LIBS=[],CPPPATH=boost_root)
|
||||||
|
env.Install(prefix+'/lib',lib_boost_serialization)
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ using boost::lexical_cast;
|
||||||
using boost::bad_lexical_cast;
|
using boost::bad_lexical_cast;
|
||||||
using boost::shared_ptr;
|
using boost::shared_ptr;
|
||||||
|
|
||||||
postgis_datasource::postgis_datasource(const Parameters& params)
|
postgis_datasource::postgis_datasource(const parameters& params)
|
||||||
: table_(params.get("table")),
|
: table_(params.get("table")),
|
||||||
type_(datasource::Vector),
|
type_(datasource::Vector),
|
||||||
desc_(params.get("name")),
|
desc_(params.get("name")),
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
featureset_ptr features(const query& q) const;
|
featureset_ptr features(const query& q) const;
|
||||||
mapnik::Envelope<double> const& envelope() const;
|
mapnik::Envelope<double> const& envelope() const;
|
||||||
layer_descriptor const& get_descriptor() const;
|
layer_descriptor const& get_descriptor() const;
|
||||||
postgis_datasource(const Parameters ¶ms);
|
postgis_datasource(const parameters ¶ms);
|
||||||
~postgis_datasource();
|
~postgis_datasource();
|
||||||
private:
|
private:
|
||||||
static std::string table_from_sql(const std::string& sql);
|
static std::string table_from_sql(const std::string& sql);
|
||||||
|
|
|
@ -31,7 +31,7 @@ using std::endl;
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
using boost::bad_lexical_cast;
|
using boost::bad_lexical_cast;
|
||||||
|
|
||||||
raster_datasource::raster_datasource(const Parameters& params)
|
raster_datasource::raster_datasource(const parameters& params)
|
||||||
: desc_(params.get("name"))
|
: desc_(params.get("name"))
|
||||||
{
|
{
|
||||||
filename_=params.get("file");
|
filename_=params.get("file");
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
layer_descriptor desc_;
|
layer_descriptor desc_;
|
||||||
static std::string name_;
|
static std::string name_;
|
||||||
public:
|
public:
|
||||||
raster_datasource(const Parameters& params);
|
raster_datasource(const parameters& params);
|
||||||
virtual ~raster_datasource();
|
virtual ~raster_datasource();
|
||||||
int type() const;
|
int type() const;
|
||||||
static std::string name();
|
static std::string name();
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(shape_datasource);
|
DATASOURCE_PLUGIN(shape_datasource);
|
||||||
|
|
||||||
shape_datasource::shape_datasource(const Parameters ¶ms)
|
shape_datasource::shape_datasource(const parameters ¶ms)
|
||||||
: shape_name_(params.get("file")),
|
: shape_name_(params.get("file")),
|
||||||
type_(datasource::Vector),
|
type_(datasource::Vector),
|
||||||
file_length_(0),
|
file_length_(0),
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
static std::string name();
|
static std::string name();
|
||||||
featureset_ptr features(const query& q) const;
|
featureset_ptr features(const query& q) const;
|
||||||
const Envelope<double>& envelope() const;
|
const Envelope<double>& envelope() const;
|
||||||
shape_datasource(const Parameters ¶ms);
|
shape_datasource(const parameters ¶ms);
|
||||||
layer_descriptor const& get_descriptor() const;
|
layer_descriptor const& get_descriptor() const;
|
||||||
virtual ~shape_datasource();
|
virtual ~shape_datasource();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace mapnik
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::string datasource_name();
|
typedef std::string datasource_name();
|
||||||
typedef datasource* create_ds(const Parameters& params);
|
typedef datasource* create_ds(const parameters& params);
|
||||||
typedef void destroy_ds(datasource *ds);
|
typedef void destroy_ds(datasource *ds);
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace mapnik
|
||||||
{ \
|
{ \
|
||||||
return classname::name();\
|
return classname::name();\
|
||||||
}\
|
}\
|
||||||
extern "C" datasource* create(const Parameters ¶ms) \
|
extern "C" datasource* create(const parameters ¶ms) \
|
||||||
{ \
|
{ \
|
||||||
return new classname(params); \
|
return new classname(params); \
|
||||||
}\
|
}\
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace mapnik
|
||||||
static bool insert(const std::string& name,const lt_dlhandle module);
|
static bool insert(const std::string& name,const lt_dlhandle module);
|
||||||
public:
|
public:
|
||||||
static void register_datasources(const std::string& path);
|
static void register_datasources(const std::string& path);
|
||||||
static boost::shared_ptr<datasource> create(Parameters const& params);
|
static boost::shared_ptr<datasource> create(parameters const& params);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //DATASOURCE_CACHE_HPP
|
#endif //DATASOURCE_CACHE_HPP
|
||||||
|
|
|
@ -25,29 +25,45 @@
|
||||||
#include "feature.hpp"
|
#include "feature.hpp"
|
||||||
#include "datasource.hpp"
|
#include "datasource.hpp"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/serialization/serialization.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
private:
|
friend class boost::serialization::access;
|
||||||
Parameters params_;
|
template <typename Archive>
|
||||||
|
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||||
|
{
|
||||||
|
ar & boost::serialization::make_nvp("name",name_)
|
||||||
|
& boost::serialization::make_nvp("params",params_)
|
||||||
|
& boost::serialization::make_nvp("min_zoom",minZoom_)
|
||||||
|
& boost::serialization::make_nvp("max_zoom",maxZoom_)
|
||||||
|
& boost::serialization::make_nvp("active",active_)
|
||||||
|
& boost::serialization::make_nvp("selectable",selectable_)
|
||||||
|
& boost::serialization::make_nvp("styles",styles_)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
parameters params_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
double minZoom_;
|
double minZoom_;
|
||||||
double maxZoom_;
|
double maxZoom_;
|
||||||
bool active_;
|
bool active_;
|
||||||
bool selectable_;
|
bool selectable_;
|
||||||
datasource_p ds_;
|
|
||||||
std::vector<std::string> styles_;
|
std::vector<std::string> styles_;
|
||||||
std::string selection_style_;
|
std::string selection_style_;
|
||||||
|
|
||||||
|
mutable datasource_p ds_;
|
||||||
mutable std::vector<boost::shared_ptr<Feature> > selection_;
|
mutable std::vector<boost::shared_ptr<Feature> > selection_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Layer(const Parameters& params);
|
Layer();
|
||||||
|
explicit Layer(const parameters& params);
|
||||||
Layer(Layer const& l);
|
Layer(Layer const& l);
|
||||||
Layer& operator=(Layer const& l);
|
Layer& operator=(Layer const& l);
|
||||||
bool operator==(Layer const& other) const;
|
bool operator==(Layer const& other) const;
|
||||||
Parameters const& params() const;
|
parameters const& params() const;
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
void add_style(std::string const& stylename);
|
void add_style(std::string const& stylename);
|
||||||
std::vector<std::string> const& styles() const;
|
std::vector<std::string> const& styles() const;
|
||||||
|
@ -72,4 +88,11 @@ namespace mapnik
|
||||||
void swap(const Layer& other);
|
void swap(const Layer& other);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(std::vector<std::string>, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(std::vector<std::string>, boost::serialization::track_never)
|
||||||
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(mapnik::Layer, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(mapnik::Layer, boost::serialization::track_never)
|
||||||
|
|
||||||
#endif //LAYER_HPP
|
#endif //LAYER_HPP
|
||||||
|
|
|
@ -21,13 +21,25 @@
|
||||||
#ifndef MAP_HPP
|
#ifndef MAP_HPP
|
||||||
#define MAP_HPP
|
#define MAP_HPP
|
||||||
|
|
||||||
|
#include <boost/serialization/serialization.hpp>
|
||||||
|
#include <boost/serialization/vector.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
class Layer;
|
class Layer;
|
||||||
|
|
||||||
class Map
|
class Map
|
||||||
{
|
{
|
||||||
private:
|
friend class boost::serialization::access;
|
||||||
|
template <typename Archive>
|
||||||
|
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||||
|
{
|
||||||
|
ar & boost::serialization::make_nvp("width",width_)
|
||||||
|
& boost::serialization::make_nvp("height",height_)
|
||||||
|
& boost::serialization::make_nvp("srid",srid_)
|
||||||
|
& boost::serialization::make_nvp("layers",layers_);
|
||||||
|
}
|
||||||
|
|
||||||
static const unsigned MIN_MAPSIZE=16;
|
static const unsigned MIN_MAPSIZE=16;
|
||||||
static const unsigned MAX_MAPSIZE=1024;
|
static const unsigned MAX_MAPSIZE=1024;
|
||||||
unsigned width_;
|
unsigned width_;
|
||||||
|
@ -37,6 +49,7 @@ namespace mapnik
|
||||||
std::vector<Layer> layers_;
|
std::vector<Layer> layers_;
|
||||||
Envelope<double> currentExtent_;
|
Envelope<double> currentExtent_;
|
||||||
public:
|
public:
|
||||||
|
Map();
|
||||||
Map(int width,int height,int srid=-1);
|
Map(int width,int height,int srid=-1);
|
||||||
Map(const Map& rhs);
|
Map(const Map& rhs);
|
||||||
Map& operator=(const Map& rhs);
|
Map& operator=(const Map& rhs);
|
||||||
|
@ -65,4 +78,11 @@ namespace mapnik
|
||||||
void fixAspectRatio();
|
void fixAspectRatio();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(std::vector<mapnik::Layer>, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(std::vector<mapnik::Layer>, boost::serialization::track_never)
|
||||||
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(mapnik::Map, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(mapnik::Map, boost::serialization::track_never)
|
||||||
|
|
||||||
#endif //MAP_HPP
|
#endif //MAP_HPP
|
||||||
|
|
|
@ -71,6 +71,11 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
void save_to_xml(Map const& map,const char* filename);
|
||||||
|
void save_to_text(Map const& map,const char* filename);
|
||||||
|
|
||||||
|
void load_from_xml(Map & map, const char * filename);
|
||||||
|
void load_from_text(Map & map, const char * filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //MAPNIK_HPP
|
#endif //MAPNIK_HPP
|
||||||
|
|
|
@ -22,26 +22,75 @@
|
||||||
#define PARAMS_HPP
|
#define PARAMS_HPP
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
//#include <boost/serialization/serialization.hpp>
|
||||||
|
//#include <boost/serialization/split_member.hpp>
|
||||||
|
//#include <boost/serialization/map.hpp>
|
||||||
|
#include <boost/serialization/serialization.hpp>
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
#include <boost/serialization/utility.hpp>
|
||||||
|
#include <boost/serialization/vector.hpp>
|
||||||
|
#include <boost/serialization/map.hpp>
|
||||||
|
#include <boost/serialization/string.hpp>
|
||||||
|
#include <boost/serialization/level.hpp>
|
||||||
|
#include <boost/serialization/tracking.hpp>
|
||||||
|
#include <boost/serialization/base_object.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::pair<std::string,std::string> Parameter;
|
typedef std::pair<const std::string,std::string> parameter;
|
||||||
|
typedef std::map<const std::string,std::string> param_map;
|
||||||
|
|
||||||
class Parameters
|
class parameters : public param_map
|
||||||
{
|
{
|
||||||
typedef std::map<std::string,std::string> ParamMap;
|
friend class boost::serialization::access;
|
||||||
private:
|
|
||||||
ParamMap data_;
|
template <typename Archive>
|
||||||
|
void save(Archive & ar, const unsigned int /*version*/) const
|
||||||
|
{
|
||||||
|
const size_t size = param_map::size();
|
||||||
|
ar & boost::serialization::make_nvp("count",size);
|
||||||
|
param_map::const_iterator itr;
|
||||||
|
for (itr=param_map::begin();itr!=param_map::end();++itr)
|
||||||
|
{
|
||||||
|
ar & boost::serialization::make_nvp("name",itr->first);
|
||||||
|
ar & boost::serialization::make_nvp("value",itr->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Archive>
|
||||||
|
void load(Archive & ar, const unsigned int /*version*/)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
ar & boost::serialization::make_nvp("size",size);
|
||||||
|
for (size_t i=0;i<size;++i)
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string value;
|
||||||
|
ar & boost::serialization::make_nvp("name",name);
|
||||||
|
ar & boost::serialization::make_nvp("value",value);
|
||||||
|
param_map::insert(make_pair(name,value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||||
public:
|
public:
|
||||||
typedef ParamMap::const_iterator const_iterator;
|
parameters() {}
|
||||||
Parameters() {}
|
const std::string get(std::string const& key) const
|
||||||
const std::string get(const std::string& name) const;
|
{
|
||||||
void add(const Parameter& param);
|
param_map::const_iterator itr=find(key);
|
||||||
void add(const std::string& name,const std::string& value);
|
if (itr != end())
|
||||||
const_iterator begin() const;
|
{
|
||||||
const_iterator end() const;
|
return itr->second;
|
||||||
virtual ~Parameters();
|
}
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //PARAMS_HPP
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(mapnik::parameter, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(mapnik::parameter, boost::serialization::track_never)
|
||||||
|
|
||||||
|
BOOST_CLASS_IMPLEMENTATION(mapnik::parameters, boost::serialization::object_serializable)
|
||||||
|
BOOST_CLASS_TRACKING(mapnik::parameters, boost::serialization::track_never)
|
||||||
|
|
||||||
|
#endif //PARAMS_HPP
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <mapnik.hpp>
|
#include <mapnik.hpp>
|
||||||
|
|
||||||
using mapnik::Layer;
|
using mapnik::Layer;
|
||||||
using mapnik::Parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
struct layer_pickle_suite : boost::python::pickle_suite
|
struct layer_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
|
@ -85,13 +85,13 @@ namespace
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
Layer create_layer(const dict& d)
|
Layer create_layer(const dict& d)
|
||||||
{
|
{
|
||||||
Parameters params;
|
parameters params;
|
||||||
boost::python::list keys=d.keys();
|
boost::python::list keys=d.keys();
|
||||||
for (int i=0;i<len(keys);++i)
|
for (int i=0;i<len(keys);++i)
|
||||||
{
|
{
|
||||||
std::string key=extract<std::string>(keys[i]);
|
std::string key=extract<std::string>(keys[i]);
|
||||||
std::string value=extract<std::string>(d[key]);
|
std::string value=extract<std::string>(d[key]);
|
||||||
params.add(key,value);
|
params[key] = value;
|
||||||
}
|
}
|
||||||
return Layer(params);
|
return Layer(params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,16 @@
|
||||||
#include <boost/python/detail/api_placeholder.hpp>
|
#include <boost/python/detail/api_placeholder.hpp>
|
||||||
#include <mapnik.hpp>
|
#include <mapnik.hpp>
|
||||||
|
|
||||||
using mapnik::Parameter;
|
using mapnik::parameter;
|
||||||
using mapnik::Parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
|
//void (parameters::*add1)(const parameter&)=¶meters::insert;
|
||||||
void (Parameters::*add1)(const Parameter&)=&Parameters::add;
|
//void (parameters::*add2)(std::make_pair(const std::string&,const std::string&))=¶meters::insert;
|
||||||
void (Parameters::*add2)(const std::string&,const std::string&)=&Parameters::add;
|
|
||||||
|
|
||||||
struct parameter_pickle_suite : boost::python::pickle_suite
|
struct parameter_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
getinitargs(const Parameter& p)
|
getinitargs(const parameter& p)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
return boost::python::make_tuple(p.first,p.second);
|
return boost::python::make_tuple(p.first,p.second);
|
||||||
|
@ -42,11 +41,11 @@ struct parameter_pickle_suite : boost::python::pickle_suite
|
||||||
struct parameters_pickle_suite : boost::python::pickle_suite
|
struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
getstate(const Parameters& p)
|
getstate(const parameters& p)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
dict d;
|
dict d;
|
||||||
Parameters::const_iterator pos=p.begin();
|
parameters::const_iterator pos=p.begin();
|
||||||
while(pos!=p.end())
|
while(pos!=p.end())
|
||||||
{
|
{
|
||||||
d[pos->first]=pos->second;
|
d[pos->first]=pos->second;
|
||||||
|
@ -55,7 +54,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
return boost::python::make_tuple(d);
|
return boost::python::make_tuple(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setstate(Parameters& p, boost::python::tuple state)
|
static void setstate(parameters& p, boost::python::tuple state)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
if (len(state) != 1)
|
if (len(state) != 1)
|
||||||
|
@ -72,7 +71,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
std::string key=extract<std::string>(keys[i]);
|
std::string key=extract<std::string>(keys[i]);
|
||||||
std::string value=extract<std::string>(d[key]);
|
std::string value=extract<std::string>(d[key]);
|
||||||
p.add(key,value);
|
p[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -81,14 +80,14 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
void export_parameters()
|
void export_parameters()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
class_<Parameter>("parameter",init<std::string,std::string>())
|
class_<parameter>("parameter",init<std::string,std::string>())
|
||||||
.def_pickle(parameter_pickle_suite())
|
.def_pickle(parameter_pickle_suite())
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<Parameters>("parameters",init<>())
|
class_<parameters>("parameters",init<>())
|
||||||
.def("add",add1)
|
//.def("add",add1)
|
||||||
.def("add",add2)
|
//.def("add",add2)
|
||||||
.def("get",&Parameters::get)
|
.def("get",¶meters::get)
|
||||||
.def_pickle(parameters_pickle_suite())
|
.def_pickle(parameters_pickle_suite())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,13 @@ freetype2_root = env['FREETYPE2_ROOT']
|
||||||
|
|
||||||
headers =[ '#include',boost_root,freetype2_root,agg_headers]
|
headers =[ '#include',boost_root,freetype2_root,agg_headers]
|
||||||
|
|
||||||
libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex']
|
libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex','boost-serialization']
|
||||||
libpaths = [prefix+'/lib','#agg']
|
libpaths = [prefix+'/lib','#agg']
|
||||||
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
||||||
|
|
||||||
source = Split(
|
source = Split(
|
||||||
"""
|
"""
|
||||||
|
mapnik.cpp
|
||||||
datasource_cache.cpp
|
datasource_cache.cpp
|
||||||
envelope.cpp
|
envelope.cpp
|
||||||
graphics.cpp
|
graphics.cpp
|
||||||
|
|
|
@ -42,12 +42,12 @@ namespace mapnik
|
||||||
std::map<string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
|
std::map<string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
|
||||||
bool datasource_cache::registered_=false;
|
bool datasource_cache::registered_=false;
|
||||||
|
|
||||||
datasource_p datasource_cache::create(const Parameters& params)
|
datasource_p datasource_cache::create(const parameters& params)
|
||||||
{
|
{
|
||||||
datasource_p ds;
|
datasource_p ds;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string type=params.get("type");
|
const std::string type=params.get("type");
|
||||||
map<string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(type);
|
map<string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(type);
|
||||||
if (itr!=plugins_.end())
|
if (itr!=plugins_.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,35 +18,28 @@
|
||||||
|
|
||||||
//$Id: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
//$Id: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "style.hpp"
|
#include "style.hpp"
|
||||||
#include "datasource.hpp"
|
#include "datasource.hpp"
|
||||||
#include "datasource_cache.hpp"
|
#include "datasource_cache.hpp"
|
||||||
#include "layer.hpp"
|
#include "layer.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
Layer::Layer() {}
|
||||||
Layer::Layer(const Parameters& params)
|
Layer::Layer(const parameters& params)
|
||||||
:params_(params),
|
:params_(params),
|
||||||
|
name_(params_["name"]),
|
||||||
minZoom_(0),
|
minZoom_(0),
|
||||||
maxZoom_(std::numeric_limits<double>::max()),
|
maxZoom_(std::numeric_limits<double>::max()),
|
||||||
active_(true),
|
active_(true),
|
||||||
selectable_(false),
|
selectable_(false),
|
||||||
selection_style_("default_selection")
|
selection_style_("default_selection")
|
||||||
{
|
{}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
name_=params_.get("name");
|
|
||||||
ds_=datasource_cache::instance()->create(params_);
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Layer::Layer(const Layer& rhs)
|
Layer::Layer(const Layer& rhs)
|
||||||
:params_(rhs.params_),
|
:params_(rhs.params_),
|
||||||
|
@ -55,7 +48,7 @@ namespace mapnik
|
||||||
maxZoom_(rhs.maxZoom_),
|
maxZoom_(rhs.maxZoom_),
|
||||||
active_(rhs.active_),
|
active_(rhs.active_),
|
||||||
selectable_(rhs.selectable_),
|
selectable_(rhs.selectable_),
|
||||||
ds_(rhs.ds_),
|
//ds_(rhs.ds_),
|
||||||
styles_(rhs.styles_),
|
styles_(rhs.styles_),
|
||||||
selection_style_(rhs.selection_style_) {}
|
selection_style_(rhs.selection_style_) {}
|
||||||
|
|
||||||
|
@ -79,14 +72,14 @@ namespace mapnik
|
||||||
maxZoom_=rhs.maxZoom_;
|
maxZoom_=rhs.maxZoom_;
|
||||||
active_=rhs.active_;
|
active_=rhs.active_;
|
||||||
selectable_=rhs.selectable_;
|
selectable_=rhs.selectable_;
|
||||||
ds_=rhs.ds_;
|
//ds_=rhs.ds_;
|
||||||
styles_=rhs.styles_;
|
styles_=rhs.styles_;
|
||||||
selection_style_=rhs.selection_style_;
|
selection_style_=rhs.selection_style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer::~Layer() {}
|
Layer::~Layer() {}
|
||||||
|
|
||||||
Parameters const& Layer::params() const
|
parameters const& Layer::params() const
|
||||||
{
|
{
|
||||||
return params_;
|
return params_;
|
||||||
}
|
}
|
||||||
|
@ -153,14 +146,28 @@ namespace mapnik
|
||||||
|
|
||||||
const datasource_p& Layer::datasource() const
|
const datasource_p& Layer::datasource() const
|
||||||
{
|
{
|
||||||
return ds_;
|
if (!ds_)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ds_=datasource_cache::instance()->create(params_);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr << "exception caught : can not create datasorce" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ds_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Envelope<double> Layer::envelope() const
|
Envelope<double> Layer::envelope() const
|
||||||
{
|
{
|
||||||
if (ds_)
|
datasource_p const& ds = datasource();
|
||||||
return ds_->envelope();
|
if (ds)
|
||||||
return Envelope<double>();
|
{
|
||||||
|
return ds->envelope();
|
||||||
|
}
|
||||||
|
return Envelope<double>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::selection_style(const std::string& name)
|
void Layer::selection_style(const std::string& name)
|
||||||
|
|
11
src/map.cpp
11
src/map.cpp
|
@ -25,12 +25,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
Map::Map()
|
||||||
|
: width_(400),
|
||||||
|
height_(400),
|
||||||
|
srid_(-1) {}
|
||||||
Map::Map(int width,int height,int srid)
|
Map::Map(int width,int height,int srid)
|
||||||
: width_(width),
|
: width_(width),
|
||||||
height_(height),
|
height_(height),
|
||||||
srid_(srid),
|
srid_(srid),
|
||||||
background_(Color(255,255,255)) {}
|
background_(Color(255,255,255)) {}
|
||||||
|
|
||||||
Map::Map(const Map& rhs)
|
Map::Map(const Map& rhs)
|
||||||
: width_(rhs.width_),
|
: width_(rhs.width_),
|
||||||
|
|
61
src/mapnik.cpp
Normal file
61
src/mapnik.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/* 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$
|
||||||
|
|
||||||
|
#include "mapnik.hpp"
|
||||||
|
#include <fstream>
|
||||||
|
#include <boost/archive/text_oarchive.hpp>
|
||||||
|
#include <boost/archive/text_iarchive.hpp>
|
||||||
|
#include <boost/archive/xml_iarchive.hpp>
|
||||||
|
#include <boost/archive/xml_oarchive.hpp>
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
void save_to_xml(Map const& m,const char* filename)
|
||||||
|
{
|
||||||
|
std::ofstream ofs(filename);
|
||||||
|
assert(ofs.good());
|
||||||
|
boost::archive::xml_oarchive oa(ofs);
|
||||||
|
oa << boost::serialization::make_nvp("map",m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void save_to_text(Map const& m,const char* filename)
|
||||||
|
{
|
||||||
|
std::ofstream ofs(filename);
|
||||||
|
assert(ofs.good());
|
||||||
|
boost::archive::text_oarchive oa(ofs);
|
||||||
|
oa << m;
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_from_xml(Map & m,const char* filename)
|
||||||
|
{
|
||||||
|
std::ifstream ifs(filename);
|
||||||
|
assert(ifs.good());
|
||||||
|
boost::archive::xml_iarchive ia(ifs);
|
||||||
|
ia >> boost::serialization::make_nvp("map",m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_from_text(Map & m,const char* filename)
|
||||||
|
{
|
||||||
|
std::ifstream ifs(filename);
|
||||||
|
assert(ifs.good());
|
||||||
|
boost::archive::text_iarchive ia(ifs);
|
||||||
|
ia >> m;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,42 +18,9 @@
|
||||||
|
|
||||||
//$Id: params.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
//$Id: params.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include "params.hpp"
|
#include "params.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::string Parameters::get(const std::string& name) const
|
|
||||||
{
|
|
||||||
std::map<std::string,std::string>::const_iterator itr;
|
|
||||||
itr=data_.find(name);
|
|
||||||
if (itr!=data_.end())
|
|
||||||
return itr->second;
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parameters::add(const Parameter& param)
|
|
||||||
{
|
|
||||||
data_.insert(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parameters::add(const std::string& name,const std::string& value)
|
|
||||||
{
|
|
||||||
Parameter param(name,value);
|
|
||||||
data_.insert(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string,std::string>::const_iterator Parameters::begin() const
|
|
||||||
{
|
|
||||||
return data_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string,std::string>::const_iterator Parameters::end() const
|
|
||||||
{
|
|
||||||
return data_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
Parameters::~Parameters() {}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -603,9 +603,7 @@ namespace mapnik
|
||||||
pixbuf_->blendPixel(x,y,rgba,alpha);
|
pixbuf_->blendPixel(x,y,rgba,alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename PixBuffer>
|
template <typename PixBuffer>
|
||||||
inline void ScanlineRasterizerAA<PixBuffer>::render_hline(int x0,int x1,int y,unsigned rgba)
|
inline void ScanlineRasterizerAA<PixBuffer>::render_hline(int x0,int x1,int y,unsigned rgba)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue