1. datasource is now a property of Layer object.
2. modified python/c++ demos to reflect the above. 3. removed large 'blobby' mapnik.hpp (compilation times!!!)
This commit is contained in:
parent
88892c196b
commit
8328424af5
19 changed files with 221 additions and 350 deletions
|
@ -33,7 +33,7 @@ void export_datasource_cache()
|
|||
using namespace boost::python;
|
||||
class_<singleton<datasource_cache,CreateStatic>,boost::noncopyable>("Singleton",no_init)
|
||||
.def("instance",&singleton<datasource_cache,CreateStatic>::instance,
|
||||
return_value_policy<reference_existing_object>())
|
||||
return_value_policy<reference_existing_object>())
|
||||
.staticmethod("instance")
|
||||
;
|
||||
|
||||
|
@ -41,7 +41,7 @@ void export_datasource_cache()
|
|||
boost::noncopyable>("DatasourceCache",no_init)
|
||||
.def("create",&datasource_cache::create)
|
||||
.staticmethod("create")
|
||||
.def("register_datasources",&datasource_cache::register_datasources)
|
||||
.staticmethod("register_datasources")
|
||||
.def("register_datasources",&datasource_cache::register_datasources)
|
||||
.staticmethod("register_datasources")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -60,29 +60,32 @@ bool (Envelope<double>::*intersects_p3)(Envelope<double> const&) const = &Envelo
|
|||
void export_envelope()
|
||||
{
|
||||
using namespace boost::python;
|
||||
class_<Envelope<double> >("Envelope","A spacial envelope (i.e. bounding box) which also defines some basic operators.",init<double,double,double,double>())
|
||||
class_<Envelope<double> >("Envelope",
|
||||
"A spacial envelope (i.e. bounding box) "
|
||||
"which also defines some basic operators." ,
|
||||
init<double,double,double,double>())
|
||||
.def(init<>())
|
||||
.def(init<const coord<double,2>&, const coord<double,2>&>())
|
||||
.def(init<const coord<double,2>&, const coord<double,2>&>())
|
||||
.add_property("minx",&Envelope<double>::minx, "X coordinate for the lower left corner")
|
||||
.add_property("miny",&Envelope<double>::miny, "Y coordinate for the lower left corner")
|
||||
.add_property("maxx",&Envelope<double>::maxx, "X coordinate for the upper right corner")
|
||||
.add_property("maxy",&Envelope<double>::maxy, "Y coordinate for the upper right corner")
|
||||
.def("center",&Envelope<double>::center)
|
||||
.def("center",&Envelope<double>::re_center)
|
||||
.def("width",width_p1)
|
||||
.def("width",width_p2)
|
||||
.def("height",height_p1)
|
||||
.def("height",height_p2)
|
||||
.def("expand_to_include",expand_to_include_p1)
|
||||
.def("expand_to_include",expand_to_include_p2)
|
||||
.def("expand_to_include",expand_to_include_p3)
|
||||
.def("contains",contains_p1)
|
||||
.def("contains",contains_p2)
|
||||
.def("contains",contains_p3)
|
||||
.def("intersects",intersects_p1)
|
||||
.def("intersects",intersects_p2)
|
||||
.def("intersects",intersects_p3)
|
||||
.def(self == self)
|
||||
.def("center",&Envelope<double>::re_center)
|
||||
.def("width",width_p1)
|
||||
.def("width",width_p2)
|
||||
.def("height",height_p1)
|
||||
.def("height",height_p2)
|
||||
.def("expand_to_include",expand_to_include_p1)
|
||||
.def("expand_to_include",expand_to_include_p2)
|
||||
.def("expand_to_include",expand_to_include_p3)
|
||||
.def("contains",contains_p1)
|
||||
.def("contains",contains_p2)
|
||||
.def("contains",contains_p3)
|
||||
.def("intersects",intersects_p1)
|
||||
.def("intersects",intersects_p2)
|
||||
.def("intersects",intersects_p3)
|
||||
.def(self == self)
|
||||
.def_pickle(envelope_pickle_suite())
|
||||
;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <regex_filter.hpp>
|
||||
#include <filter.hpp>
|
||||
#include <filter_factory.hpp>
|
||||
#include <mapnik.hpp>
|
||||
|
||||
using mapnik::filter;
|
||||
using mapnik::filter_ptr;
|
||||
|
|
|
@ -30,76 +30,6 @@
|
|||
using mapnik::Layer;
|
||||
using mapnik::parameters;
|
||||
|
||||
struct layer_pickle_suite : boost::python::pickle_suite
|
||||
{
|
||||
|
||||
static boost::python::tuple
|
||||
getinitargs(const Layer& l)
|
||||
{
|
||||
using namespace boost::python;
|
||||
return boost::python::make_tuple(l.params());
|
||||
}
|
||||
static boost::python::tuple
|
||||
getstate(const Layer& l)
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
std::vector<std::string> const& styles=l.styles();
|
||||
std::vector<std::string>::const_iterator itr=styles.begin();
|
||||
boost::python::list py_styles;
|
||||
|
||||
while (itr!=styles.end())
|
||||
{
|
||||
py_styles.append(*itr++);
|
||||
}
|
||||
|
||||
return boost::python::make_tuple(l.getMinZoom(),
|
||||
l.getMaxZoom(),
|
||||
py_styles);
|
||||
}
|
||||
|
||||
static void
|
||||
setstate (Layer& l, boost::python::tuple state)
|
||||
{
|
||||
using namespace boost::python;
|
||||
if (len(state) != 3)
|
||||
{
|
||||
PyErr_SetObject(PyExc_ValueError,
|
||||
("expected 3-item tuple in call to __setstate__; got %s"
|
||||
% state).ptr()
|
||||
);
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
l.setMinZoom(extract<double>(state[0]));
|
||||
l.setMaxZoom(extract<double>(state[1]));
|
||||
|
||||
boost::python::list styles=extract<boost::python::list>(state[2]);
|
||||
for (int i=0;i<len(styles);++i)
|
||||
{
|
||||
l.add_style(extract<std::string>(styles[i]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
//user-friendly wrapper that uses Python dictionary
|
||||
using namespace boost::python;
|
||||
Layer create_layer(const dict& d)
|
||||
{
|
||||
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[key] = value;
|
||||
}
|
||||
return Layer(params);
|
||||
}
|
||||
}
|
||||
|
||||
void export_layer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
@ -107,17 +37,42 @@ void export_layer()
|
|||
.def(vector_indexing_suite<std::vector<std::string>,true >())
|
||||
;
|
||||
|
||||
class_<Layer>("Layer","A map layer.",no_init)
|
||||
.def("name",&Layer::name,return_value_policy<copy_const_reference>(), "Return the name of the layer.")
|
||||
.def("title",&Layer::title,return_value_policy<copy_const_reference>(), "Return the title of the layer.")
|
||||
.def("abstract",&Layer::abstract,return_value_policy<copy_const_reference>(), "Return the abstract of the layer.")
|
||||
.def("params",&Layer::params,return_value_policy<reference_existing_object>(), "The configuration parameters of the layer. These vary depending on the type of data source.")
|
||||
.def("envelope",&Layer::envelope, "Return the geographic envelope/bounding box of the data in the layer.")
|
||||
.add_property("minzoom",&Layer::getMinZoom,&Layer::setMinZoom)
|
||||
.add_property("maxzoom",&Layer::getMaxZoom,&Layer::setMaxZoom)
|
||||
.add_property("styles",make_function
|
||||
(&Layer::styles,return_value_policy<reference_existing_object>()))
|
||||
.def_pickle(layer_pickle_suite())
|
||||
class_<Layer>("Layer","A map layer.", init<std::string const&>())
|
||||
.add_property("name",
|
||||
make_function(&Layer::name, return_value_policy<reference_existing_object>()),
|
||||
&Layer::set_name,
|
||||
"Get/Set the name of the layer.")
|
||||
|
||||
.add_property("title",
|
||||
make_function(&Layer::title, return_value_policy<reference_existing_object>()),
|
||||
&Layer::set_title,
|
||||
"Get/Set the title of the layer.")
|
||||
|
||||
.add_property("abstract",
|
||||
make_function(&Layer::abstract,return_value_policy<reference_existing_object>()),
|
||||
&Layer::set_abstract,
|
||||
"Get/Set the abstract of the layer.")
|
||||
|
||||
.add_property("minzoom",
|
||||
&Layer::getMinZoom,
|
||||
&Layer::setMinZoom)
|
||||
|
||||
.add_property("maxzoom",
|
||||
&Layer::getMaxZoom,
|
||||
&Layer::setMaxZoom)
|
||||
|
||||
.add_property("styles",
|
||||
make_function(&Layer::styles,
|
||||
return_value_policy<reference_existing_object>()))
|
||||
|
||||
.add_property("datasource",
|
||||
&Layer::datasource,
|
||||
&Layer::set_datasource,
|
||||
"The datasource attached to this layer")
|
||||
|
||||
.def("envelope",&Layer::envelope,
|
||||
"Return the geographic envelope/bounding box "
|
||||
"of the data in the layer.")
|
||||
|
||||
;
|
||||
def("CreateLayer",&create_layer);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
|
||||
//#include <mapnik.hpp>
|
||||
|
||||
void export_color();
|
||||
void export_layer();
|
||||
void export_parameters();
|
||||
|
@ -49,12 +47,10 @@ void export_raster_symbolizer();
|
|||
void export_text_symbolizer();
|
||||
void export_font_engine();
|
||||
|
||||
//using namespace mapnik;
|
||||
#include <map.hpp>
|
||||
#include <agg_renderer.hpp>
|
||||
#include <graphics.hpp>
|
||||
//#include <filter.hpp>
|
||||
//#include <coord.hpp>
|
||||
#include <datasource_cache.hpp>
|
||||
|
||||
void render_to_file(const mapnik::Map& map,
|
||||
const std::string& file,
|
||||
|
@ -72,6 +68,25 @@ void render(const mapnik::Map& map,mapnik::Image32& image)
|
|||
ren.apply();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//user-friendly wrapper that uses Python dictionary
|
||||
using namespace boost::python;
|
||||
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
|
||||
{
|
||||
mapnik::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[key] = value;
|
||||
}
|
||||
|
||||
return mapnik::datasource_cache::create(params);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_MODULE(_mapnik)
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
@ -87,11 +102,16 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
;
|
||||
|
||||
class_<datasource,boost::shared_ptr<datasource>,
|
||||
boost::noncopyable>("Datasource",no_init)
|
||||
.def("envelope",&datasource::envelope,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("features",&datasource::features)
|
||||
;
|
||||
boost::noncopyable>("Datasource",no_init)
|
||||
.def("envelope",&datasource::envelope,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("features",&datasource::features)
|
||||
.def("params",&datasource::params,return_value_policy<reference_existing_object>(),
|
||||
"The configuration parameters of the data source. "
|
||||
"These vary depending on the type of data source.")
|
||||
;
|
||||
|
||||
def("CreateDatasource",&create_datasource);
|
||||
|
||||
export_parameters();
|
||||
export_color();
|
||||
|
@ -111,6 +131,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
export_raster_symbolizer();
|
||||
export_text_symbolizer();
|
||||
export_font_engine();
|
||||
|
||||
class_<coord<double,2> >("Coord",init<double,double>())
|
||||
.def_readwrite("x", &coord<double,2>::x)
|
||||
.def_readwrite("y", &coord<double,2>::y)
|
||||
|
|
|
@ -34,13 +34,13 @@ void export_style()
|
|||
using mapnik::rules;
|
||||
|
||||
class_<rules>("Rules",init<>("default ctor"))
|
||||
.def(vector_indexing_suite<rules>())
|
||||
;
|
||||
.def(vector_indexing_suite<rules>())
|
||||
;
|
||||
class_<feature_type_style>("Style",init<>("default style constructor"))
|
||||
.add_property("rules",make_function
|
||||
(&feature_type_style::get_rules,
|
||||
return_value_policy<reference_existing_object>()))
|
||||
;
|
||||
.add_property("rules",make_function
|
||||
(&feature_type_style::get_rules,
|
||||
return_value_policy<reference_existing_object>()))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
|
||||
#include <mapnik.hpp>
|
||||
#include <map.hpp>
|
||||
|
||||
#include <datasource_cache.hpp>
|
||||
#include <font_engine_freetype.hpp>
|
||||
#include <agg_renderer.hpp>
|
||||
#include <filter_factory.hpp>
|
||||
#include <color_factory.hpp>
|
||||
#include <image_util.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace mapnik;
|
||||
|
@ -133,11 +141,11 @@ int main ( int argc , char** argv)
|
|||
// Provincial polygons
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Provinces";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/boundaries";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Provinces");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("provinces");
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
|
@ -145,21 +153,21 @@ int main ( int argc , char** argv)
|
|||
// Drainage
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Quebec Hydrography";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/qcdrainage";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Quebec Hydrography");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("drainage");
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Ontario Hydrography";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/ontdrainage";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Ontario Hydrography");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("drainage");
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
|
@ -167,11 +175,10 @@ int main ( int argc , char** argv)
|
|||
// Provincial boundaries
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Provincial borders";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/boundaries_l";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Provincial borders");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("provlines");
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
|
@ -179,29 +186,29 @@ int main ( int argc , char** argv)
|
|||
// Roads
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Roads";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/roads";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Roads");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("smallroads");
|
||||
lyr.add_style("road-border");
|
||||
lyr.add_style("road-fill");
|
||||
lyr.add_style("highway-border");
|
||||
lyr.add_style("highway-fill");
|
||||
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
// popplaces
|
||||
{
|
||||
parameters p;
|
||||
p["name"]="Populated Places";
|
||||
p["type"]="shape";
|
||||
p["file"]="../data/popplaces";
|
||||
|
||||
Layer lyr(p);
|
||||
Layer lyr("Populated Places");
|
||||
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||
lyr.add_style("popplaces");
|
||||
m.addLayer(lyr);
|
||||
}
|
||||
|
||||
m.zoomToBox(Envelope<double>(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577));
|
||||
|
||||
Image32 buf(m.getWidth(),m.getHeight());
|
||||
|
|
|
@ -55,7 +55,8 @@ m.background = Color('white')
|
|||
# password='mypassword'
|
||||
# table= TODO
|
||||
|
||||
provpoly_lyr = Layer(name='Provinces', type='shape', file='../data/boundaries')
|
||||
provpoly_lyr = Layer('Provinces')
|
||||
provpoly_lyr.datasource = Datasource(type='shape', file='../data/boundaries')
|
||||
|
||||
# We then define a style for the layer. A layer can have one or many styles.
|
||||
# Styles are named, so they can be shared across different layers.
|
||||
|
@ -118,8 +119,10 @@ m.layers.append(provpoly_lyr)
|
|||
|
||||
# A simple example ...
|
||||
|
||||
qcdrain_lyr = Layer(name='Quebec Hydrography', type='shape',
|
||||
file='../data/qcdrainage')
|
||||
qcdrain_lyr = Layer('Quebec Hydrography')
|
||||
|
||||
qcdrain_lyr.datasource = Datasource( type='shape',
|
||||
file='../data/qcdrainage')
|
||||
|
||||
qcdrain_style = Style()
|
||||
qcdrain_rule = Rule()
|
||||
|
@ -135,15 +138,18 @@ m.layers.append(qcdrain_lyr)
|
|||
# attributes, and same desired style), so we're going to
|
||||
# re-use the style defined in the above layer for the next one.
|
||||
|
||||
ondrain_lyr = Layer(name='Ontario Hydrography', type='shape',
|
||||
file='../data/ontdrainage')
|
||||
ondrain_lyr = Layer('Ontario Hydrography')
|
||||
ondrain_lyr.datasource = Datasource(type='shape',
|
||||
file='../data/ontdrainage')
|
||||
|
||||
ondrain_lyr.styles.append('drainage')
|
||||
m.layers.append(ondrain_lyr)
|
||||
|
||||
# Provincial boundaries
|
||||
|
||||
provlines_lyr = Layer(name='Provincial borders', type='shape',
|
||||
file='../data/boundaries_l')
|
||||
provlines_lyr = Layer('Provincial borders')
|
||||
provlines_lyr.datasource = Datasource (type='shape',
|
||||
file='../data/boundaries_l')
|
||||
|
||||
# Here we define a "dash dot dot dash" pattern for the provincial boundaries.
|
||||
|
||||
|
@ -165,7 +171,8 @@ m.layers.append(provlines_lyr)
|
|||
|
||||
# Roads 3 and 4 (The "grey" roads)
|
||||
|
||||
roads34_lyr = Layer(name='Roads', type='shape', file='../data/roads')
|
||||
roads34_lyr = Layer('Roads')
|
||||
roads34_lyr.datasource = Datasource(type='shape', file='../data/roads')
|
||||
|
||||
roads34_style = Style()
|
||||
roads34_rule = Rule()
|
||||
|
@ -195,7 +202,8 @@ m.layers.append(roads34_lyr)
|
|||
|
||||
# Roads 2 (The thin yellow ones)
|
||||
|
||||
roads2_lyr = Layer(name='Roads', type='shape', file='../data/roads')
|
||||
roads2_lyr = Layer('Roads')
|
||||
roads2_lyr.datasource = Datasource (type='shape', file='../data/roads')
|
||||
|
||||
roads2_style_1 = Style()
|
||||
roads2_rule_1 = Rule()
|
||||
|
@ -228,7 +236,8 @@ m.layers.append(roads2_lyr)
|
|||
|
||||
# Roads 1 (The big orange ones, the highways)
|
||||
|
||||
roads1_lyr = Layer(name='Roads', type='shape', file='../data/roads')
|
||||
roads1_lyr = Layer('Roads')
|
||||
roads1_lyr.datasource = Datasource(type='shape', file='../data/roads')
|
||||
|
||||
roads1_style_1 = Style()
|
||||
roads1_rule_1 = Rule()
|
||||
|
@ -260,8 +269,9 @@ m.layers.append(roads1_lyr)
|
|||
|
||||
# Populated Places
|
||||
|
||||
popplaces_lyr = Layer(name='Populated Places', type='shape',
|
||||
file='../data/popplaces')
|
||||
popplaces_lyr = Layer('Populated Places')
|
||||
popplaces_lyr.datasource = Datasource (type='shape',
|
||||
file='../data/popplaces')
|
||||
|
||||
popplaces_style = Style()
|
||||
popplaces_rule = Rule()
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifndef COLOR_FACTORY_HPP
|
||||
#define COLOR_FACTORY_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
#include "css_color_parser.hpp"
|
||||
|
||||
namespace mapnik
|
||||
|
@ -33,19 +34,19 @@ namespace mapnik
|
|||
class MAPNIK_DECL color_factory
|
||||
{
|
||||
public:
|
||||
static Color from_string(char const* css_color)
|
||||
{
|
||||
Color color;
|
||||
actions<Color> a(color);
|
||||
css_color_grammar<actions<Color> > grammar(a);
|
||||
parse_info<> info = parse(css_color, grammar, space_p);
|
||||
if (info.full) return color;
|
||||
return Color(0,0,0);
|
||||
}
|
||||
static Color from_string(char const* css_color)
|
||||
{
|
||||
Color color;
|
||||
actions<Color> a(color);
|
||||
css_color_grammar<actions<Color> > grammar(a);
|
||||
parse_info<> info = parse(css_color, grammar, space_p);
|
||||
if (info.full) return color;
|
||||
return Color(0,0,0);
|
||||
}
|
||||
private:
|
||||
color_factory();
|
||||
color_factory(color_factory const&);
|
||||
color_factory& operator=(color_factory const&);
|
||||
color_factory();
|
||||
color_factory(color_factory const&);
|
||||
color_factory& operator=(color_factory const&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,24 +35,26 @@ namespace mapnik
|
|||
class MAPNIK_DECL filter_factory
|
||||
{
|
||||
public:
|
||||
static filter_ptr compile(string const& str)
|
||||
{
|
||||
stack<shared_ptr<filter<FeatureT> > > filters;
|
||||
stack<shared_ptr<expression<FeatureT> > > exps;
|
||||
filter_grammar<FeatureT> grammar(filters,exps);
|
||||
char const *text = str.c_str();
|
||||
parse_info<> info = parse(text,text+strlen(text),grammar,space_p);
|
||||
if (info.full && !filters.empty())
|
||||
{
|
||||
return filters.top();
|
||||
}
|
||||
else
|
||||
{
|
||||
clog << "failed at :" << info.stop << "\n";
|
||||
return filter_ptr(new none_filter<FeatureT>());
|
||||
}
|
||||
}
|
||||
static filter_ptr compile(string const& str)
|
||||
{
|
||||
stack<shared_ptr<filter<FeatureT> > > filters;
|
||||
stack<shared_ptr<expression<FeatureT> > > exps;
|
||||
filter_grammar<FeatureT> grammar(filters,exps);
|
||||
char const *text = str.c_str();
|
||||
parse_info<> info = parse(text,text+strlen(text),grammar,space_p);
|
||||
if (info.full && !filters.empty())
|
||||
{
|
||||
return filters.top();
|
||||
}
|
||||
else
|
||||
{
|
||||
clog << "failed at :" << info.stop << "\n";
|
||||
return filter_ptr(new none_filter<FeatureT>());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MAPNIK_DECL filter_ptr create_filter (std::string const& wkt);
|
||||
}
|
||||
|
||||
#endif //FILTER_FACTORY_HPP
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "expression.hpp"
|
||||
#include "filter.hpp"
|
||||
#include "regex_filter.hpp"
|
||||
|
||||
#include "logical.hpp"
|
||||
|
||||
using namespace boost::spirit;
|
||||
using std::string;
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* #include <boost/serialization/serialization.hpp>
|
||||
License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id: layer.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
||||
|
||||
#ifndef LAYER_HPP
|
||||
|
@ -34,7 +33,6 @@ namespace mapnik
|
|||
{
|
||||
class MAPNIK_DECL Layer
|
||||
{
|
||||
parameters params_;
|
||||
std::string name_;
|
||||
std::string title_;
|
||||
std::string abstract_;
|
||||
|
@ -50,12 +48,10 @@ namespace mapnik
|
|||
mutable datasource_p ds_;
|
||||
|
||||
public:
|
||||
Layer();
|
||||
explicit Layer(const parameters& params);
|
||||
explicit Layer(std::string const& name);
|
||||
Layer(Layer const& l);
|
||||
Layer& operator=(Layer const& l);
|
||||
bool operator==(Layer const& other) const;
|
||||
parameters const& params() const;
|
||||
void set_name(std::string const& name);
|
||||
const std::string& name() const;
|
||||
void set_title(std::string const& title);
|
||||
|
@ -79,9 +75,9 @@ namespace mapnik
|
|||
std::vector<boost::shared_ptr<Feature> >& selection() const;
|
||||
void clear_selection() const;
|
||||
void set_datasource(datasource_p const& ds);
|
||||
datasource_p const& datasource() const;
|
||||
datasource_p datasource() const;
|
||||
Envelope<double> envelope() const;
|
||||
virtual ~Layer();
|
||||
~Layer();
|
||||
private:
|
||||
void swap(const Layer& other);
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace mapnik
|
|||
|
||||
public:
|
||||
|
||||
typedef std::map<std::string,feature_type_style>::const_iterator style_iterator;
|
||||
typedef std::map<std::string,feature_type_style>::const_iterator style_iterator;
|
||||
|
||||
Map();
|
||||
Map(int width,int height,int srid=-1);
|
||||
|
@ -76,7 +76,7 @@ namespace mapnik
|
|||
void pan_and_zoom(int x,int y,double zoom);
|
||||
const Envelope<double>& getCurrentExtent() const;
|
||||
double scale() const;
|
||||
virtual ~Map();
|
||||
~Map();
|
||||
private:
|
||||
void fixAspectRatio();
|
||||
};
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//$Id: mapnik.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
||||
|
||||
#ifndef MAPNIK_HPP
|
||||
#define MAPNIK_HPP
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "global.hpp"
|
||||
#include "factory.hpp"
|
||||
#include "filter.hpp"
|
||||
#include "query.hpp"
|
||||
#include "rule.hpp"
|
||||
#include "spatial.hpp"
|
||||
#include "logical.hpp"
|
||||
#include "comparison.hpp"
|
||||
#include "regex_filter.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "geometry.hpp"
|
||||
#include "geom_util.hpp"
|
||||
#include "raster.hpp"
|
||||
#include "feature.hpp"
|
||||
#include "attribute.hpp"
|
||||
#include "attribute_collector.hpp"
|
||||
#include "graphics.hpp"
|
||||
#include "image_reader.hpp"
|
||||
#include "line_symbolizer.hpp"
|
||||
#include "polygon_symbolizer.hpp"
|
||||
#include "agg_renderer.hpp"
|
||||
#include "polygon_pattern_symbolizer.hpp"
|
||||
#include "line_pattern_symbolizer.hpp"
|
||||
#include "point_symbolizer.hpp"
|
||||
#include "raster_symbolizer.hpp"
|
||||
#include "text_symbolizer.hpp"
|
||||
#include "image_util.hpp"
|
||||
#include "datasource.hpp"
|
||||
#include "layer.hpp"
|
||||
#include "datasource_cache.hpp"
|
||||
#include "wkb.hpp"
|
||||
#include "map.hpp"
|
||||
#include "feature_type_style.hpp"
|
||||
#include "feature_factory.hpp"
|
||||
#include "math_expr.hpp"
|
||||
#include "value.hpp"
|
||||
#include "expression.hpp"
|
||||
#include "filter_visitor.hpp"
|
||||
#include "filter_parser.hpp"
|
||||
#include "filter_factory.hpp"
|
||||
#include "text_symbolizer.hpp"
|
||||
#include "label_placement.hpp"
|
||||
#include "feature_layer_desc.hpp"
|
||||
#include "css_color_parser.hpp"
|
||||
#include "color_factory.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
MAPNIK_DECL filter_ptr create_filter (std::string const& wkt);
|
||||
}
|
||||
|
||||
#endif //MAPNIK_HPP
|
|
@ -32,7 +32,6 @@ linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
|||
|
||||
source = Split(
|
||||
"""
|
||||
mapnik.cpp
|
||||
datasource_cache.cpp
|
||||
envelope.cpp
|
||||
graphics.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*****************************************************************************
|
||||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
|
@ -75,26 +75,26 @@ namespace mapnik
|
|||
}
|
||||
std::clog<<"datasource="<<ds<<" type="<<type<<std::endl;
|
||||
}
|
||||
catch (datasource_exception& ex)
|
||||
{
|
||||
std::clog<<ex.what()<<std::endl;
|
||||
}
|
||||
catch (datasource_exception& ex)
|
||||
{
|
||||
std::clog<<ex.what()<<std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog<<"exception caught "<<std::endl;
|
||||
std::clog<<" exception caught\n";
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
bool datasource_cache::insert(const std::string& type,const lt_dlhandle module)
|
||||
{
|
||||
return plugins_.insert(make_pair(type,boost::shared_ptr<PluginInfo>(new PluginInfo(type,module)))).second;
|
||||
return plugins_.insert(make_pair(type,boost::shared_ptr<PluginInfo>(new PluginInfo(type,module)))).second;
|
||||
}
|
||||
|
||||
void datasource_cache::register_datasources(const std::string& str)
|
||||
{
|
||||
mutex::scoped_lock lock(mapnik::singleton<mapnik::datasource_cache,
|
||||
mapnik::CreateStatic>::mutex_);
|
||||
mapnik::CreateStatic>::mutex_);
|
||||
filesystem::path path(str);
|
||||
filesystem::directory_iterator end_itr;
|
||||
if (exists(path))
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//$Id$
|
||||
|
||||
#include "mapnik.hpp"
|
||||
#include "filter_factory.hpp"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -32,5 +31,3 @@ namespace mapnik
|
|||
return factory.compile(wkt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +34,8 @@
|
|||
namespace mapnik
|
||||
{
|
||||
using namespace std;
|
||||
Layer::Layer()
|
||||
: params_(),
|
||||
name_("unknown"),
|
||||
Layer::Layer(std::string const& name)
|
||||
: name_(name),
|
||||
title_(""),
|
||||
abstract_(""),
|
||||
minZoom_(0),
|
||||
|
@ -46,30 +45,17 @@ namespace mapnik
|
|||
selection_style_("default_selection")
|
||||
{}
|
||||
|
||||
Layer::Layer(const parameters& params)
|
||||
:params_(params),
|
||||
name_(params_["name"]),
|
||||
title_(params_["title"]),
|
||||
abstract_(params_["abstract"]),
|
||||
minZoom_(0),
|
||||
maxZoom_(std::numeric_limits<double>::max()),
|
||||
active_(true),
|
||||
selectable_(false),
|
||||
selection_style_("default_selection")
|
||||
{}
|
||||
|
||||
Layer::Layer(const Layer& rhs)
|
||||
:params_(rhs.params_),
|
||||
name_(rhs.name_),
|
||||
title_(rhs.title_),
|
||||
abstract_(rhs.abstract_),
|
||||
minZoom_(rhs.minZoom_),
|
||||
maxZoom_(rhs.maxZoom_),
|
||||
active_(rhs.active_),
|
||||
selectable_(rhs.selectable_),
|
||||
ds_(rhs.ds_),
|
||||
styles_(rhs.styles_),
|
||||
selection_style_(rhs.selection_style_) {}
|
||||
: name_(rhs.name_),
|
||||
title_(rhs.title_),
|
||||
abstract_(rhs.abstract_),
|
||||
minZoom_(rhs.minZoom_),
|
||||
maxZoom_(rhs.maxZoom_),
|
||||
active_(rhs.active_),
|
||||
selectable_(rhs.selectable_),
|
||||
styles_(rhs.styles_),
|
||||
ds_(rhs.ds_),
|
||||
selection_style_(rhs.selection_style_) {}
|
||||
|
||||
Layer& Layer::operator=(const Layer& rhs)
|
||||
{
|
||||
|
@ -85,7 +71,6 @@ namespace mapnik
|
|||
|
||||
void Layer::swap(const Layer& rhs)
|
||||
{
|
||||
params_=rhs.params_;
|
||||
name_=rhs.name_;
|
||||
title_=rhs.title_;
|
||||
abstract_=rhs.abstract_;
|
||||
|
@ -93,18 +78,13 @@ namespace mapnik
|
|||
maxZoom_=rhs.maxZoom_;
|
||||
active_=rhs.active_;
|
||||
selectable_=rhs.selectable_;
|
||||
ds_=rhs.ds_;
|
||||
styles_=rhs.styles_;
|
||||
ds_=rhs.ds_;
|
||||
selection_style_=rhs.selection_style_;
|
||||
}
|
||||
|
||||
Layer::~Layer() {}
|
||||
|
||||
parameters const& Layer::params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
|
||||
void Layer::set_name( std::string const& name)
|
||||
{
|
||||
name_ = name;
|
||||
|
@ -190,22 +170,11 @@ namespace mapnik
|
|||
return selectable_;
|
||||
}
|
||||
|
||||
const datasource_p& Layer::datasource() const
|
||||
datasource_p Layer::datasource() const
|
||||
{
|
||||
if (!ds_)
|
||||
{
|
||||
try
|
||||
{
|
||||
ds_=datasource_cache::instance()->create(params_);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog << "exception caught : can not create datasource" << std::endl;
|
||||
}
|
||||
}
|
||||
return ds_;
|
||||
}
|
||||
// TODO: !!!!
|
||||
|
||||
void Layer::set_datasource(datasource_p const& ds)
|
||||
{
|
||||
ds_ = ds;
|
||||
|
@ -213,11 +182,7 @@ namespace mapnik
|
|||
|
||||
Envelope<double> Layer::envelope() const
|
||||
{
|
||||
datasource_p const& ds = datasource();
|
||||
if (ds)
|
||||
{
|
||||
return ds->envelope();
|
||||
}
|
||||
if (ds_) return ds_->envelope();
|
||||
return Envelope<double>();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue