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
|
@ -60,7 +60,10 @@ bool (Envelope<double>::*intersects_p3)(Envelope<double> const&) const = &Envelo
|
||||||
void export_envelope()
|
void export_envelope()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
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<>())
|
||||||
.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("minx",&Envelope<double>::minx, "X coordinate for the lower left corner")
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <regex_filter.hpp>
|
#include <regex_filter.hpp>
|
||||||
#include <filter.hpp>
|
#include <filter.hpp>
|
||||||
#include <filter_factory.hpp>
|
#include <filter_factory.hpp>
|
||||||
#include <mapnik.hpp>
|
|
||||||
|
|
||||||
using mapnik::filter;
|
using mapnik::filter;
|
||||||
using mapnik::filter_ptr;
|
using mapnik::filter_ptr;
|
||||||
|
|
|
@ -30,76 +30,6 @@
|
||||||
using mapnik::Layer;
|
using mapnik::Layer;
|
||||||
using mapnik::parameters;
|
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()
|
void export_layer()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -107,17 +37,42 @@ void export_layer()
|
||||||
.def(vector_indexing_suite<std::vector<std::string>,true >())
|
.def(vector_indexing_suite<std::vector<std::string>,true >())
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<Layer>("Layer","A map layer.",no_init)
|
class_<Layer>("Layer","A map layer.", init<std::string const&>())
|
||||||
.def("name",&Layer::name,return_value_policy<copy_const_reference>(), "Return the name of the layer.")
|
.add_property("name",
|
||||||
.def("title",&Layer::title,return_value_policy<copy_const_reference>(), "Return the title of the layer.")
|
make_function(&Layer::name, return_value_policy<reference_existing_object>()),
|
||||||
.def("abstract",&Layer::abstract,return_value_policy<copy_const_reference>(), "Return the abstract of the layer.")
|
&Layer::set_name,
|
||||||
.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.")
|
"Get/Set the name of the layer.")
|
||||||
.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("title",
|
||||||
.add_property("maxzoom",&Layer::getMaxZoom,&Layer::setMaxZoom)
|
make_function(&Layer::title, return_value_policy<reference_existing_object>()),
|
||||||
.add_property("styles",make_function
|
&Layer::set_title,
|
||||||
(&Layer::styles,return_value_policy<reference_existing_object>()))
|
"Get/Set the title of the layer.")
|
||||||
.def_pickle(layer_pickle_suite())
|
|
||||||
|
.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/get_pointer.hpp>
|
||||||
#include <boost/python/detail/api_placeholder.hpp>
|
#include <boost/python/detail/api_placeholder.hpp>
|
||||||
|
|
||||||
//#include <mapnik.hpp>
|
|
||||||
|
|
||||||
void export_color();
|
void export_color();
|
||||||
void export_layer();
|
void export_layer();
|
||||||
void export_parameters();
|
void export_parameters();
|
||||||
|
@ -49,12 +47,10 @@ void export_raster_symbolizer();
|
||||||
void export_text_symbolizer();
|
void export_text_symbolizer();
|
||||||
void export_font_engine();
|
void export_font_engine();
|
||||||
|
|
||||||
//using namespace mapnik;
|
|
||||||
#include <map.hpp>
|
#include <map.hpp>
|
||||||
#include <agg_renderer.hpp>
|
#include <agg_renderer.hpp>
|
||||||
#include <graphics.hpp>
|
#include <graphics.hpp>
|
||||||
//#include <filter.hpp>
|
#include <datasource_cache.hpp>
|
||||||
//#include <coord.hpp>
|
|
||||||
|
|
||||||
void render_to_file(const mapnik::Map& map,
|
void render_to_file(const mapnik::Map& map,
|
||||||
const std::string& file,
|
const std::string& file,
|
||||||
|
@ -72,6 +68,25 @@ void render(const mapnik::Map& map,mapnik::Image32& image)
|
||||||
ren.apply();
|
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)
|
BOOST_PYTHON_MODULE(_mapnik)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -91,8 +106,13 @@ BOOST_PYTHON_MODULE(_mapnik)
|
||||||
.def("envelope",&datasource::envelope,
|
.def("envelope",&datasource::envelope,
|
||||||
return_value_policy<reference_existing_object>())
|
return_value_policy<reference_existing_object>())
|
||||||
.def("features",&datasource::features)
|
.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_parameters();
|
||||||
export_color();
|
export_color();
|
||||||
export_envelope();
|
export_envelope();
|
||||||
|
@ -111,6 +131,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
||||||
export_raster_symbolizer();
|
export_raster_symbolizer();
|
||||||
export_text_symbolizer();
|
export_text_symbolizer();
|
||||||
export_font_engine();
|
export_font_engine();
|
||||||
|
|
||||||
class_<coord<double,2> >("Coord",init<double,double>())
|
class_<coord<double,2> >("Coord",init<double,double>())
|
||||||
.def_readwrite("x", &coord<double,2>::x)
|
.def_readwrite("x", &coord<double,2>::x)
|
||||||
.def_readwrite("y", &coord<double,2>::y)
|
.def_readwrite("y", &coord<double,2>::y)
|
||||||
|
|
|
@ -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>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace mapnik;
|
using namespace mapnik;
|
||||||
|
@ -133,11 +141,11 @@ int main ( int argc , char** argv)
|
||||||
// Provincial polygons
|
// Provincial polygons
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Provinces";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/boundaries";
|
p["file"]="../data/boundaries";
|
||||||
|
|
||||||
Layer lyr(p);
|
Layer lyr("Provinces");
|
||||||
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("provinces");
|
lyr.add_style("provinces");
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
|
@ -145,21 +153,21 @@ int main ( int argc , char** argv)
|
||||||
// Drainage
|
// Drainage
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Quebec Hydrography";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/qcdrainage";
|
p["file"]="../data/qcdrainage";
|
||||||
|
Layer lyr("Quebec Hydrography");
|
||||||
Layer lyr(p);
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("drainage");
|
lyr.add_style("drainage");
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Ontario Hydrography";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/ontdrainage";
|
p["file"]="../data/ontdrainage";
|
||||||
|
|
||||||
Layer lyr(p);
|
Layer lyr("Ontario Hydrography");
|
||||||
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("drainage");
|
lyr.add_style("drainage");
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
|
@ -167,11 +175,10 @@ int main ( int argc , char** argv)
|
||||||
// Provincial boundaries
|
// Provincial boundaries
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Provincial borders";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/boundaries_l";
|
p["file"]="../data/boundaries_l";
|
||||||
|
Layer lyr("Provincial borders");
|
||||||
Layer lyr(p);
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("provlines");
|
lyr.add_style("provlines");
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
|
@ -179,29 +186,29 @@ int main ( int argc , char** argv)
|
||||||
// Roads
|
// Roads
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Roads";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/roads";
|
p["file"]="../data/roads";
|
||||||
|
Layer lyr("Roads");
|
||||||
Layer lyr(p);
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("smallroads");
|
lyr.add_style("smallroads");
|
||||||
lyr.add_style("road-border");
|
lyr.add_style("road-border");
|
||||||
lyr.add_style("road-fill");
|
lyr.add_style("road-fill");
|
||||||
lyr.add_style("highway-border");
|
lyr.add_style("highway-border");
|
||||||
lyr.add_style("highway-fill");
|
lyr.add_style("highway-fill");
|
||||||
|
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
// popplaces
|
// popplaces
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["name"]="Populated Places";
|
|
||||||
p["type"]="shape";
|
p["type"]="shape";
|
||||||
p["file"]="../data/popplaces";
|
p["file"]="../data/popplaces";
|
||||||
|
Layer lyr("Populated Places");
|
||||||
Layer lyr(p);
|
lyr.set_datasource(datasource_cache::instance()->create(p));
|
||||||
lyr.add_style("popplaces");
|
lyr.add_style("popplaces");
|
||||||
m.addLayer(lyr);
|
m.addLayer(lyr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m.zoomToBox(Envelope<double>(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577));
|
m.zoomToBox(Envelope<double>(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577));
|
||||||
|
|
||||||
Image32 buf(m.getWidth(),m.getHeight());
|
Image32 buf(m.getWidth(),m.getHeight());
|
||||||
|
|
|
@ -55,7 +55,8 @@ m.background = Color('white')
|
||||||
# password='mypassword'
|
# password='mypassword'
|
||||||
# table= TODO
|
# 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.
|
# 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.
|
# Styles are named, so they can be shared across different layers.
|
||||||
|
@ -118,7 +119,9 @@ m.layers.append(provpoly_lyr)
|
||||||
|
|
||||||
# A simple example ...
|
# A simple example ...
|
||||||
|
|
||||||
qcdrain_lyr = Layer(name='Quebec Hydrography', type='shape',
|
qcdrain_lyr = Layer('Quebec Hydrography')
|
||||||
|
|
||||||
|
qcdrain_lyr.datasource = Datasource( type='shape',
|
||||||
file='../data/qcdrainage')
|
file='../data/qcdrainage')
|
||||||
|
|
||||||
qcdrain_style = Style()
|
qcdrain_style = Style()
|
||||||
|
@ -135,14 +138,17 @@ m.layers.append(qcdrain_lyr)
|
||||||
# attributes, and same desired style), so we're going to
|
# attributes, and same desired style), so we're going to
|
||||||
# re-use the style defined in the above layer for the next one.
|
# re-use the style defined in the above layer for the next one.
|
||||||
|
|
||||||
ondrain_lyr = Layer(name='Ontario Hydrography', type='shape',
|
ondrain_lyr = Layer('Ontario Hydrography')
|
||||||
|
ondrain_lyr.datasource = Datasource(type='shape',
|
||||||
file='../data/ontdrainage')
|
file='../data/ontdrainage')
|
||||||
|
|
||||||
ondrain_lyr.styles.append('drainage')
|
ondrain_lyr.styles.append('drainage')
|
||||||
m.layers.append(ondrain_lyr)
|
m.layers.append(ondrain_lyr)
|
||||||
|
|
||||||
# Provincial boundaries
|
# Provincial boundaries
|
||||||
|
|
||||||
provlines_lyr = Layer(name='Provincial borders', type='shape',
|
provlines_lyr = Layer('Provincial borders')
|
||||||
|
provlines_lyr.datasource = Datasource (type='shape',
|
||||||
file='../data/boundaries_l')
|
file='../data/boundaries_l')
|
||||||
|
|
||||||
# Here we define a "dash dot dot dash" pattern for the provincial boundaries.
|
# 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)
|
# 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_style = Style()
|
||||||
roads34_rule = Rule()
|
roads34_rule = Rule()
|
||||||
|
@ -195,7 +202,8 @@ m.layers.append(roads34_lyr)
|
||||||
|
|
||||||
# Roads 2 (The thin yellow ones)
|
# 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_style_1 = Style()
|
||||||
roads2_rule_1 = Rule()
|
roads2_rule_1 = Rule()
|
||||||
|
@ -228,7 +236,8 @@ m.layers.append(roads2_lyr)
|
||||||
|
|
||||||
# Roads 1 (The big orange ones, the highways)
|
# 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_style_1 = Style()
|
||||||
roads1_rule_1 = Rule()
|
roads1_rule_1 = Rule()
|
||||||
|
@ -260,7 +269,8 @@ m.layers.append(roads1_lyr)
|
||||||
|
|
||||||
# Populated Places
|
# Populated Places
|
||||||
|
|
||||||
popplaces_lyr = Layer(name='Populated Places', type='shape',
|
popplaces_lyr = Layer('Populated Places')
|
||||||
|
popplaces_lyr.datasource = Datasource (type='shape',
|
||||||
file='../data/popplaces')
|
file='../data/popplaces')
|
||||||
|
|
||||||
popplaces_style = Style()
|
popplaces_style = Style()
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#ifndef COLOR_FACTORY_HPP
|
#ifndef COLOR_FACTORY_HPP
|
||||||
#define COLOR_FACTORY_HPP
|
#define COLOR_FACTORY_HPP
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
#include "css_color_parser.hpp"
|
#include "css_color_parser.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
|
|
@ -53,6 +53,8 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MAPNIK_DECL filter_ptr create_filter (std::string const& wkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FILTER_FACTORY_HPP
|
#endif //FILTER_FACTORY_HPP
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "expression.hpp"
|
#include "expression.hpp"
|
||||||
#include "filter.hpp"
|
#include "filter.hpp"
|
||||||
#include "regex_filter.hpp"
|
#include "regex_filter.hpp"
|
||||||
|
#include "logical.hpp"
|
||||||
|
|
||||||
using namespace boost::spirit;
|
using namespace boost::spirit;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* 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
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -34,7 +33,6 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
class MAPNIK_DECL Layer
|
class MAPNIK_DECL Layer
|
||||||
{
|
{
|
||||||
parameters params_;
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string title_;
|
std::string title_;
|
||||||
std::string abstract_;
|
std::string abstract_;
|
||||||
|
@ -50,12 +48,10 @@ namespace mapnik
|
||||||
mutable datasource_p ds_;
|
mutable datasource_p ds_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Layer();
|
explicit Layer(std::string const& name);
|
||||||
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;
|
|
||||||
void set_name(std::string const& name);
|
void set_name(std::string const& name);
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
void set_title(std::string const& title);
|
void set_title(std::string const& title);
|
||||||
|
@ -79,9 +75,9 @@ namespace mapnik
|
||||||
std::vector<boost::shared_ptr<Feature> >& selection() const;
|
std::vector<boost::shared_ptr<Feature> >& selection() const;
|
||||||
void clear_selection() const;
|
void clear_selection() const;
|
||||||
void set_datasource(datasource_p const& ds);
|
void set_datasource(datasource_p const& ds);
|
||||||
datasource_p const& datasource() const;
|
datasource_p datasource() const;
|
||||||
Envelope<double> envelope() const;
|
Envelope<double> envelope() const;
|
||||||
virtual ~Layer();
|
~Layer();
|
||||||
private:
|
private:
|
||||||
void swap(const Layer& other);
|
void swap(const Layer& other);
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace mapnik
|
||||||
void pan_and_zoom(int x,int y,double zoom);
|
void pan_and_zoom(int x,int y,double zoom);
|
||||||
const Envelope<double>& getCurrentExtent() const;
|
const Envelope<double>& getCurrentExtent() const;
|
||||||
double scale() const;
|
double scale() const;
|
||||||
virtual ~Map();
|
~Map();
|
||||||
private:
|
private:
|
||||||
void fixAspectRatio();
|
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(
|
source = Split(
|
||||||
"""
|
"""
|
||||||
mapnik.cpp
|
|
||||||
datasource_cache.cpp
|
datasource_cache.cpp
|
||||||
envelope.cpp
|
envelope.cpp
|
||||||
graphics.cpp
|
graphics.cpp
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::clog<<"exception caught "<<std::endl;
|
std::clog<<" exception caught\n";
|
||||||
}
|
}
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,9 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
|
|
||||||
#include "mapnik.hpp"
|
#include "filter_factory.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
@ -32,5 +31,3 @@ namespace mapnik
|
||||||
return factory.compile(wkt);
|
return factory.compile(wkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,8 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
Layer::Layer()
|
Layer::Layer(std::string const& name)
|
||||||
: params_(),
|
: name_(name),
|
||||||
name_("unknown"),
|
|
||||||
title_(""),
|
title_(""),
|
||||||
abstract_(""),
|
abstract_(""),
|
||||||
minZoom_(0),
|
minZoom_(0),
|
||||||
|
@ -46,29 +45,16 @@ namespace mapnik
|
||||||
selection_style_("default_selection")
|
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)
|
Layer::Layer(const Layer& rhs)
|
||||||
:params_(rhs.params_),
|
: name_(rhs.name_),
|
||||||
name_(rhs.name_),
|
|
||||||
title_(rhs.title_),
|
title_(rhs.title_),
|
||||||
abstract_(rhs.abstract_),
|
abstract_(rhs.abstract_),
|
||||||
minZoom_(rhs.minZoom_),
|
minZoom_(rhs.minZoom_),
|
||||||
maxZoom_(rhs.maxZoom_),
|
maxZoom_(rhs.maxZoom_),
|
||||||
active_(rhs.active_),
|
active_(rhs.active_),
|
||||||
selectable_(rhs.selectable_),
|
selectable_(rhs.selectable_),
|
||||||
ds_(rhs.ds_),
|
|
||||||
styles_(rhs.styles_),
|
styles_(rhs.styles_),
|
||||||
|
ds_(rhs.ds_),
|
||||||
selection_style_(rhs.selection_style_) {}
|
selection_style_(rhs.selection_style_) {}
|
||||||
|
|
||||||
Layer& Layer::operator=(const Layer& rhs)
|
Layer& Layer::operator=(const Layer& rhs)
|
||||||
|
@ -85,7 +71,6 @@ namespace mapnik
|
||||||
|
|
||||||
void Layer::swap(const Layer& rhs)
|
void Layer::swap(const Layer& rhs)
|
||||||
{
|
{
|
||||||
params_=rhs.params_;
|
|
||||||
name_=rhs.name_;
|
name_=rhs.name_;
|
||||||
title_=rhs.title_;
|
title_=rhs.title_;
|
||||||
abstract_=rhs.abstract_;
|
abstract_=rhs.abstract_;
|
||||||
|
@ -93,18 +78,13 @@ namespace mapnik
|
||||||
maxZoom_=rhs.maxZoom_;
|
maxZoom_=rhs.maxZoom_;
|
||||||
active_=rhs.active_;
|
active_=rhs.active_;
|
||||||
selectable_=rhs.selectable_;
|
selectable_=rhs.selectable_;
|
||||||
ds_=rhs.ds_;
|
|
||||||
styles_=rhs.styles_;
|
styles_=rhs.styles_;
|
||||||
|
ds_=rhs.ds_;
|
||||||
selection_style_=rhs.selection_style_;
|
selection_style_=rhs.selection_style_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer::~Layer() {}
|
Layer::~Layer() {}
|
||||||
|
|
||||||
parameters const& Layer::params() const
|
|
||||||
{
|
|
||||||
return params_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::set_name( std::string const& name)
|
void Layer::set_name( std::string const& name)
|
||||||
{
|
{
|
||||||
name_ = name;
|
name_ = name;
|
||||||
|
@ -190,22 +170,11 @@ namespace mapnik
|
||||||
return selectable_;
|
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_;
|
return ds_;
|
||||||
}
|
}
|
||||||
// TODO: !!!!
|
|
||||||
void Layer::set_datasource(datasource_p const& ds)
|
void Layer::set_datasource(datasource_p const& ds)
|
||||||
{
|
{
|
||||||
ds_ = ds;
|
ds_ = ds;
|
||||||
|
@ -213,11 +182,7 @@ namespace mapnik
|
||||||
|
|
||||||
Envelope<double> Layer::envelope() const
|
Envelope<double> Layer::envelope() const
|
||||||
{
|
{
|
||||||
datasource_p const& ds = datasource();
|
if (ds_) return ds_->envelope();
|
||||||
if (ds)
|
|
||||||
{
|
|
||||||
return ds->envelope();
|
|
||||||
}
|
|
||||||
return Envelope<double>();
|
return Envelope<double>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue