This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository python-mapnik.
commit 81d8c67000aeb585c9b20962b7a0b794262bd534 Author: Bas Couwenberg <[email protected]> Date: Fri Jan 20 15:05:26 2017 +0100 Imported Upstream version 0.0~20170119-5a6896f --- README.md | 2 +- demo/data/COPYRIGHT.txt | 3 + demo/data/boundaries.dbf | Bin 0 -> 749 bytes demo/data/boundaries.shp | Bin 0 -> 853032 bytes demo/data/boundaries.shx | Bin 0 -> 116 bytes demo/data/boundaries_l.dbf | Bin 0 -> 971 bytes demo/data/boundaries_l.shp | Bin 0 -> 95436 bytes demo/data/boundaries_l.shx | Bin 0 -> 236 bytes demo/data/ontdrainage.dbf | Bin 0 -> 264967 bytes demo/data/ontdrainage.shp | Bin 0 -> 496980 bytes demo/data/ontdrainage.shx | Bin 0 -> 6612 bytes demo/data/popplaces.dbf | Bin 0 -> 93537 bytes demo/data/popplaces.shp | Bin 0 -> 5476 bytes demo/data/popplaces.shx | Bin 0 -> 1636 bytes demo/data/qcdrainage.dbf | Bin 0 -> 219467 bytes demo/data/qcdrainage.shp | Bin 0 -> 327504 bytes demo/data/qcdrainage.shx | Bin 0 -> 5492 bytes demo/data/roads.dbf | Bin 0 -> 1127355 bytes demo/data/roads.shp | Bin 0 -> 545476 bytes demo/data/roads.shx | Bin 0 -> 31956 bytes demo/python/README.txt | 20 ++ demo/python/rundemo.py | 379 +++++++++++++++++++++++++++ setup.py | 1 - src/mapnik_feature.cpp | 8 +- src/mapnik_map.cpp | 1 + src/mapnik_parameters.cpp | 2 +- src/mapnik_python.cpp | 5 +- src/mapnik_svg.hpp | 4 +- src/mapnik_symbolizer.cpp | 43 ++++ src/mapnik_text_placement.cpp | 583 ------------------------------------------ 30 files changed, 457 insertions(+), 594 deletions(-) diff --git a/README.md b/README.md index 2549bbf..7af1719 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ git submodule update --init python setup.py test ``` -The test data in `./test/data` and `./test/data-visual` are standalone modules. If you need to update them see https://github.com/mapnik/mapnik/blob/master/docs/contributing.markdown#testing +The test data in `./test/data` and `./test/data-visual` are standalone modules. If you need to update them see https://github.com/mapnik/mapnik/blob/master/docs/contributing.md#testing ### Troubleshooting diff --git a/demo/data/COPYRIGHT.txt b/demo/data/COPYRIGHT.txt new file mode 100644 index 0000000..4758477 --- /dev/null +++ b/demo/data/COPYRIGHT.txt @@ -0,0 +1,3 @@ +� 2003. Government of Canada with permission from Natural Resources Canada + +Original License: http://geogratis.cgdi.gc.ca/geogratis/en/licence.jsp diff --git a/demo/data/boundaries.dbf b/demo/data/boundaries.dbf new file mode 100644 index 0000000..04d2ed6 Binary files /dev/null and b/demo/data/boundaries.dbf differ diff --git a/demo/data/boundaries.shp b/demo/data/boundaries.shp new file mode 100644 index 0000000..48fcfdb Binary files /dev/null and b/demo/data/boundaries.shp differ diff --git a/demo/data/boundaries.shx b/demo/data/boundaries.shx new file mode 100644 index 0000000..9a6bd46 Binary files /dev/null and b/demo/data/boundaries.shx differ diff --git a/demo/data/boundaries_l.dbf b/demo/data/boundaries_l.dbf new file mode 100644 index 0000000..44d4ca8 Binary files /dev/null and b/demo/data/boundaries_l.dbf differ diff --git a/demo/data/boundaries_l.shp b/demo/data/boundaries_l.shp new file mode 100644 index 0000000..9951fe8 Binary files /dev/null and b/demo/data/boundaries_l.shp differ diff --git a/demo/data/boundaries_l.shx b/demo/data/boundaries_l.shx new file mode 100644 index 0000000..d0f18f8 Binary files /dev/null and b/demo/data/boundaries_l.shx differ diff --git a/demo/data/ontdrainage.dbf b/demo/data/ontdrainage.dbf new file mode 100644 index 0000000..8192650 Binary files /dev/null and b/demo/data/ontdrainage.dbf differ diff --git a/demo/data/ontdrainage.shp b/demo/data/ontdrainage.shp new file mode 100644 index 0000000..758d37e Binary files /dev/null and b/demo/data/ontdrainage.shp differ diff --git a/demo/data/ontdrainage.shx b/demo/data/ontdrainage.shx new file mode 100644 index 0000000..9f11f92 Binary files /dev/null and b/demo/data/ontdrainage.shx differ diff --git a/demo/data/popplaces.dbf b/demo/data/popplaces.dbf new file mode 100644 index 0000000..d385b6f Binary files /dev/null and b/demo/data/popplaces.dbf differ diff --git a/demo/data/popplaces.shp b/demo/data/popplaces.shp new file mode 100644 index 0000000..3c3f7ac Binary files /dev/null and b/demo/data/popplaces.shp differ diff --git a/demo/data/popplaces.shx b/demo/data/popplaces.shx new file mode 100644 index 0000000..f36ff6b Binary files /dev/null and b/demo/data/popplaces.shx differ diff --git a/demo/data/qcdrainage.dbf b/demo/data/qcdrainage.dbf new file mode 100644 index 0000000..04fcf85 Binary files /dev/null and b/demo/data/qcdrainage.dbf differ diff --git a/demo/data/qcdrainage.shp b/demo/data/qcdrainage.shp new file mode 100644 index 0000000..ce685f8 Binary files /dev/null and b/demo/data/qcdrainage.shp differ diff --git a/demo/data/qcdrainage.shx b/demo/data/qcdrainage.shx new file mode 100644 index 0000000..295f570 Binary files /dev/null and b/demo/data/qcdrainage.shx differ diff --git a/demo/data/roads.dbf b/demo/data/roads.dbf new file mode 100644 index 0000000..709f881 Binary files /dev/null and b/demo/data/roads.dbf differ diff --git a/demo/data/roads.shp b/demo/data/roads.shp new file mode 100644 index 0000000..6f7e2a2 Binary files /dev/null and b/demo/data/roads.shp differ diff --git a/demo/data/roads.shx b/demo/data/roads.shx new file mode 100644 index 0000000..5d4b156 Binary files /dev/null and b/demo/data/roads.shx differ diff --git a/demo/python/README.txt b/demo/python/README.txt new file mode 100644 index 0000000..4a13579 --- /dev/null +++ b/demo/python/README.txt @@ -0,0 +1,20 @@ +This directory contains a sample python script implementing the Mapnik API. + +The script is thoroughly commented and also acts as a mini tutorial. Reading +it should get you on your way, and you can use it as a base for your work. + +You must compile and install mapnik and the python bindings FIRST. + +Once this is done, run it: + +/path/to/python rundemo.py + +If all goes well, it should render 2 map images: + +demo.jpg +demo.png + +Have a look! + +Cheers, +J.F. diff --git a/demo/python/rundemo.py b/demo/python/rundemo.py new file mode 100755 index 0000000..910d846 --- /dev/null +++ b/demo/python/rundemo.py @@ -0,0 +1,379 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# +# +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Jean-Francois Doyon +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +from __future__ import print_function +import sys +from os import path +import mapnik + +# Instanciate a map, giving it a width and height. Remember: the word "map" is +# reserved in Python! :) + +root = path.dirname(__file__) +m = mapnik.Map(800,600,"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs") + +# Set its background colour. More on colours later ... + +m.background = mapnik.Color('white') + +# Now we can start adding layers, in stacking order (i.e. bottom layer first) + +# Canadian Provinces (Polygons) + +# Instanciate a layer. The parameters depend on the type of data: +# shape: +# type='shape' +# file='/path/to/shape' +# raster: +# type='raster' +# file='/path/to/raster' +# postgis: +# type='postgis' +# host='127.0.0.1' +# dbname='mydatabase' +# user='myusername' +# password='mypassword' +# table= TODO + +provpoly_lyr = mapnik.Layer('Provinces') +provpoly_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +provpoly_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/boundaries'), encoding='latin1') + +# 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. +# Multiple styles per layer behaves functionally like multiple layers. The +# data is completely re-scanned for each style within one layer, and a style +# will be drawn entirely "above" the previous one. Performance wise using +# multiple styles in one layer is the same has having multiple layers. +# The paradigm is useful mostly as a convenience. + +provpoly_style = mapnik.Style() + +# A Style needs one or more rules. A rule will normally consist of a filter +# for feature selection, and one or more symbolizers. + +provpoly_rule_on = mapnik.Rule() + +# A Expression() allows the selection of features to which the symbology will +# be applied. More on Mapnik expressions can be found in Tutorial #2. +# A given feature can only match one filter per rule per style. + +provpoly_rule_on.filter = mapnik.Expression("[NAME_EN] = 'Ontario'") + +# Here a symbolizer is defined. Available are: +# - LineSymbolizer(Color(),<width>) +# - LineSymbolizer(Stroke()) +# - PolygonSymbolizer(Color()) +# - PointSymbolizer(<file>,<type>,<width>,<height>) + +# Some of them can accept a Color() instance, which can be created with: +# - Color(<red>, <green>, <blue>) +# - Color(<red>, <green>, <blue>, <alpha>) +# - Color(<string>) where <string> will be something like '#00FF00' +# or '#0f0' or 'green' + +sym = mapnik.PolygonSymbolizer() +sym.fill = mapnik.Color(250, 190, 183); +provpoly_rule_on.symbols.append(sym) +provpoly_style.rules.append(provpoly_rule_on) + +provpoly_rule_qc = mapnik.Rule() +provpoly_rule_qc.filter = mapnik.Expression("[NOM_FR] = 'Québec'") +sym = mapnik.PolygonSymbolizer() +sym.fill = mapnik.Color(217, 235, 203) +provpoly_rule_qc.symbols.append(sym) +provpoly_style.rules.append(provpoly_rule_qc) + +# Add the style to the map, giving it a name. This is the name that will be +# used to refer to it from here on. Having named styles allows them to be +# re-used throughout the map. + +m.append_style('provinces', provpoly_style) + +# Then associate the style to the layer itself. + +provpoly_lyr.styles.append('provinces') + +# Then add the layer to the map. In reality, it's the order in which you +# append them to the map that will determine the drawing order, though by +# convention it is recommended to define them in drawing order as well. + +m.layers.append(provpoly_lyr) + +# Drainage + +# A simple example ... + +qcdrain_lyr = mapnik.Layer('Quebec Hydrography') +qcdrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +qcdrain_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/qcdrainage')) + +qcdrain_style = mapnik.Style() +qcdrain_rule = mapnik.Rule() +qcdrain_rule.filter = mapnik.Expression('[HYC] = 8') +sym = mapnik.PolygonSymbolizer() +sym.fill = mapnik.Color(153, 204, 255) +sym.smooth = 1.0 # very smooth +qcdrain_rule.symbols.append(sym) +qcdrain_style.rules.append(qcdrain_rule) + +m.append_style('drainage', qcdrain_style) +qcdrain_lyr.styles.append('drainage') +m.layers.append(qcdrain_lyr) + +# In this case, we have 2 data sets with similar schemas (same filtering +# attributes, and same desired style), so we're going to +# re-use the style defined in the above layer for the next one. + +ondrain_lyr = mapnik.Layer('Ontario Hydrography') +ondrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +ondrain_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/ontdrainage')) + +ondrain_lyr.styles.append('drainage') +m.layers.append(ondrain_lyr) + +# Provincial boundaries + +provlines_lyr = mapnik.Layer('Provincial borders') +provlines_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +provlines_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/boundaries_l')) + +# Here we define a "dash dot dot dash" pattern for the provincial boundaries. + +provlines_style = mapnik.Style() +provlines_rule = mapnik.Rule() +sym = mapnik.LineSymbolizer() +# FIXME - currently adding dash arrays is broken +# https://github.com/mapnik/mapnik/issues/2324 +sym.stroke = mapnik.Color('black') +sym.stroke_width = 1.0 +provlines_rule.symbols.append(sym) +provlines_style.rules.append(provlines_rule) + +m.append_style('provlines', provlines_style) +provlines_lyr.styles.append('provlines') +m.layers.append(provlines_lyr) + +# Roads 3 and 4 (The "grey" roads) + +roads34_lyr = mapnik.Layer('Roads') +roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +# create roads datasource (we're going to re-use it later) + +roads34_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/roads')) + +roads34_style = mapnik.Style() +roads34_rule = mapnik.Rule() +roads34_rule.filter = mapnik.Expression('([CLASS] = 3) or ([CLASS] = 4)') + +# With lines of a certain width, you can control how the ends +# are closed off using line_cap as below. + +# Available options are: +# line_cap: BUTT_CAP, SQUARE_CAP, ROUND_CAP +# line_join: MITER_JOIN, MITER_REVERT_JOIN, ROUND_JOIN, BEVEL_JOIN + +# And one last Stroke() attribute not used here is "opacity", which +# can be set to a numerical value. + +sym = mapnik.LineSymbolizer() +sym.stroke = mapnik.Color(171,158,137) +sym.stroke_width = 2.0 +sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP + +roads34_rule.symbols.append(sym) +roads34_style.rules.append(roads34_rule) + +m.append_style('smallroads', roads34_style) +roads34_lyr.styles.append('smallroads') +m.layers.append(roads34_lyr) + +# Roads 2 (The thin yellow ones) + +roads2_lyr = mapnik.Layer('Roads') +roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +# Just get a copy from roads34_lyr +roads2_lyr.datasource = roads34_lyr.datasource + +roads2_style_1 = mapnik.Style() +roads2_rule_1 = mapnik.Rule() +roads2_rule_1.filter = mapnik.Expression('[CLASS] = 2') + +sym = mapnik.LineSymbolizer() +sym.stroke = mapnik.Color(171,158,137) +sym.stroke_width = 4.0 +sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP +roads2_rule_1.symbols.append(sym) +roads2_style_1.rules.append(roads2_rule_1) + +m.append_style('road-border', roads2_style_1) + +roads2_style_2 = mapnik.Style() +roads2_rule_2 = mapnik.Rule() +roads2_rule_2.filter = mapnik.Expression('[CLASS] = 2') +sym = mapnik.LineSymbolizer() +sym.stroke = mapnik.Color(255,250,115) +sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP +sym.stroke_width = 2.0 +roads2_rule_2.symbols.append(sym) +roads2_style_2.rules.append(roads2_rule_2) + +m.append_style('road-fill', roads2_style_2) + +roads2_lyr.styles.append('road-border') +roads2_lyr.styles.append('road-fill') + +m.layers.append(roads2_lyr) + +# Roads 1 (The big orange ones, the highways) + +roads1_lyr = mapnik.Layer('Roads') +roads1_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +roads1_lyr.datasource = roads34_lyr.datasource + +roads1_style_1 = mapnik.Style() +roads1_rule_1 = mapnik.Rule() +roads1_rule_1.filter = mapnik.Expression('[CLASS] = 1') +sym = mapnik.LineSymbolizer() +sym.stroke = mapnik.Color(188,149,28) +sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP +sym.stroke_width = 7.0 +roads1_rule_1.symbols.append(sym) +roads1_style_1.rules.append(roads1_rule_1) +m.append_style('highway-border', roads1_style_1) + +roads1_style_2 = mapnik.Style() +roads1_rule_2 = mapnik.Rule() +roads1_rule_2.filter = mapnik.Expression('[CLASS] = 1') +sym.stroke = mapnik.Color(242,191,36) +sym.stroke_linecap = mapnik.stroke_linecap.ROUND_CAP +sym.stroke_width = 5.0 +roads1_rule_2.symbols.append(sym) +roads1_style_2.rules.append(roads1_rule_2) + +m.append_style('highway-fill', roads1_style_2) + +roads1_lyr.styles.append('highway-border') +roads1_lyr.styles.append('highway-fill') + +m.layers.append(roads1_lyr) + +# Populated Places + +popplaces_lyr = mapnik.Layer('Populated Places') +popplaces_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" +popplaces_lyr.datasource = mapnik.Shapefile(file=path.join(root,'../data/popplaces'),encoding='latin1') + +popplaces_style = mapnik.Style() +popplaces_rule = mapnik.Rule() + +# And here we have a TextSymbolizer, used for labeling. +# The first parameter is the name of the attribute to use as the source of the +# text to label with. Then there is font size in points (I think?), and colour. + +# TODO - currently broken: https://github.com/mapnik/mapnik/issues/2324 +#popplaces_text_symbolizer = mapnik.TextSymbolizer(mapnik.Expression("[GEONAME]"), +# 'DejaVu Sans Book', +# 10, mapnik.Color('black')) + +# We set a "halo" around the text, which looks like an outline if thin enough, +# or an outright background if large enough. +#popplaces_text_symbolizer.label_placement= mapnik.label_placement.POINT_PLACEMENT +#popplaces_text_symbolizer.halo_fill = mapnik.Color(255,255,200) +#popplaces_text_symbolizer.halo_radius = 1 +#popplaces_text_symbolizer.avoid_edges = True +#popplaces_text_symbolizer.minimum_padding = 30 +#popplaces_rule.symbols.append(popplaces_text_symbolizer) + +popplaces_style.rules.append(popplaces_rule) + +m.append_style('popplaces', popplaces_style) +popplaces_lyr.styles.append('popplaces') +m.layers.append(popplaces_lyr) + +# Draw map + +# Set the initial extent of the map in 'master' spherical Mercator projection +m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855)) + +# Render map +im = mapnik.Image(m.width,m.height) +mapnik.render(m, im) + +# Save image to files +images_ = [] +if mapnik.has_png(): + im.save('demo.png', 'png') # true-colour RGBA + images_.append('demo.png') + + # old behavior, now can do 'png8:c=256' + im.save('demo256.png', 'png256') # save to palette based (max 256 colours) png + images_.append('demo256.png') + + im.save('demo64_binary_transparency.png', 'png8:c=64:t=1') + images_.append('demo64_binary_transparency.png') + + im.save('demo128_colors_hextree_no_alpha.png', 'png8:c=100:m=h:t=0') + images_.append('demo128_colors_hextree_no_alpha.png') + +if mapnik.has_jpeg(): + im.save('demo_high.jpg', 'jpeg100') + images_.append('demo_high.jpg') + + im.save('demo_low.jpg', 'jpeg50') + images_.append('demo_low.jpg') + +if mapnik.has_tiff(): + im.save('demo.tif', 'tiff') + images_.append('demo.tif') + +if mapnik.has_webp(): + im.save('demo.webp', 'webp') # default quality is 90 + images_.append('demo.webp') + + im.save('demo_highest.webp', 'webp:quality=100') + images_.append('demo_med.webp') + + im.save('demo_low.webp', 'webp:quality=50') + images_.append('demo_low.webp') + + +# Render cairo examples +if mapnik.has_cairo(): + mapnik.render_to_file(m,'demo.pdf') + images_.append('demo.pdf') + mapnik.render_to_file(m,'demo.ps') + images_.append('demo.ps') + mapnik.render_to_file(m,'demo.svg') + images_.append('demo.svg') + mapnik.render_to_file(m,'demo_cairo_rgb24.png','RGB24') + images_.append('demo_cairo_rgb.png') + mapnik.render_to_file(m,'demo_cairo_argb32.png','ARGB32') + images_.append('demo_cairo_argb.png') + +print ("\n\n", len(images_), "maps have been rendered in the current directory:") + +for im_ in images_: + print ("-", im_) + +print ("\n\nHave a look!\n\n") + +mapnik.save_map(m,"map.xml") diff --git a/setup.py b/setup.py index b56b9a1..23be235 100755 --- a/setup.py +++ b/setup.py @@ -307,7 +307,6 @@ setup( 'src/mapnik_style.cpp', 'src/mapnik_svg_generator_grammar.cpp', 'src/mapnik_symbolizer.cpp', - 'src/mapnik_text_placement.cpp', 'src/mapnik_view_transform.cpp', 'src/python_grid_utils.cpp', ], diff --git a/src/mapnik_feature.cpp b/src/mapnik_feature.cpp index e8f1fbc..dc06170 100644 --- a/src/mapnik_feature.cpp +++ b/src/mapnik_feature.cpp @@ -40,9 +40,8 @@ #include <mapnik/feature_kv_iterator.hpp> #include <mapnik/datasource.hpp> #include <mapnik/wkb.hpp> -//#include <mapnik/wkt/wkt_factory.hpp> #include <mapnik/json/feature_parser.hpp> -#include <mapnik/json/feature_generator.hpp> +#include <mapnik/util/feature_to_geojson.hpp> // stl #include <stdexcept> @@ -67,7 +66,7 @@ mapnik::feature_ptr from_geojson_impl(std::string const& json, mapnik::context_p std::string feature_to_geojson(mapnik::feature_impl const& feature) { std::string json; - if (!mapnik::json::to_geojson(json,feature)) + if (!mapnik::util::to_geojson(json,feature)) { throw std::runtime_error("Failed to generate GeoJSON"); } @@ -215,7 +214,8 @@ void export_feature() boost::noncopyable>("Feature",init<context_ptr,mapnik::value_integer>("Default ctor.")) .def("id",&mapnik::feature_impl::id) .add_property("geometry", - make_function(&mapnik::feature_impl::get_geometry,return_value_policy<reference_existing_object>()), + make_function((mapnik::geometry::geometry<double>& (mapnik::feature_impl::*)()) + &mapnik::feature_impl::get_geometry, return_value_policy<reference_existing_object>()), &mapnik::feature_impl::set_geometry_copy) .def("envelope", &mapnik::feature_impl::envelope) .def("has_key", &mapnik::feature_impl::has_key) diff --git a/src/mapnik_map.cpp b/src/mapnik_map.cpp index e7efb51..3036cf8 100644 --- a/src/mapnik_map.cpp +++ b/src/mapnik_map.cpp @@ -35,6 +35,7 @@ #include <mapnik/rule.hpp> #include <mapnik/layer.hpp> #include <mapnik/map.hpp> +#include <mapnik/featureset.hpp> #include <mapnik/projection.hpp> #include <mapnik/view_transform.hpp> #include <mapnik/feature_type_style.hpp> diff --git a/src/mapnik_parameters.cpp b/src/mapnik_parameters.cpp index 6d7fb06..e5fc4e2 100644 --- a/src/mapnik_parameters.cpp +++ b/src/mapnik_parameters.cpp @@ -32,8 +32,8 @@ #include <mapnik/debug.hpp> #include <mapnik/params.hpp> #include <mapnik/unicode.hpp> -#include <mapnik/value_types.hpp> #include <mapnik/value.hpp> +#include <mapnik/value_types.hpp> // stl #include <iterator> diff --git a/src/mapnik_python.cpp b/src/mapnik_python.cpp index 7f8534c..b101cef 100644 --- a/src/mapnik_python.cpp +++ b/src/mapnik_python.cpp @@ -79,7 +79,7 @@ void export_polygon_symbolizer(); void export_building_symbolizer(); void export_polygon_pattern_symbolizer(); void export_raster_symbolizer(); -void export_text_placement(); +void export_text_symbolizer(); void export_shield_symbolizer(); void export_debug_symbolizer(); void export_group_symbolizer(); @@ -101,6 +101,7 @@ void export_logger(); #include <mapnik/image_any.hpp> #include <mapnik/load_map.hpp> #include <mapnik/value_error.hpp> +#include <mapnik/value.hpp> #include <mapnik/save_map.hpp> #include <mapnik/scale_denominator.hpp> #if defined(GRID_RENDERER) @@ -754,7 +755,7 @@ BOOST_PYTHON_MODULE(_mapnik) export_building_symbolizer(); export_polygon_pattern_symbolizer(); export_raster_symbolizer(); - export_text_placement(); + export_text_symbolizer(); export_shield_symbolizer(); export_debug_symbolizer(); export_group_symbolizer(); diff --git a/src/mapnik_svg.hpp b/src/mapnik_svg.hpp index 4555ecf..3c68f0c 100644 --- a/src/mapnik_svg.hpp +++ b/src/mapnik_svg.hpp @@ -48,8 +48,8 @@ void set_svg_transform(T& symbolizer, std::string const& transform_wkt) if (!trans_expr) { std::stringstream ss; - ss << "Could not parse transform from '" - << transform_wkt + ss << "Could not parse transform from '" + << transform_wkt << "', expected SVG transform attribute"; throw mapnik::value_error(ss.str()); } diff --git a/src/mapnik_symbolizer.cpp b/src/mapnik_symbolizer.cpp index 6473132..15c0392 100644 --- a/src/mapnik_symbolizer.cpp +++ b/src/mapnik_symbolizer.cpp @@ -202,6 +202,49 @@ void export_symbolizer() ; } +void export_text_symbolizer() +{ + using namespace boost::python; + mapnik::enumeration_<mapnik::label_placement_e>("label_placement") + .value("LINE_PLACEMENT", mapnik::LINE_PLACEMENT) + .value("POINT_PLACEMENT", mapnik::POINT_PLACEMENT) + .value("VERTEX_PLACEMENT", mapnik::VERTEX_PLACEMENT) + .value("INTERIOR_PLACEMENT", mapnik::INTERIOR_PLACEMENT); + + mapnik::enumeration_<mapnik::vertical_alignment_e>("vertical_alignment") + .value("TOP", mapnik::V_TOP) + .value("MIDDLE", mapnik::V_MIDDLE) + .value("BOTTOM", mapnik::V_BOTTOM) + .value("AUTO", mapnik::V_AUTO); + + mapnik::enumeration_<mapnik::horizontal_alignment_e>("horizontal_alignment") + .value("LEFT", mapnik::H_LEFT) + .value("MIDDLE", mapnik::H_MIDDLE) + .value("RIGHT", mapnik::H_RIGHT) + .value("AUTO", mapnik::H_AUTO); + + mapnik::enumeration_<mapnik::justify_alignment_e>("justify_alignment") + .value("LEFT", mapnik::J_LEFT) + .value("MIDDLE", mapnik::J_MIDDLE) + .value("RIGHT", mapnik::J_RIGHT) + .value("AUTO", mapnik::J_AUTO); + + mapnik::enumeration_<mapnik::text_transform_e>("text_transform") + .value("NONE", mapnik::NONE) + .value("UPPERCASE", mapnik::UPPERCASE) + .value("LOWERCASE", mapnik::LOWERCASE) + .value("CAPITALIZE", mapnik::CAPITALIZE); + + mapnik::enumeration_<mapnik::halo_rasterizer_e>("halo_rasterizer") + .value("FULL", mapnik::HALO_RASTERIZER_FULL) + .value("FAST", mapnik::HALO_RASTERIZER_FAST); + + class_< text_symbolizer, bases<symbolizer_base> >("TextSymbolizer", + init<>("Default ctor")) + .def("__hash__",hash_impl_2<text_symbolizer>) + ; + +} void export_shield_symbolizer() { diff --git a/src/mapnik_text_placement.cpp b/src/mapnik_text_placement.cpp deleted file mode 100644 index 05aef76..0000000 --- a/src/mapnik_text_placement.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2015 Artem Pavlenko, Jean-Francois Doyon - * - * 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 - * - *****************************************************************************/ - -#include <mapnik/config.hpp> -#include "boost_std_shared_shim.hpp" - -#pragma GCC diagnostic push -#include <mapnik/warning_ignore.hpp> -#include <boost/python.hpp> -#include <boost/python/stl_iterator.hpp> -#include <boost/noncopyable.hpp> -#pragma GCC diagnostic pop - -#include <mapnik/text/text_properties.hpp> -#include <mapnik/text/placements/simple.hpp> -#include <mapnik/text/placements/list.hpp> -#include <mapnik/text/formatting/text.hpp> -#include <mapnik/text/formatting/list.hpp> -#include <mapnik/text/formatting/format.hpp> -#include <mapnik/text/formatting/layout.hpp> -#include <mapnik/text/text_layout.hpp> -#include <mapnik/symbolizer.hpp> - -#include "mapnik_enumeration.hpp" -#include "mapnik_threads.hpp" - -using namespace mapnik; - -/* Notes: - Overriding functions in inherited classes: - boost.python documentation doesn't really tell you how to do it. - But this helps: - http://www.gamedev.net/topic/446225-inheritance-in-boostpython/ - - register_ptr_to_python is required for wrapped classes, but not for unwrapped. - - Functions don't have to be members of the class, but can also be - normal functions taking a ref to the class as first parameter. -*/ - -namespace { - -using namespace boost::python; - -// This class works around a feature in boost python. -// See http://osdir.com/ml/python.c++/2003-11/msg00158.html - -template <typename T, - typename X1 = boost::python::detail::not_specified, - typename X2 = boost::python::detail::not_specified, - typename X3 = boost::python::detail::not_specified> -class class_with_converter : public boost::python::class_<T, X1, X2, X3> -{ -public: - using self = class_with_converter<T,X1,X2,X3>; - // Construct with the class name, with or without docstring, and default __init__() function - class_with_converter(char const* name, char const* doc = 0) : boost::python::class_<T, X1, X2, X3>(name, doc) { } - - // Construct with class name, no docstring, and an uncallable __init__ function - class_with_converter(char const* name, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, y) { } - - // Construct with class name, docstring, and an uncallable __init__ function - class_with_converter(char const* name, char const* doc, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, doc, y) { } - - // Construct with class name and init<> function - template <class DerivedT> class_with_converter(char const* name, boost::python::init_base<DerivedT> const& i) - : boost::python::class_<T, X1, X2, X3>(name, i) { } - - // Construct with class name, docstring and init<> function - template <class DerivedT> - inline class_with_converter(char const* name, char const* doc, boost::python::init_base<DerivedT> const& i) - : boost::python::class_<T, X1, X2, X3>(name, doc, i) { } - - template <class D> - self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0) - { - this->add_property(name, - boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()), - boost::python::make_setter(d, boost::python::default_call_policies())); - return *this; - } -}; - -/* -boost::python::tuple get_displacement(text_layout_properties const& t) -{ - return boost::python::make_tuple(0.0,0.0);// FIXME t.displacement.x, t.displacement.y); -} - -void set_displacement(text_layout_properties &t, boost::python::tuple arg) -{ - if (len(arg) != 2) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 2-item tuple in call to set_displacement; got %s" - % arg).ptr() - ); - throw_error_already_set(); - } - - //double x = extract<double>(arg[0]); - //double y = extract<double>(arg[1]); - //t.displacement.set(x, y); FIXME -} - - -struct NodeWrap - : formatting::node, wrapper<formatting::node> -{ - NodeWrap() - : formatting::node(), wrapper<formatting::node>() {} - - void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - python_block_auto_unblock b; - this->get_override("apply")(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - - virtual void add_expressions(expression_set &output) const - { - override o = this->get_override("add_expressions"); - if (o) - { - python_block_auto_unblock b; - o(ptr(&output)); - } else - { - formatting::node::add_expressions(output); - } - } - - void default_add_expressions(expression_set &output) const - { - formatting::node::add_expressions(output); - } -}; -*/ -/* -struct TextNodeWrap - : formatting::text_node, wrapper<formatting::text_node> -{ - TextNodeWrap(expression_ptr expr) - : formatting::text_node(expr), wrapper<formatting::text_node>() {} - - TextNodeWrap(std::string expr_text) - : formatting::text_node(expr_text), wrapper<formatting::text_node>() {} - - virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - if(override o = this->get_override("apply")) - { - python_block_auto_unblock b; - o(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - else - { - formatting::text_node::apply(p, feature, vars, output); - } - } - - void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - formatting::text_node::apply(p, feature, vars, output); - } -}; -*/ -/* -struct FormatNodeWrap - : formatting::format_node, wrapper<formatting::format_node> -{ - virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - if(override o = this->get_override("apply")) - { - python_block_auto_unblock b; - o(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - else - { - formatting::format_node::apply(p, feature, vars ,output); - } - } - - void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - formatting::format_node::apply(p, feature, vars, output); - } -}; - -struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expression_format> -{ - virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - if(override o = this->get_override("apply")) - { - python_block_auto_unblock b; - o(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - else - { - formatting::expression_format::apply(p, feature, vars, output); - } - } - - void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - formatting::expression_format::apply(p, feature, vars, output); - } -}; - -struct LayoutNodeWrap: formatting::layout_node, wrapper<formatting::layout_node> -{ - virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - if(override o = this->get_override("apply")) - { - python_block_auto_unblock b; - o(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - else - { - formatting::layout_node::apply(p, feature, vars, output); - } - } - - void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - formatting::layout_node::apply(p, feature, vars, output); - } -}; - -struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node> -{ - //Default constructor - ListNodeWrap() : formatting::list_node(), wrapper<formatting::list_node>() - { - } - - //Special constructor: Takes a python sequence as its argument - ListNodeWrap(object l) : formatting::list_node(), wrapper<formatting::list_node>() - { - stl_input_iterator<formatting::node_ptr> begin(l), end; - while (begin != end) - { - children_.push_back(*begin); - ++begin; - } - } - - // TODO: Add constructor taking variable number of arguments. - http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function - - virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - if(override o = this->get_override("apply")) - { - python_block_auto_unblock b; - o(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); - } - else - { - formatting::list_node::apply(p, feature, vars, output); - } - } - - void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const - { - formatting::list_node::apply(p, feature, vars, output); - } - - inline void IndexError(){ - PyErr_SetString(PyExc_IndexError, "Index out of range"); - throw_error_already_set(); - } - - unsigned get_length() - { - return children_.size(); - } - - formatting::node_ptr get_item(int i) - { - if (i < 0) i+= children_.size(); - if (i < static_cast<int>(children_.size())) return children_[i]; - IndexError(); - return formatting::node_ptr(); //Avoid compiler warning - } - - void set_item(int i, formatting::node_ptr ptr) - { - if (i < 0) i+= children_.size(); - if (i < static_cast<int>(children_.size())) children_[i] = ptr; - IndexError(); - } - - void append(formatting::node_ptr ptr) - { - children_.push_back(ptr); - } -}; -*/ -/* -struct TextPlacementsWrap: text_placements, wrapper<text_placements> -{ - text_placement_info_ptr get_placement_info(double scale_factor_) const - { - python_block_auto_unblock b; - //return this->get_override("get_placement_info")(); - return text_placement_info_ptr(); - } -}; - -struct TextPlacementInfoWrap: text_placement_info, wrapper<text_placement_info> -{ - TextPlacementInfoWrap(text_placements const* parent, - double scale_factor_) - : text_placement_info(parent, scale_factor_) - { - - } - - bool next() - { - python_block_auto_unblock b; - return this->get_override("next")(); - } -}; - -void insert_expression(expression_set *set, expression_ptr p) -{ - set->insert(p); -} - - -evaluated_format_properties_ptr get_format(text_symbolizer const& sym) -{ - return sym.get_placement_options()->defaults.format; -} - -void set_format(text_symbolizer const& sym, evaluated_format_properties_ptr format) -{ - sym.get_placement_options()->defaults.format = format; -} - -text_symbolizer_properties & get_properties(text_symbolizer const& sym) -{ - return sym.get_placement_options()->defaults; -} - -void set_properties(text_symbolizer const& sym, text_symbolizer_properties & defaults) -{ - sym.get_placement_options()->defaults = defaults; -} -*/ -} - -void export_text_placement() -{ - /* - using namespace boost::python; - - enumeration_<label_placement_e>("label_placement") - .value("LINE_PLACEMENT",LINE_PLACEMENT) - .value("POINT_PLACEMENT",POINT_PLACEMENT) - .value("VERTEX_PLACEMENT",VERTEX_PLACEMENT) - .value("INTERIOR_PLACEMENT",INTERIOR_PLACEMENT) - ; - enumeration_<vertical_alignment_e>("vertical_alignment") - .value("TOP",V_TOP) - .value("MIDDLE",V_MIDDLE) - .value("BOTTOM",V_BOTTOM) - .value("AUTO",V_AUTO) - ; - - enumeration_<horizontal_alignment_e>("horizontal_alignment") - .value("LEFT",H_LEFT) - .value("MIDDLE",H_MIDDLE) - .value("RIGHT",H_RIGHT) - .value("AUTO",H_AUTO) - ; - - enumeration_<justify_alignment_e>("justify_alignment") - .value("LEFT",J_LEFT) - .value("MIDDLE",J_MIDDLE) - .value("RIGHT",J_RIGHT) - .value("AUTO", J_AUTO) - ; - - enumeration_<text_transform_e>("text_transform") - .value("NONE",NONE) - .value("UPPERCASE",UPPERCASE) - .value("LOWERCASE",LOWERCASE) - .value("CAPITALIZE",CAPITALIZE) - ; - - enumeration_<halo_rasterizer_e>("halo_rasterizer") - .value("FULL",HALO_RASTERIZER_FULL) - .value("FAST",HALO_RASTERIZER_FAST) - ; - */ - class_<text_symbolizer>("TextSymbolizer", - init<>()) - ; - /* - - class_with_converter<text_symbolizer_properties> - ("TextSymbolizerProperties") - .def_readwrite_convert("label_placement", &text_symbolizer_properties::label_placement) - .def_readwrite_convert("upright", &text_symbolizer_properties::upright) - .def_readwrite("label_spacing", &text_symbolizer_properties::label_spacing) - .def_readwrite("label_position_tolerance", &text_symbolizer_properties::label_position_tolerance) - .def_readwrite("avoid_edges", &text_symbolizer_properties::avoid_edges) - .def_readwrite("margin", &text_symbolizer_properties::margin) - .def_readwrite("repeat_distance", &text_symbolizer_properties::repeat_distance) - .def_readwrite("minimum_distance", &text_symbolizer_properties::minimum_distance) - .def_readwrite("minimum_padding", &text_symbolizer_properties::minimum_padding) - .def_readwrite("minimum_path_length", &text_symbolizer_properties::minimum_path_length) - .def_readwrite("maximum_angle_char_delta", &text_symbolizer_properties::max_char_angle_delta) - .def_readwrite("allow_overlap", &text_symbolizer_properties::allow_overlap) - .def_readwrite("largest_bbox_only", &text_symbolizer_properties::largest_bbox_only) - .def_readwrite("layout_defaults", &text_symbolizer_properties::layout_defaults) - //.def_readwrite("format", &text_symbolizer_properties::format) - .add_property ("format_tree", - &text_symbolizer_properties::format_tree, - &text_symbolizer_properties::set_format_tree); - //from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python. - // add_expressions isn't useful in python either. The result is only needed by - // attribute_collector (which isn't exposed in python) and - // it just calls add_expressions of the associated formatting tree. - // set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. - ; - - class_with_converter<text_layout_properties> - ("TextLayoutProperties") - .def_readwrite_convert("horizontal_alignment", &text_layout_properties::halign) - .def_readwrite_convert("justify_alignment", &text_layout_properties::jalign) - .def_readwrite_convert("vertical_alignment", &text_layout_properties::valign) - .def_readwrite("text_ratio", &text_layout_properties::text_ratio) - .def_readwrite("wrap_width", &text_layout_properties::wrap_width) - .def_readwrite("wrap_before", &text_layout_properties::wrap_before) - .def_readwrite("orientation", &text_layout_properties::orientation) - .def_readwrite("rotate_displacement", &text_layout_properties::rotate_displacement) - .add_property("displacement", &get_displacement, &set_displacement); - - class_with_converter<detail::evaluated_format_properties> - ("CharProperties") - .def_readwrite_convert("text_transform", &detail::evaluated_format_properties::text_transform) - .def_readwrite_convert("fontset", &detail::evaluated_format_properties::fontset) - .def(init<detail::evaluated_format_properties const&>()) //Copy constructor - .def_readwrite("face_name", &detail::evaluated_format_properties::face_name) - .def_readwrite("text_size", &detail::evaluated_format_properties::text_size) - .def_readwrite("character_spacing", &detail::evaluated_format_properties::character_spacing) - .def_readwrite("line_spacing", &detail::evaluated_format_properties::line_spacing) - .def_readwrite("text_opacity", &detail::evaluated_format_properties::text_opacity) - .def_readwrite("fill", &detail::evaluated_format_properties::fill) - .def_readwrite("halo_fill", &detail::evaluated_format_properties::halo_fill) - .def_readwrite("halo_radius", &evaluated_format_properties::halo_radius) - //from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python. - ; - class_<TextPlacementsWrap, - std::shared_ptr<TextPlacementsWrap>, - boost::noncopyable> - ("TextPlacements") - .def_readwrite("defaults", &text_placements::defaults) - //.def("get_placement_info", pure_virtual(&text_placements::get_placement_info)) - // TODO: add_expressions() - ; - register_ptr_to_python<std::shared_ptr<text_placements> >(); - - class_<TextPlacementInfoWrap, - std::shared_ptr<TextPlacementInfoWrap>, - boost::noncopyable> - ("TextPlacementInfo", - init<text_placements const*, double>()) - .def("next", pure_virtual(&text_placement_info::next)) - .def_readwrite("properties", &text_placement_info::properties) - .def_readwrite("scale_factor", &text_placement_info::scale_factor) - ; - register_ptr_to_python<std::shared_ptr<text_placement_info> >(); - - - class_<expression_set,std::shared_ptr<expression_set>, - boost::noncopyable>("ExpressionSet") - .def("insert", &insert_expression); - ; - - class_<formatting::node,std::shared_ptr<formatting::node>, - boost::noncopyable>("FormattingNode") - .def("apply", pure_virtual(&formatting::node::apply)) - .def("add_expressions", pure_virtual(&formatting::node::add_expressions)) - .def("to_xml", pure_virtual(&formatting::node::to_xml)) - ; - - register_ptr_to_python<std::shared_ptr<formatting::node> >(); - - class_<formatting::text_node, - std::shared_ptr<formatting::text_node>, - bases<formatting::node>,boost::noncopyable>("FormattingText", init<expression_ptr>()) - .def(init<std::string>()) - .def("apply", &formatting::text_node::apply)//, &TextNodeWrap::default_apply) - .add_property("text",&formatting::text_node::get_text, &formatting::text_node::set_text) - ; - - register_ptr_to_python<std::shared_ptr<formatting::text_node> >(); - - class_with_converter<FormatNodeWrap, - std::shared_ptr<FormatNodeWrap>, - bases<formatting::node>, - boost::noncopyable> - ("FormattingFormat") - .def_readwrite_convert("text_size", &formatting::format_node::text_size) - .def_readwrite_convert("face_name", &formatting::format_node::face_name) - .def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing) - .def_readwrite_convert("line_spacing", &formatting::format_node::line_spacing) - .def_readwrite_convert("text_opacity", &formatting::format_node::text_opacity) - .def_readwrite_convert("text_transform", &formatting::format_node::text_transform) - .def_readwrite_convert("fill", &formatting::format_node::fill) - .def_readwrite_convert("halo_fill", &formatting::format_node::halo_fill) - .def_readwrite_convert("halo_radius", &formatting::format_node::halo_radius) - .def("apply", &formatting::format_node::apply, &FormatNodeWrap::default_apply) - .add_property("child", - &formatting::format_node::get_child, - &formatting::format_node::set_child) - ; - register_ptr_to_python<std::shared_ptr<formatting::format_node> >(); - - class_<ListNodeWrap, - std::shared_ptr<ListNodeWrap>, - bases<formatting::node>, - boost::noncopyable> - ("FormattingList", init<>()) - .def(init<list>()) - .def("append", &formatting::list_node::push_back) - .def("apply", &formatting::list_node::apply, &ListNodeWrap::default_apply) - .def("__len__", &ListNodeWrap::get_length) - .def("__getitem__", &ListNodeWrap::get_item) - .def("__setitem__", &ListNodeWrap::set_item) - .def("append", &ListNodeWrap::append) - ; - - register_ptr_to_python<std::shared_ptr<formatting::list_node> >(); - - class_<ExprFormatWrap, - std::shared_ptr<ExprFormatWrap>, - bases<formatting::node>, - boost::noncopyable> - ("FormattingExpressionFormat") - .def_readwrite("text_size", &formatting::expression_format::text_size) - .def_readwrite("face_name", &formatting::expression_format::face_name) - .def_readwrite("character_spacing", &formatting::expression_format::character_spacing) - .def_readwrite("line_spacing", &formatting::expression_format::line_spacing) - .def_readwrite("text_opacity", &formatting::expression_format::text_opacity) - .def_readwrite("fill", &formatting::expression_format::fill) - .def_readwrite("halo_fill", &formatting::expression_format::halo_fill) - .def_readwrite("halo_radius", &formatting::expression_format::halo_radius) - .def("apply", &formatting::expression_format::apply, &ExprFormatWrap::default_apply) - .add_property("child", - &formatting::expression_format::get_child, - &formatting::expression_format::set_child) - ; - register_ptr_to_python<std::shared_ptr<formatting::expression_format> >(); -*/ - //TODO: registry -} -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-mapnik.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

