+reflect building symbolizer in python

This commit is contained in:
Dane Springmeyer 2012-08-20 18:17:00 -07:00
parent 9273f861bc
commit b76c8e5c64
6 changed files with 71 additions and 18 deletions

View file

@ -43,6 +43,8 @@ TODO - fill these out more:
- geometry closed
- feature api better - context's provide schema support
- Python: exposed BuildingSymbolizer
- Support in the CSV plugin for reading JSON encoded geometries (#1392)
- Increased grid encoding performance (#1315)

View file

@ -0,0 +1,50 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 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 <boost/python.hpp>
#include <mapnik/building_symbolizer.hpp>
using namespace mapnik;
using mapnik::building_symbolizer;
using mapnik::color;
void export_building_symbolizer()
{
using namespace boost::python;
class_<building_symbolizer>("BuildingSymbolizer",
init<>("Default BuildingSymbolizer"))
.add_property("fill",make_function
(&building_symbolizer::get_fill,
return_value_policy<copy_const_reference>()),
&building_symbolizer::set_fill)
.add_property("fill_opacity",
&building_symbolizer::get_opacity,
&building_symbolizer::set_opacity)
.add_property("height",
make_function(&building_symbolizer::height,
return_value_policy<copy_const_reference>()),
&building_symbolizer::set_height,
"Set/get the building height")
;
}

View file

@ -57,6 +57,7 @@ void export_point_symbolizer();
void export_line_symbolizer();
void export_line_pattern_symbolizer();
void export_polygon_symbolizer();
void export_building_symbolizer();
void export_polygon_pattern_symbolizer();
void export_raster_symbolizer();
void export_text_placement();
@ -395,6 +396,7 @@ BOOST_PYTHON_MODULE(_mapnik)
export_line_symbolizer();
export_line_pattern_symbolizer();
export_polygon_symbolizer();
export_building_symbolizer();
export_polygon_pattern_symbolizer();
export_raster_symbolizer();
export_text_placement();

View file

@ -34,11 +34,11 @@ namespace mapnik
struct MAPNIK_DECL building_symbolizer : public symbolizer_base
{
building_symbolizer();
building_symbolizer(color const& fill, expression_ptr height);
building_symbolizer(color const& fill, expression_ptr const& height);
color const& get_fill() const;
void set_fill(color const& fill);
expression_ptr height() const;
void set_height(expression_ptr height);
expression_ptr const& height() const;
void set_height(expression_ptr const& height);
void set_opacity(double opacity);
double get_opacity() const;

View file

@ -32,7 +32,7 @@ building_symbolizer::building_symbolizer()
opacity_(1.0)
{}
building_symbolizer::building_symbolizer(color const& fill, expression_ptr height)
building_symbolizer::building_symbolizer(color const& fill, expression_ptr const& height)
: symbolizer_base(),
fill_(fill),
height_(height),
@ -47,12 +47,12 @@ void building_symbolizer::set_fill(color const& fill)
{
fill_ = fill;
}
expression_ptr building_symbolizer::height() const
expression_ptr const& building_symbolizer::height() const
{
return height_;
}
void building_symbolizer::set_height(expression_ptr height)
void building_symbolizer::set_height(expression_ptr const& height)
{
height_=height;
}

View file

@ -107,18 +107,12 @@ def test_shieldsymbolizer_modify():
check_transform("scale([sx], [sy]/2)")
# TODO check expected failures
def test_polygonsymbolizer_init():
p = mapnik.PolygonSymbolizer()
eq_(p.fill, mapnik.Color('gray'))
eq_(p.fill_opacity, 1)
def test_point_symbolizer_init():
p = mapnik.PointSymbolizer()
eq_(p.placement, mapnik.point_placement.CENTROID)
p = mapnik.PolygonSymbolizer(mapnik.Color('blue'))
p = mapnik.PointSymbolizer()
p.placement = mapnik.point_placement.INTERIOR
eq_(p.fill, mapnik.Color('blue'))
eq_(p.fill_opacity, 1)
eq_(p.placement, mapnik.point_placement.INTERIOR)
# PointSymbolizer initialization
@ -189,8 +183,7 @@ def test_markersymbolizer_init():
#def test_pointsymbolizer_missing_image():
# p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/broken.png"))
# PolygonSymbolizer initialization
def test_polygonsymbolizer_init():
def test_polygon_symbolizer_init():
p = mapnik.PolygonSymbolizer()
eq_(p.fill, mapnik.Color('gray'))
@ -201,7 +194,13 @@ def test_polygonsymbolizer_init():
eq_(p.fill, mapnik.Color('blue'))
eq_(p.fill_opacity, 1)
# Stroke initialization
def test_building_symbolizer_init():
p = mapnik.BuildingSymbolizer()
eq_(p.fill, mapnik.Color('gray'))
eq_(p.fill_opacity, 1)
eq_(p.height,None)
def test_stroke_init():
s = mapnik.Stroke()