From ae2e89ef5459079ba13d4d99f3fc94f068a3e3a5 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 1 Feb 2006 09:31:03 +0000 Subject: [PATCH] removed python dir (now in bindings) --- python/SConscript | 122 --------------------------- python/__init__.py | 20 ----- python/mapnik/__init__.py.in | 61 -------------- python/mapnik_color.cpp | 58 ------------- python/mapnik_datasource_cache.cpp | 44 ---------- python/mapnik_envelope.cpp | 86 ------------------- python/mapnik_filter.cpp | 45 ---------- python/mapnik_image.cpp | 38 --------- python/mapnik_layer.cpp | 118 -------------------------- python/mapnik_map.cpp | 98 ---------------------- python/mapnik_parameters.cpp | 93 --------------------- python/mapnik_python.cpp | 129 ----------------------------- python/mapnik_rule.cpp | 65 --------------- python/mapnik_stroke.cpp | 52 ------------ python/mapnik_style.cpp | 57 ------------- 15 files changed, 1086 deletions(-) delete mode 100644 python/SConscript delete mode 100644 python/__init__.py delete mode 100644 python/mapnik/__init__.py.in delete mode 100644 python/mapnik_color.cpp delete mode 100644 python/mapnik_datasource_cache.cpp delete mode 100644 python/mapnik_envelope.cpp delete mode 100644 python/mapnik_filter.cpp delete mode 100644 python/mapnik_image.cpp delete mode 100644 python/mapnik_layer.cpp delete mode 100644 python/mapnik_map.cpp delete mode 100644 python/mapnik_parameters.cpp delete mode 100644 python/mapnik_python.cpp delete mode 100644 python/mapnik_rule.cpp delete mode 100644 python/mapnik_stroke.cpp delete mode 100644 python/mapnik_style.cpp diff --git a/python/SConscript b/python/SConscript deleted file mode 100644 index ec67c55eb..000000000 --- a/python/SConscript +++ /dev/null @@ -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) diff --git a/python/__init__.py b/python/__init__.py deleted file mode 100644 index 03fa054a6..000000000 --- a/python/__init__.py +++ /dev/null @@ -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$ -# diff --git a/python/mapnik/__init__.py.in b/python/mapnik/__init__.py.in deleted file mode 100644 index 78f4433c7..000000000 --- a/python/mapnik/__init__.py.in +++ /dev/null @@ -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) - diff --git a/python/mapnik_color.cpp b/python/mapnik_color.cpp deleted file mode 100644 index a1ad5f27a..000000000 --- a/python/mapnik_color.cpp +++ /dev/null @@ -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 -#include - -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",init<>()) - .def(init >()) - .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); -} - diff --git a/python/mapnik_datasource_cache.cpp b/python/mapnik_datasource_cache.cpp deleted file mode 100644 index e9514f75a..000000000 --- a/python/mapnik_datasource_cache.cpp +++ /dev/null @@ -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 -#include "mapnik.hpp" - - -void export_datasource_cache() -{ - using mapnik::datasource_cache; - using mapnik::singleton; - using mapnik::CreateStatic; - using namespace boost::python; - class_,boost::noncopyable>("singleton",no_init) - .def("instance",&singleton::instance, - return_value_policy()) - .staticmethod("instance") - ; - - class_ >, - boost::noncopyable>("datasource_cache",no_init) - .def("create",&datasource_cache::create) - .staticmethod("create") - .def("register_datasources",&datasource_cache::register_datasources) - .staticmethod("register_datasources") - ; -} diff --git a/python/mapnik_envelope.cpp b/python/mapnik_envelope.cpp deleted file mode 100644 index ca48d4b94..000000000 --- a/python/mapnik_envelope.cpp +++ /dev/null @@ -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 -#include - - -using mapnik::coord; -using mapnik::Envelope; - -struct envelope_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const Envelope& e) - { - using namespace boost::python; - return boost::python::make_tuple(e.minx(),e.miny(),e.maxx(),e.maxy()); - } -}; - -//define overloads here -void (Envelope::*width_p1)(double) = &Envelope::width; -double (Envelope::*width_p2)() const = &Envelope::width; - -void (Envelope::*height_p1)(double) = &Envelope::height; -double (Envelope::*height_p2)() const = &Envelope::height; - -void (Envelope::*expand_to_include_p1)(double,double) = &Envelope::expand_to_include; -void (Envelope::*expand_to_include_p2)(coord const& ) = &Envelope::expand_to_include; -void (Envelope::*expand_to_include_p3)(Envelope const& ) = &Envelope::expand_to_include; - -bool (Envelope::*contains_p1)(double,double) const = &Envelope::contains; -bool (Envelope::*contains_p2)(coord const&) const = &Envelope::contains; -bool (Envelope::*contains_p3)(Envelope const&) const = &Envelope::contains; - -bool (Envelope::*intersects_p1)(double,double) const = &Envelope::intersects; -bool (Envelope::*intersects_p2)(coord const&) const = &Envelope::intersects; -bool (Envelope::*intersects_p3)(Envelope const&) const = &Envelope::intersects; - - -void export_envelope() -{ - using namespace boost::python; - class_ >("envelope",init()) - .def(init<>()) - .def(init&, const coord&>()) - .add_property("minx",&Envelope::minx) - .add_property("miny",&Envelope::miny) - .add_property("maxx",&Envelope::maxx) - .add_property("maxy",&Envelope::maxy) - .def("center",&Envelope::center) - .def("center",&Envelope::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()) - ; -} diff --git a/python/mapnik_filter.cpp b/python/mapnik_filter.cpp deleted file mode 100644 index f43590f16..000000000 --- a/python/mapnik_filter.cpp +++ /dev/null @@ -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 -#include - -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::compile(filter_text); - } -} - -void export_filter() -{ - using namespace boost::python; - class_,boost::noncopyable>("filter",no_init) - .def("__str__",&filter::to_string); - ; - def("filter",&create_filter); -} diff --git a/python/mapnik_image.cpp b/python/mapnik_image.cpp deleted file mode 100644 index 24f74b26a..000000000 --- a/python/mapnik_image.cpp +++ /dev/null @@ -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 -#include - -using mapnik::Image32; - - -char const* rawdata(const Image32& image) -{ - return (char const* )image.raw_data(); -} - -void export_image() -{ - using namespace boost::python; - class_("image",init()) - ; - def("rawdata",&rawdata); -} diff --git a/python/mapnik_layer.cpp b/python/mapnik_layer.cpp deleted file mode 100644 index 09905a744..000000000 --- a/python/mapnik_layer.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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 const& styles=l.styles(); - std::vector::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(state[0])); - l.setMaxZoom(extract(state[1])); - - boost::python::list styles=extract(state[2]); - for (int i=0;i(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(keys[i]); - std::string value=extract(d[key]); - params[key] = value; - } - return Layer(params); - } -} - -void export_layer() -{ - using namespace boost::python; - class_ >("styles") - .def(vector_indexing_suite,true >()) - ; - //class_("layer",init("Layer constructor")) - class_("layer",no_init) - .def("name",&Layer::name,return_value_policy()) - .def("params",&Layer::params,return_value_policy()) - .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())) - .def_pickle(layer_pickle_suite()) - ; - def("create_layer",&create_layer); -} diff --git a/python/mapnik_map.cpp b/python/mapnik_map.cpp deleted file mode 100644 index 48e4a16d2..000000000 --- a/python/mapnik_map.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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 ext = extract >(state[0]); - Color bg = extract(state[1]); - m.zoomToBox(ext); - m.setBackground(bg); - boost::python::list l=extract(state[2]); - for (int i=0;i(l[i])); - } - } -}; - -void export_map() -{ - using namespace boost::python; - class_ >("layers") - .def(vector_indexing_suite >()) - ; - class_("map",init >()) - .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()), - &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())) - .def_pickle(map_pickle_suite()) - ; -} diff --git a/python/mapnik_parameters.cpp b/python/mapnik_parameters.cpp deleted file mode 100644 index 00cc78f8e..000000000 --- a/python/mapnik_parameters.cpp +++ /dev/null @@ -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 -#include -#include - -using mapnik::parameter; -using mapnik::parameters; - -//void (parameters::*add1)(const parameter&)=¶meters::insert; -//void (parameters::*add2)(std::make_pair(const std::string&,const std::string&))=¶meters::insert; - -struct parameter_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const parameter& p) - { - 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(state[0]); - boost::python::list keys=d.keys(); - for (int i=0;i(keys[i]); - std::string value=extract(d[key]); - p[key] = value; - } - } -}; - - -void export_parameters() -{ - using namespace boost::python; - class_("parameter",init()) - .def_pickle(parameter_pickle_suite()) - ; - - class_("parameters",init<>()) - //.def("add",add1) - //.def("add",add2) - .def("get",¶meters::get) - .def_pickle(parameters_pickle_suite()) - ; -} diff --git a/python/mapnik_python.cpp b/python/mapnik_python.cpp deleted file mode 100644 index c7afa1d35..000000000 --- a/python/mapnik_python.cpp +++ /dev/null @@ -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 -#include -#include - -#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::render(map,image); - image.saveToFile(file,format); -} - -void render(const Map& map,Image32& image) -{ - Renderer::render(map,image); -} - - -boost::shared_ptr create_point_symbolizer(std::string const& file,unsigned w,unsigned h) -{ - return boost::shared_ptr(new image_symbolizer(file,"png",w,h)); -} - -boost::shared_ptr create_line_symbolizer(const Color& pen,float width) -{ - return boost::shared_ptr(new line_symbolizer(pen,width)); -} - -boost::shared_ptr create_line_symbolizer2(stroke const& strk) -{ - return boost::shared_ptr(new line_symbolizer(strk)); -} - -boost::shared_ptr create_line_symbolizer3(std::string const& file,unsigned w,unsigned h) -{ - return boost::shared_ptr(new line_pattern_symbolizer(file,"png",w,h)); -} - -boost::shared_ptr create_polygon_symbolizer(const Color& fill) -{ - return boost::shared_ptr(new polygon_symbolizer(fill)); -} - -boost::shared_ptr create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h) -{ - return boost::shared_ptr(new polygon_pattern_symbolizer(file,"png",w,h)); -} - -BOOST_PYTHON_MODULE(_mapnik) -{ - using namespace boost::python; - - class_, - boost::noncopyable>("datasource",no_init) - .def("envelope",&datasource::envelope, - return_value_policy()) - ; - - class_ ("symbolizer_",no_init) - ; - class_, - 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",init()) - .def_readwrite("x", &coord::x) - .def_readwrite("y", &coord::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 >(); - register_ptr_to_python(); -} diff --git a/python/mapnik_rule.cpp b/python/mapnik_rule.cpp deleted file mode 100644 index 3d462b192..000000000 --- a/python/mapnik_rule.cpp +++ /dev/null @@ -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 -#include -#include - -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",init<>("TODO")) - .def(vector_indexing_suite()) - ; - - class_("rule",init<>("default ctor")) - .def(init >()) - .add_property("name",make_function - (&rule_type::get_name, - return_value_policy()), - &rule_type::set_name) - .add_property("title",make_function - (&rule_type::get_title,return_value_policy()), - &rule_type::set_title) - .add_property("abstract",make_function - (&rule_type::get_abstract,return_value_policy()), - &rule_type::set_abstract) - .add_property("filter",make_function - (&rule_type::get_filter,return_value_policy()), - &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())) - ; -} - diff --git a/python/mapnik_stroke.cpp b/python/mapnik_stroke.cpp deleted file mode 100644 index 3596eae46..000000000 --- a/python/mapnik_stroke.cpp +++ /dev/null @@ -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 -#include - -void export_stroke () -{ - using namespace mapnik; - using namespace boost::python; - - enum_("line_cap") - .value("BUTT_CAP",BUTT_CAP) - .value("SQUARE_CAP",SQUARE_CAP) - .value("ROUND_CAP",ROUND_CAP) - ; - enum_("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",init<>()) - .def(init()) - .add_property("color",make_function - (&stroke::get_color,return_value_policy()), - &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) - ; -} diff --git a/python/mapnik_style.cpp b/python/mapnik_style.cpp deleted file mode 100644 index 6426d061f..000000000 --- a/python/mapnik_style.cpp +++ /dev/null @@ -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 -#include -#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",init<>("default ctor")) - .def(vector_indexing_suite()) - ; - class_("style",init<>("default style constructor")) - .add_property("rules",make_function - (&feature_type_style::get_rules,return_value_policy())) - ; - - class_,boost::noncopyable>("singleton",no_init) - .def("instance",&singleton::instance, - return_value_policy()) - .staticmethod("instance") - ; - - class_ >, - boost::noncopyable>("style_cache",no_init) - .def("insert",&named_style_cache::insert) - .staticmethod("insert") - .def("remove",&named_style_cache::remove) - .staticmethod("remove") - ; -} -