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)
|
||||
|
||||
cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
||||
cxx_release='-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG'
|
||||
cxx_debug='-Wall -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
||||
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)
|
||||
debug_env = env.Copy(CXXFLAGS = cxx_debug)
|
||||
#release_env = env.Copy(CXXFLAGS = cxx_release)
|
||||
#debug_env = env.Copy(CXXFLAGS = cxx_debug)
|
||||
|
||||
if ARGUMENTS.get('debug',0):
|
||||
env.Append(CXXFLAGS = cxx_debug)
|
||||
|
|
|
@ -29,11 +29,18 @@ filesystem_src_dir = boost_root + '/libs/filesystem/src/'
|
|||
boost_fs_src= glob.glob(filesystem_src_dir + '*.cpp')
|
||||
lib_boost_filesystem = env.SharedLibrary('libboost-filesystem',boost_fs_src,LIBS=[],CPPPATH=boost_root)
|
||||
env.Install(prefix+'/lib',lib_boost_filesystem)
|
||||
|
||||
#boost regex
|
||||
regex_src_dir = boost_root + '/libs/regex/src/'
|
||||
boost_regex_src = glob.glob(regex_src_dir+ '*.cpp')
|
||||
lib_boost_regex = env.SharedLibrary('libboost-regex',boost_regex_src,LIBS=[],CPPPATH=boost_root)
|
||||
|
||||
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::shared_ptr;
|
||||
|
||||
postgis_datasource::postgis_datasource(const Parameters& params)
|
||||
postgis_datasource::postgis_datasource(const parameters& params)
|
||||
: table_(params.get("table")),
|
||||
type_(datasource::Vector),
|
||||
desc_(params.get("name")),
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
featureset_ptr features(const query& q) const;
|
||||
mapnik::Envelope<double> const& envelope() const;
|
||||
layer_descriptor const& get_descriptor() const;
|
||||
postgis_datasource(const Parameters ¶ms);
|
||||
postgis_datasource(const parameters ¶ms);
|
||||
~postgis_datasource();
|
||||
private:
|
||||
static std::string table_from_sql(const std::string& sql);
|
||||
|
|
|
@ -31,7 +31,7 @@ using std::endl;
|
|||
using boost::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"))
|
||||
{
|
||||
filename_=params.get("file");
|
||||
|
|
|
@ -37,7 +37,7 @@ private:
|
|||
layer_descriptor desc_;
|
||||
static std::string name_;
|
||||
public:
|
||||
raster_datasource(const Parameters& params);
|
||||
raster_datasource(const parameters& params);
|
||||
virtual ~raster_datasource();
|
||||
int type() const;
|
||||
static std::string name();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
DATASOURCE_PLUGIN(shape_datasource);
|
||||
|
||||
shape_datasource::shape_datasource(const Parameters ¶ms)
|
||||
shape_datasource::shape_datasource(const parameters ¶ms)
|
||||
: shape_name_(params.get("file")),
|
||||
type_(datasource::Vector),
|
||||
file_length_(0),
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
static std::string name();
|
||||
featureset_ptr features(const query& q) const;
|
||||
const Envelope<double>& envelope() const;
|
||||
shape_datasource(const Parameters ¶ms);
|
||||
shape_datasource(const parameters ¶ms);
|
||||
layer_descriptor const& get_descriptor() const;
|
||||
virtual ~shape_datasource();
|
||||
private:
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace mapnik
|
|||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace mapnik
|
|||
{ \
|
||||
return classname::name();\
|
||||
}\
|
||||
extern "C" datasource* create(const Parameters ¶ms) \
|
||||
extern "C" datasource* create(const parameters ¶ms) \
|
||||
{ \
|
||||
return new classname(params); \
|
||||
}\
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace mapnik
|
|||
static bool insert(const std::string& name,const lt_dlhandle module);
|
||||
public:
|
||||
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
|
||||
|
|
|
@ -25,29 +25,45 @@
|
|||
#include "feature.hpp"
|
||||
#include "datasource.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class Layer
|
||||
{
|
||||
private:
|
||||
Parameters params_;
|
||||
friend class boost::serialization::access;
|
||||
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_;
|
||||
double minZoom_;
|
||||
double maxZoom_;
|
||||
bool active_;
|
||||
bool selectable_;
|
||||
datasource_p ds_;
|
||||
|
||||
std::vector<std::string> styles_;
|
||||
std::string selection_style_;
|
||||
|
||||
mutable datasource_p ds_;
|
||||
mutable std::vector<boost::shared_ptr<Feature> > selection_;
|
||||
|
||||
public:
|
||||
explicit Layer(const Parameters& params);
|
||||
Layer();
|
||||
explicit Layer(const parameters& params);
|
||||
Layer(Layer const& l);
|
||||
Layer& operator=(Layer const& l);
|
||||
bool operator==(Layer const& other) const;
|
||||
Parameters const& params() const;
|
||||
parameters const& params() const;
|
||||
const std::string& name() const;
|
||||
void add_style(std::string const& stylename);
|
||||
std::vector<std::string> const& styles() const;
|
||||
|
@ -72,4 +88,11 @@ namespace mapnik
|
|||
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
|
||||
|
|
|
@ -21,13 +21,25 @@
|
|||
#ifndef MAP_HPP
|
||||
#define MAP_HPP
|
||||
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class Layer;
|
||||
|
||||
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 MAX_MAPSIZE=1024;
|
||||
unsigned width_;
|
||||
|
@ -37,6 +49,7 @@ namespace mapnik
|
|||
std::vector<Layer> layers_;
|
||||
Envelope<double> currentExtent_;
|
||||
public:
|
||||
Map();
|
||||
Map(int width,int height,int srid=-1);
|
||||
Map(const Map& rhs);
|
||||
Map& operator=(const Map& rhs);
|
||||
|
@ -65,4 +78,11 @@ namespace mapnik
|
|||
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
|
||||
|
|
|
@ -71,6 +71,11 @@
|
|||
|
||||
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
|
||||
|
|
|
@ -22,26 +22,75 @@
|
|||
#define PARAMS_HPP
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
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;
|
||||
private:
|
||||
ParamMap data_;
|
||||
friend class boost::serialization::access;
|
||||
|
||||
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:
|
||||
typedef ParamMap::const_iterator const_iterator;
|
||||
Parameters() {}
|
||||
const std::string get(const std::string& name) const;
|
||||
void add(const Parameter& param);
|
||||
void add(const std::string& name,const std::string& value);
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
virtual ~Parameters();
|
||||
parameters() {}
|
||||
const std::string get(std::string const& key) const
|
||||
{
|
||||
param_map::const_iterator itr=find(key);
|
||||
if (itr != end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
using mapnik::Layer;
|
||||
using mapnik::Parameters;
|
||||
using mapnik::parameters;
|
||||
|
||||
struct layer_pickle_suite : boost::python::pickle_suite
|
||||
{
|
||||
|
@ -85,13 +85,13 @@ namespace
|
|||
using namespace boost::python;
|
||||
Layer create_layer(const dict& d)
|
||||
{
|
||||
Parameters params;
|
||||
parameters params;
|
||||
boost::python::list keys=d.keys();
|
||||
for (int i=0;i<len(keys);++i)
|
||||
{
|
||||
std::string key=extract<std::string>(keys[i]);
|
||||
std::string value=extract<std::string>(d[key]);
|
||||
params.add(key,value);
|
||||
params[key] = value;
|
||||
}
|
||||
return Layer(params);
|
||||
}
|
||||
|
|
|
@ -22,17 +22,16 @@
|
|||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <mapnik.hpp>
|
||||
|
||||
using mapnik::Parameter;
|
||||
using mapnik::Parameters;
|
||||
using mapnik::parameter;
|
||||
using mapnik::parameters;
|
||||
|
||||
|
||||
void (Parameters::*add1)(const Parameter&)=&Parameters::add;
|
||||
void (Parameters::*add2)(const std::string&,const std::string&)=&Parameters::add;
|
||||
//void (parameters::*add1)(const parameter&)=¶meters::insert;
|
||||
//void (parameters::*add2)(std::make_pair(const std::string&,const std::string&))=¶meters::insert;
|
||||
|
||||
struct parameter_pickle_suite : boost::python::pickle_suite
|
||||
{
|
||||
static boost::python::tuple
|
||||
getinitargs(const Parameter& p)
|
||||
getinitargs(const parameter& p)
|
||||
{
|
||||
using namespace boost::python;
|
||||
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
|
||||
{
|
||||
static boost::python::tuple
|
||||
getstate(const Parameters& p)
|
||||
getstate(const parameters& p)
|
||||
{
|
||||
using namespace boost::python;
|
||||
dict d;
|
||||
Parameters::const_iterator pos=p.begin();
|
||||
parameters::const_iterator pos=p.begin();
|
||||
while(pos!=p.end())
|
||||
{
|
||||
d[pos->first]=pos->second;
|
||||
|
@ -55,7 +54,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
|||
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;
|
||||
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 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()
|
||||
{
|
||||
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())
|
||||
;
|
||||
|
||||
class_<Parameters>("parameters",init<>())
|
||||
.def("add",add1)
|
||||
.def("add",add2)
|
||||
.def("get",&Parameters::get)
|
||||
class_<parameters>("parameters",init<>())
|
||||
//.def("add",add1)
|
||||
//.def("add",add2)
|
||||
.def("get",¶meters::get)
|
||||
.def_pickle(parameters_pickle_suite())
|
||||
;
|
||||
}
|
||||
|
|
|
@ -30,12 +30,13 @@ freetype2_root = env['FREETYPE2_ROOT']
|
|||
|
||||
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']
|
||||
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
||||
|
||||
source = Split(
|
||||
"""
|
||||
mapnik.cpp
|
||||
datasource_cache.cpp
|
||||
envelope.cpp
|
||||
graphics.cpp
|
||||
|
|
|
@ -42,12 +42,12 @@ namespace mapnik
|
|||
std::map<string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
|
||||
bool datasource_cache::registered_=false;
|
||||
|
||||
datasource_p datasource_cache::create(const Parameters& params)
|
||||
datasource_p datasource_cache::create(const parameters& params)
|
||||
{
|
||||
datasource_p ds;
|
||||
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);
|
||||
if (itr!=plugins_.end())
|
||||
{
|
||||
|
|
|
@ -18,35 +18,28 @@
|
|||
|
||||
//$Id: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "style.hpp"
|
||||
#include "datasource.hpp"
|
||||
#include "datasource_cache.hpp"
|
||||
#include "layer.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
Layer::Layer(const Parameters& params)
|
||||
Layer::Layer() {}
|
||||
Layer::Layer(const parameters& params)
|
||||
:params_(params),
|
||||
name_(params_["name"]),
|
||||
minZoom_(0),
|
||||
maxZoom_(std::numeric_limits<double>::max()),
|
||||
active_(true),
|
||||
selectable_(false),
|
||||
selection_style_("default_selection")
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
name_=params_.get("name");
|
||||
ds_=datasource_cache::instance()->create(params_);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
Layer::Layer(const Layer& rhs)
|
||||
:params_(rhs.params_),
|
||||
|
@ -55,7 +48,7 @@ namespace mapnik
|
|||
maxZoom_(rhs.maxZoom_),
|
||||
active_(rhs.active_),
|
||||
selectable_(rhs.selectable_),
|
||||
ds_(rhs.ds_),
|
||||
//ds_(rhs.ds_),
|
||||
styles_(rhs.styles_),
|
||||
selection_style_(rhs.selection_style_) {}
|
||||
|
||||
|
@ -79,14 +72,14 @@ namespace mapnik
|
|||
maxZoom_=rhs.maxZoom_;
|
||||
active_=rhs.active_;
|
||||
selectable_=rhs.selectable_;
|
||||
ds_=rhs.ds_;
|
||||
//ds_=rhs.ds_;
|
||||
styles_=rhs.styles_;
|
||||
selection_style_=rhs.selection_style_;
|
||||
}
|
||||
|
||||
Layer::~Layer() {}
|
||||
|
||||
Parameters const& Layer::params() const
|
||||
parameters const& Layer::params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
|
@ -153,13 +146,27 @@ namespace mapnik
|
|||
|
||||
const datasource_p& Layer::datasource() const
|
||||
{
|
||||
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
|
||||
{
|
||||
if (ds_)
|
||||
return ds_->envelope();
|
||||
datasource_p const& ds = datasource();
|
||||
if (ds)
|
||||
{
|
||||
return ds->envelope();
|
||||
}
|
||||
return Envelope<double>();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
Map::Map()
|
||||
: width_(400),
|
||||
height_(400),
|
||||
srid_(-1) {}
|
||||
Map::Map(int width,int height,int srid)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
|
|
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 $
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "params.hpp"
|
||||
|
||||
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() {}
|
||||
}
|
||||
|
|
|
@ -604,8 +604,6 @@ namespace mapnik
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename PixBuffer>
|
||||
inline void ScanlineRasterizerAA<PixBuffer>::render_hline(int x0,int x1,int y,unsigned rgba)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue