removed python dir (now in bindings)

This commit is contained in:
Artem Pavlenko 2006-02-01 09:31:03 +00:00
parent 6ebc93b7a1
commit ae2e89ef54
15 changed files with 0 additions and 1086 deletions

View file

@ -1,122 +0,0 @@
# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# $Id$
import os
import SCons.Errors
import SCons.Defaults
import glob
Import('env')
#env.Append(CCFLAGS = ' -DBOOST_PYTHON_DYNAMIC_LIB')
#boost python
prefix = env['PREFIX']
boost_root = env['BOOST_ROOT']
python_root = env['PYTHON_ROOT']
python_version = env['PYTHON_VERSION']
python_headers = python_root+'/include/python'+python_version
boost_python_src_dir = boost_root + '/libs/python/src/'
boost_python_src = glob.glob(boost_python_src_dir + '*.cpp')
boost_python_src.append(glob.glob(boost_python_src_dir + 'object/*.cpp'))
boost_python_src.append(glob.glob(boost_python_src_dir + 'converter/*.cpp'))
python_cpppath = python_root+'/include/python'+python_version
lib_boost_python = env.SharedLibrary('libboost-python',boost_python_src,LIBS=[],CPPPATH=[boost_root,python_cpppath])
env.Install(prefix + '/lib',lib_boost_python)
#agg_root = env['AGG_ROOT']
#agg_headers = agg_root +'/include'
#freetype2_root = env['FREETYPE2_ROOT']
def createPythonExtBuilder(env):
"""This is a utility function that creates boost-python
extension Builder in an Environment if it is not there already.
If it is already there, we return the existing one.
"""
try:
python_ext = env['BUILDERS']['PythonExtension']
except KeyError:
action_list = [ SCons.Defaults.SharedCheck,
SCons.Defaults.ShLinkAction ]
python_ext = SCons.Builder.Builder(action = action_list,
emitter = "$SHLIBEMITTER",
prefix = '',
suffix = '$SHLIBSUFFIX',
target_scanner = SCons.Defaults.ProgScan,
src_suffix = '$SHOBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['PythonExtension'] = python_ext
return python_ext
createPythonExtBuilder(env)
mapnik_python_src=Split(
"""
mapnik_color.cpp
mapnik_envelope.cpp
mapnik_image.cpp
mapnik_layer.cpp
mapnik_map.cpp
mapnik_parameters.cpp
mapnik_filter.cpp
mapnik_rule.cpp
mapnik_style.cpp
mapnik_stroke.cpp
mapnik_datasource_cache.cpp
mapnik_python.cpp
"""
)
headers =[ '#include',boost_root,python_headers]
libraries=['mapnik','boost-python']
libpaths = [prefix+"/lib"]
_mapnik_python = env.PythonExtension(target='_mapnik',\
source=mapnik_python_src,\
CPPPATH=headers,\
LIBS=libraries,\
LIBPATH=libpaths)
def substitute_prefix(target,source,env):
from string import Template
s = Template(source[0].get_contents())
str = s.substitute(PREFIX=prefix)
_out = file(target[0].abspath,'w')
_out.write(str)
_out.close()
return None
env.Command('mapnik/__init__.py','mapnik/__init__.py.in', substitute_prefix)
__init1__ = env.Install(prefix+'/lib','__init__.py')
__init2__ = env.Install(prefix+'/lib/mapnik','mapnik/__init__.py')
_source=env.Install(prefix+'/lib/mapnik',_mapnik_python)
_source.append(__init1__)
_source.append(__init2__)
env.Alias(target="install",source=_source)

View file

@ -1,20 +0,0 @@
#
# This file is part of Mapnik (C++/Python 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$
#

View file

@ -1,61 +0,0 @@
#
# This file is part of Mapnik (C++/Python 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.
#
#
#
#
from sys import getdlopenflags,setdlopenflags
from dl import RTLD_NOW,RTLD_GLOBAL
flags = getdlopenflags()
setdlopenflags(RTLD_NOW | RTLD_GLOBAL)
from _mapnik import *
# The base Boost.Python class
BoostPythonMetaclass = coord.__class__
class _injector(object):
class __metaclass__(BoostPythonMetaclass):
def __init__(self, name, bases, dict):
for b in bases:
if type(b) not in (self, type):
for k,v in dict.items():
setattr(b,k,v)
return type.__init__(self, name, bases, dict)
class _coord(coord,_injector):
def __repr__(self):
return 'coord(%s,%s)' % (self.x, self.y)
class _envelope(envelope,_injector):
def __repr__(self):
return 'envelope(%s,%s,%s,%s)' % \
(self.minx,self.miny,self.maxx,self.maxy)
class _color(color,_injector):
def __repr__(self):
return 'color(%s,%s,%s,%s)' % \
(self.r,self.g,self.b,self.a)
#register datasources
from mapnik import datasource_cache
datasource_cache.instance().register_datasources("${PREFIX}/datasources")
#set dlopen flags back to the original
setdlopenflags(flags)

View file

@ -1,58 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_color.cc 17 2005-03-08 23:58:43Z pavlenko $
#include <boost/python.hpp>
#include <mapnik.hpp>
using mapnik::Color;
using mapnik::color_factory;
struct color_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const Color& c)
{
using namespace boost::python;
return boost::python::make_tuple(c.red(),c.green(),c.blue());
}
};
Color create_from_string(const char* str)
{
return color_factory::from_string(str);
}
void export_color ()
{
using namespace boost::python;
class_<Color>("color",init<>())
.def(init<int,int,int,boost::python::optional<int> >())
.add_property("r",&Color::red,&Color::set_red)
.add_property("g",&Color::green,&Color::set_green)
.add_property("b",&Color::blue,&Color::set_blue)
.add_property("a",&Color::alpha)
.def(self == self)
.def_pickle(color_pickle_suite())
;
def("color_from_string",&create_from_string);
}

View file

@ -1,44 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include "mapnik.hpp"
void export_datasource_cache()
{
using mapnik::datasource_cache;
using mapnik::singleton;
using mapnik::CreateStatic;
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>())
.staticmethod("instance")
;
class_<datasource_cache,bases<singleton<datasource_cache,CreateStatic> >,
boost::noncopyable>("datasource_cache",no_init)
.def("create",&datasource_cache::create)
.staticmethod("create")
.def("register_datasources",&datasource_cache::register_datasources)
.staticmethod("register_datasources")
;
}

View file

@ -1,86 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $
#include <boost/python.hpp>
#include <mapnik.hpp>
using mapnik::coord;
using mapnik::Envelope;
struct envelope_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const Envelope<double>& e)
{
using namespace boost::python;
return boost::python::make_tuple(e.minx(),e.miny(),e.maxx(),e.maxy());
}
};
//define overloads here
void (Envelope<double>::*width_p1)(double) = &Envelope<double>::width;
double (Envelope<double>::*width_p2)() const = &Envelope<double>::width;
void (Envelope<double>::*height_p1)(double) = &Envelope<double>::height;
double (Envelope<double>::*height_p2)() const = &Envelope<double>::height;
void (Envelope<double>::*expand_to_include_p1)(double,double) = &Envelope<double>::expand_to_include;
void (Envelope<double>::*expand_to_include_p2)(coord<double,2> const& ) = &Envelope<double>::expand_to_include;
void (Envelope<double>::*expand_to_include_p3)(Envelope<double> const& ) = &Envelope<double>::expand_to_include;
bool (Envelope<double>::*contains_p1)(double,double) const = &Envelope<double>::contains;
bool (Envelope<double>::*contains_p2)(coord<double,2> const&) const = &Envelope<double>::contains;
bool (Envelope<double>::*contains_p3)(Envelope<double> const&) const = &Envelope<double>::contains;
bool (Envelope<double>::*intersects_p1)(double,double) const = &Envelope<double>::intersects;
bool (Envelope<double>::*intersects_p2)(coord<double,2> const&) const = &Envelope<double>::intersects;
bool (Envelope<double>::*intersects_p3)(Envelope<double> const&) const = &Envelope<double>::intersects;
void export_envelope()
{
using namespace boost::python;
class_<Envelope<double> >("envelope",init<double,double,double,double>())
.def(init<>())
.def(init<const coord<double,2>&, const coord<double,2>&>())
.add_property("minx",&Envelope<double>::minx)
.add_property("miny",&Envelope<double>::miny)
.add_property("maxx",&Envelope<double>::maxx)
.add_property("maxy",&Envelope<double>::maxy)
.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_pickle(envelope_pickle_suite())
;
}

View file

@ -1,45 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include <mapnik.hpp>
using mapnik::filter;
using mapnik::filter_ptr;
using mapnik::filter_factory;
using mapnik::Feature;
namespace
{
using namespace boost::python;
filter_ptr create_filter(string const& filter_text)
{
return filter_factory<Feature>::compile(filter_text);
}
}
void export_filter()
{
using namespace boost::python;
class_<filter<Feature>,boost::noncopyable>("filter",no_init)
.def("__str__",&filter<Feature>::to_string);
;
def("filter",&create_filter);
}

View file

@ -1,38 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include <mapnik.hpp>
using mapnik::Image32;
char const* rawdata(const Image32& image)
{
return (char const* )image.raw_data();
}
void export_image()
{
using namespace boost::python;
class_<Image32>("image",init<int,int>())
;
def("rawdata",&rawdata);
}

View file

@ -1,118 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_layer.cc 17 2005-03-08 23:58:43Z pavlenko $
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <mapnik.hpp>
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;
class_<std::vector<std::string> >("styles")
.def(vector_indexing_suite<std::vector<std::string>,true >())
;
//class_<Layer>("layer",init<const Parameters&>("Layer constructor"))
class_<Layer>("layer",no_init)
.def("name",&Layer::name,return_value_policy<copy_const_reference>())
.def("params",&Layer::params,return_value_policy<reference_existing_object>())
.def("envelope",&Layer::envelope)
.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())
;
def("create_layer",&create_layer);
}

View file

@ -1,98 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_map.cc 17 2005-03-08 23:58:43Z pavlenko $
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <mapnik.hpp>
using mapnik::Color;
using mapnik::coord;
using mapnik::Envelope;
using mapnik::Layer;
using mapnik::Map;
struct map_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const Map& m)
{
return boost::python::make_tuple(m.getWidth(),m.getHeight(),m.srid());
}
static boost::python::tuple
getstate(const Map& m)
{
boost::python::list l;
for (unsigned i=0;i<m.layerCount();++i)
{
l.append(m.getLayer(i));
}
return boost::python::make_tuple(m.getCurrentExtent(),m.getBackground(),l);
}
static void
setstate (Map& m, 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();
}
Envelope<double> ext = extract<Envelope<double> >(state[0]);
Color bg = extract<Color>(state[1]);
m.zoomToBox(ext);
m.setBackground(bg);
boost::python::list l=extract<boost::python::list>(state[2]);
for (int i=0;i<len(l);++i)
{
m.addLayer(extract<Layer>(l[i]));
}
}
};
void export_map()
{
using namespace boost::python;
class_<std::vector<Layer> >("layers")
.def(vector_indexing_suite<std::vector<Layer> >())
;
class_<Map>("map",init<int,int,boost::python::optional<int> >())
.add_property("width",&Map::getWidth)
.add_property("height",&Map::getHeight)
.add_property("srid",&Map::srid)
.add_property("background",make_function
(&Map::getBackground,return_value_policy<copy_const_reference>()),
&Map::setBackground)
.def("scale", &Map::scale)
.def("zoom_to_box",&Map::zoomToBox)
.def("pan",&Map::pan)
.def("zoom",&Map::zoom)
.def("pan_and_zoom",&Map::pan_and_zoom)
.add_property("layers",make_function
(&Map::layers,return_value_policy<reference_existing_object>()))
.def_pickle(map_pickle_suite())
;
}

View file

@ -1,93 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_parameters.cc 17 2005-03-08 23:58:43Z pavlenko $
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <mapnik.hpp>
using mapnik::parameter;
using mapnik::parameters;
//void (parameters::*add1)(const parameter&)=&parameters::insert;
//void (parameters::*add2)(std::make_pair(const std::string&,const std::string&))=&parameters::insert;
struct parameter_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const parameter& p)
{
using namespace boost::python;
return boost::python::make_tuple(p.first,p.second);
}
};
struct parameters_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getstate(const parameters& p)
{
using namespace boost::python;
dict d;
parameters::const_iterator pos=p.begin();
while(pos!=p.end())
{
d[pos->first]=pos->second;
++pos;
}
return boost::python::make_tuple(d);
}
static void setstate(parameters& p, boost::python::tuple state)
{
using namespace boost::python;
if (len(state) != 1)
{
PyErr_SetObject(PyExc_ValueError,
("expected 1-item tuple in call to __setstate__; got %s"
% state).ptr()
);
throw_error_already_set();
}
dict d = extract<dict>(state[0]);
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]);
p[key] = value;
}
}
};
void export_parameters()
{
using namespace boost::python;
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)
.def_pickle(parameters_pickle_suite())
;
}

View file

@ -1,129 +0,0 @@
/* This file is part of python_mapnik (c++/python 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: mapnik_python.cc 27 2005-03-30 21:45:40Z pavlenko $
#include <boost/python.hpp>
#include <boost/get_pointer.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include "mapnik.hpp"
using namespace mapnik;
void export_color();
void export_layer();
void export_parameters();
void export_envelope();
void export_image();
void export_map();
void export_python();
void export_filter();
void export_rule();
void export_style();
void export_stroke();
void export_datasource_cache();
void render_to_file(const Map& map,const std::string& file,const std::string& format)
{
Image32 image(map.getWidth(),map.getHeight());
Renderer<Image32>::render(map,image);
image.saveToFile(file,format);
}
void render(const Map& map,Image32& image)
{
Renderer<Image32>::render(map,image);
}
boost::shared_ptr<symbolizer> create_point_symbolizer(std::string const& file,unsigned w,unsigned h)
{
return boost::shared_ptr<symbolizer>(new image_symbolizer(file,"png",w,h));
}
boost::shared_ptr<symbolizer> create_line_symbolizer(const Color& pen,float width)
{
return boost::shared_ptr<symbolizer>(new line_symbolizer(pen,width));
}
boost::shared_ptr<symbolizer> create_line_symbolizer2(stroke const& strk)
{
return boost::shared_ptr<symbolizer>(new line_symbolizer(strk));
}
boost::shared_ptr<symbolizer> create_line_symbolizer3(std::string const& file,unsigned w,unsigned h)
{
return boost::shared_ptr<symbolizer>(new line_pattern_symbolizer(file,"png",w,h));
}
boost::shared_ptr<symbolizer> create_polygon_symbolizer(const Color& fill)
{
return boost::shared_ptr<symbolizer>(new polygon_symbolizer(fill));
}
boost::shared_ptr<symbolizer> create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h)
{
return boost::shared_ptr<symbolizer>(new polygon_pattern_symbolizer(file,"png",w,h));
}
BOOST_PYTHON_MODULE(_mapnik)
{
using namespace boost::python;
class_<datasource,boost::shared_ptr<datasource>,
boost::noncopyable>("datasource",no_init)
.def("envelope",&datasource::envelope,
return_value_policy<reference_existing_object>())
;
class_<symbolizer,boost::noncopyable> ("symbolizer_",no_init)
;
class_<boost::shared_ptr<symbolizer>,
boost::noncopyable>("symbolizer",no_init)
;
export_parameters();
export_color();
export_envelope();
export_image();
export_filter();
export_rule();
export_style();
export_layer();
export_stroke();
export_datasource_cache();
class_<coord<double,2> >("coord",init<double,double>())
.def_readwrite("x", &coord<double,2>::x)
.def_readwrite("y", &coord<double,2>::y)
;
export_map();
def("render_to_file",&render_to_file);
def("render",&render);
def("point_symbolizer",&create_point_symbolizer);
def("line_symbolizer",&create_line_symbolizer);
def("line_symbolizer",&create_line_symbolizer2);
def("line_symbolizer",&create_line_symbolizer3);
def("polygon_symbolizer",&create_polygon_symbolizer);
def("polygon_symbolizer",&create_polygon_symbolizer2);
register_ptr_to_python<boost::shared_ptr<symbolizer> >();
register_ptr_to_python<filter_ptr>();
}

View file

@ -1,65 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <mapnik.hpp>
using mapnik::rule_type;
using mapnik::filter;
using mapnik::filter_ptr;
using mapnik::Feature;
using mapnik::symbolizers;
void export_rule()
{
using namespace boost::python;
class_<symbolizers>("symbolizers",init<>("TODO"))
.def(vector_indexing_suite<symbolizers>())
;
class_<rule_type>("rule",init<>("default ctor"))
.def(init<std::string const&,
boost::python::optional<std::string const&,double,double> >())
.add_property("name",make_function
(&rule_type::get_name,
return_value_policy<copy_const_reference>()),
&rule_type::set_name)
.add_property("title",make_function
(&rule_type::get_title,return_value_policy<copy_const_reference>()),
&rule_type::set_title)
.add_property("abstract",make_function
(&rule_type::get_abstract,return_value_policy<copy_const_reference>()),
&rule_type::set_abstract)
.add_property("filter",make_function
(&rule_type::get_filter,return_value_policy<copy_const_reference>()),
&rule_type::set_filter)
.add_property("min_scale",&rule_type::get_min_scale,&rule_type::set_min_scale)
.add_property("max_scale",&rule_type::get_max_scale,&rule_type::set_max_scale)
.def("set_else",&rule_type::set_else)
.def("has_else",&rule_type::has_else_filter)
.def("active",&rule_type::active)
.add_property("symbols",make_function
(&rule_type::get_symbolizers,return_value_policy<reference_existing_object>()))
;
}

View file

@ -1,52 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include <mapnik.hpp>
void export_stroke ()
{
using namespace mapnik;
using namespace boost::python;
enum_<line_cap_e>("line_cap")
.value("BUTT_CAP",BUTT_CAP)
.value("SQUARE_CAP",SQUARE_CAP)
.value("ROUND_CAP",ROUND_CAP)
;
enum_<line_join_e>("line_join")
.value("MITER_JOIN",MITER_JOIN)
.value("MITER_REVERT_JOIN",MITER_REVERT_JOIN)
.value("ROUND_JOIN",ROUND_JOIN)
.value("BEVEL_JOIN",BEVEL_JOIN)
;
class_<stroke>("stroke",init<>())
.def(init<Color,float>())
.add_property("color",make_function
(&stroke::get_color,return_value_policy<reference_existing_object>()),
&stroke::set_color)
.add_property("width",&stroke::get_width,&stroke::set_width)
.add_property("opacity",&stroke::get_opacity,&stroke::set_opacity)
.add_property("line_cap",&stroke::get_line_cap,&stroke::set_line_cap)
.add_property("line_join",&stroke::get_line_join,&stroke::set_line_join)
.def("add_dash",&stroke::add_dash)
;
}

View file

@ -1,57 +0,0 @@
/* This file is part of python_mapnik (c++/python 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 <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "mapnik.hpp"
using mapnik::feature_type_style;
using mapnik::named_style_cache;
using mapnik::singleton;
using mapnik::CreateStatic;
using mapnik::rules;
void export_style()
{
using namespace boost::python;
class_<rules>("rules",init<>("default ctor"))
.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>()))
;
class_<singleton<named_style_cache,CreateStatic>,boost::noncopyable>("singleton",no_init)
.def("instance",&singleton<named_style_cache,CreateStatic>::instance,
return_value_policy<reference_existing_object>())
.staticmethod("instance")
;
class_<named_style_cache,bases<singleton<named_style_cache,CreateStatic> >,
boost::noncopyable>("style_cache",no_init)
.def("insert",&named_style_cache::insert)
.staticmethod("insert")
.def("remove",&named_style_cache::remove)
.staticmethod("remove")
;
}