Compare commits

...

39 commits

Author SHA1 Message Date
Dane Springmeyer
0ba337278f try 4.9 2016-09-26 22:12:49 -07:00
Dane Springmeyer
5226f39bd4 try libstdc++-4.8-dev 2016-09-26 21:27:48 -07:00
artemp
03f1e49818 GeoJSON feature/geometry grammars - split (a | b | ...) % lit(',') rule to avoid creating bogus temp synthesised attribute e.g boost::variant<a,b,..> which causes clang compiler >= 3.9 to segfault. (ref #3507)
NOTE: In general many Boost.Spirit gotchas can be fixed by simplifying rules (better control what gets synthesied under the bonet)
2016-09-22 12:24:53 +02:00
artemp
34e1096788 GeoJSON generator - implement using geometry<double> karma adapters 2016-09-20 11:01:38 +02:00
artemp
a34cb6c2a3 remove unused rule 2016-09-20 10:55:38 +02:00
artemp
9d05667723 add specialisations for coord_type = std::int64_t 2016-09-20 10:55:00 +02:00
artemp
ba573e558b remove redundant and bogus enum value 2016-09-19 16:55:25 +02:00
artemp
fc481b171d wkt generator - remove boost::phoenix headers 2016-09-19 16:54:54 +02:00
artemp
6e010cbbd0 mapnik::geometry - refactor karma adaper into separate header for re-use 2016-09-19 16:32:40 +02:00
artemp
d67410f82a fix typo 2016-09-19 15:56:15 +02:00
artemp
8ddbd18d20 adapt mapnik::geometry::geometry<double> to work with boost::spirit::karma + simplify and optimise WKT generator 2016-09-19 15:51:21 +02:00
artemp
7197a946fa variant - pin to 'types' branch (requires types typedef) 2016-09-19 15:49:18 +02:00
artemp
545b32eaf5 refactor path_expression_grammar 2016-09-15 15:41:31 +02:00
artemp
c03cb2d434 consistently return x3 grammars by const& 2016-09-15 15:40:38 +02:00
artemp
dfbe7fd893 wkt x3 - add missing file 2016-09-14 11:15:18 +02:00
artemp
e4e628ecd5 upgrade WKT grammar to boost::spirit::x3 2016-09-13 15:11:05 +02:00
artemp
46fe1d6f4a Merge branch 'master' into develop 2016-09-12 12:59:34 +02:00
artemp
7d3d088a79 Merge branch 'master' into develop 2016-09-06 10:00:26 +02:00
artemp
d06cfff0ad Merge branch 'master' into develop 2016-09-05 11:40:22 +02:00
artemp
f322d95f3e Merge branch 'master' into develop 2016-09-05 11:38:57 +02:00
artemp
a4c75fe2d7 Merge branch 'master' into develop 2016-08-31 17:43:50 +01:00
artemp
468aeb23e1 Merge branch 'master' into develop 2016-08-31 14:37:38 +01:00
artemp
611edd19ac Merge branch 'master' into develop 2016-08-30 10:45:50 +01:00
artemp
fc4581cdbe Merge branch 'master' into develop 2016-08-26 14:42:16 +01:00
artemp
792675225b cleanup 2016-08-26 10:35:35 +01:00
artemp
e03b607b27 remove unused include directives 2016-08-26 10:34:48 +01:00
artemp
75ec9d6063 merge spirit-x3 2016-08-26 10:09:22 +01:00
artemp
4b8dc524e9 Merge branch 'master' into tidy-headers 2016-08-26 09:17:48 +01:00
artemp
d5a8992ce6 Merge branch 'master' into tidy-headers 2016-08-24 11:14:33 +01:00
artemp
451bd3c370 Merge branch 'master' into tidy-headers 2016-08-11 10:18:46 +01:00
artemp
3ef675c3d4 Merge branch 'master' into tidy-headers 2016-08-10 17:21:17 +01:00
artemp
850915c151 Merge branch 'master' into tidy-headers [skip ci] 2016-08-08 12:40:09 +01:00
artemp
266fccf190 Merge branch 'master' into tidy-headers 2016-08-05 16:26:41 +01:00
artemp
dd2344b99c add geometry and value dirs 2016-08-03 13:49:58 +01:00
artemp
ce3cbdd83e Merge branch 'master' into tidy-headers 2016-08-03 12:36:03 +01:00
artemp
94c2e1d4b5 Merge branch 'master' into tidy-headers 2016-08-03 12:34:53 +01:00
artemp
7aa424bb5d geometry_to_path.hpp => geometry/to_path.hpp 2016-08-03 12:17:05 +01:00
artemp
d06af64d0d refactor value related objects into include/value dir 2016-08-02 15:34:59 +01:00
artemp
5104f5dfea refactor souce code files with the following rule: the physical filesytem path matches namespace structure
e.g `mapnik::geometry::centroid()` -> `$(MAPNIK_SOURCE)/include/mapnik/geometry/centroid.hpp`
2016-08-02 14:43:02 +01:00
242 changed files with 4170 additions and 3640 deletions

View file

@ -28,20 +28,20 @@ matrix:
env: JOBS=8 MASON_PUBLISH=true CXX="ccache clang++-3.8 -Qunused-arguments" CC="clang-3.8" TRIGGER=true
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test']
packages: [ 'libstdc++-5-dev', 'xutils-dev']
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-4.9-dev', 'xutils-dev' ]
- os: linux
sudo: false
compiler: ": clang-coverage"
env: JOBS=8 COVERAGE=true CXX="ccache clang++-3.8 -Qunused-arguments" CC="clang-3.8"
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test']
packages: ['libstdc++-5-dev', 'xutils-dev' ]
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-4.9-dev', 'xutils-dev' ]
- os: osx
compiler: ": clang-osx"
# https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode7.3 # upgrades clang from 6 -> 7
osx_image: xcode8 # upgrades clang from 6 -> 7
env: JOBS=4 MASON_PUBLISH=true CXX="ccache clang++ -Qunused-arguments"
before_install:
@ -76,13 +76,10 @@ install:
before_script:
- source bootstrap.sh
- |
if [[ $(uname -s) == 'Linux' ]]; then
mason install clang 3.8.0
export PATH=$(mason prefix clang 3.8.0)/bin:${PATH}
which clang++
export LLVM_COV="$(mason prefix clang 3.8.0)/bin/llvm-cov"
fi
- mason install clang++ 3.8.1
- export PATH=$(mason prefix clang++ 3.8.1)/bin:${PATH}
- which clang++
- export LLVM_COV="$(mason prefix clang++ 3.8.1)/bin/llvm-cov"
- ccache --version
- ccache -p || true
- ccache --show-stats || true

View file

@ -1,4 +1,3 @@
OS := $(shell uname -s)
PYTHON = python
@ -36,10 +35,10 @@ src/json/libmapnik-json.a:
src/renderer_common/render_thunk_extractor.os \
src/json/libmapnik-json.a \
src/wkt/libmapnik-wkt.a \
src/css_color_grammar.os \
src/expression_grammar.os \
src/transform_expression_grammar.os \
src/image_filter_grammar.os \
src/css_color_grammar_x3.os \
src/expression_grammar_x3.os \
src/transform_expression_grammar_x3.os \
src/image_filter_grammar_x3.os \
src/marker_helpers.os \
src/svg/svg_transform_parser.os \
src/agg/process_line_symbolizer.os \

1897
SConstruct

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/params.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/safe_cast.hpp>
#include "../test/cleanup.hpp"

View file

@ -24,7 +24,7 @@ run test_getline 30 10000000
#run test_polygon_clipping 10 1000
#run test_polygon_clipping_rendering 10 100
run test_proj_transform1 10 100
run test_expression_parse 10 1000
run test_expression_parse 10 10000
run test_face_ptr_creation 10 1000
run test_font_registration 10 100
run test_offset_converter 10 1000

View file

@ -1,8 +1,8 @@
#include "bench_framework.hpp"
#include <mapnik/unicode.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp>
#include <mapnik/expression_grammar.hpp>
class test : public benchmark::test_case
{

View file

@ -10,10 +10,10 @@
#include <mapnik/geometry.hpp>
#include <mapnik/vertex_adapters.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry_envelope.hpp>
#include <mapnik/geometry_correct.hpp>
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <mapnik/geometry/envelope.hpp>
#include <mapnik/geometry/correct.hpp>
#include <mapnik/geometry/is_empty.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/color.hpp>
// boost geometry

View file

@ -11,7 +11,7 @@ todo
- shrink icu data
'
MASON_VERSION="new-pkgs"
MASON_VERSION="llvm-3.9.0-newpkgs"
function setup_mason() {
if [[ ! -d ./.mason ]]; then
@ -47,42 +47,34 @@ function install() {
ICU_VERSION="55.1"
function install_mason_deps() {
FAIL=0
install ccache 3.3.0 &
install zlib system &
install jpeg_turbo 1.5.0 libjpeg &
install libpng 1.6.24 libpng &
install libtiff 4.0.6 libtiff &
install libpq 9.5.2 &
install sqlite 3.14.1 libsqlite3 &
install expat 2.2.0 libexpat &
install icu ${ICU_VERSION} &
install proj 4.9.2 libproj &
install pixman 0.34.0 libpixman-1 &
install cairo 1.14.6 libcairo &
install protobuf 2.6.1 &
install ccache 3.3.0
install zlib system
install jpeg_turbo 1.5.0 libjpeg
install libpng 1.6.24 libpng
install libtiff 4.0.6 libtiff
install libpq 9.5.2
install sqlite 3.14.1 libsqlite3
install expat 2.2.0 libexpat
install icu ${ICU_VERSION}
install proj 4.9.2 libproj
install pixman 0.34.0 libpixman-1
install cairo 1.14.6 libcairo
install protobuf 2.6.1
# technically protobuf is not a mapnik core dep, but installing
# here by default helps make mapnik-vector-tile builds easier
install webp 0.5.1 libwebp &
install gdal 2.1.1 libgdal &
install boost 1.61.0 &
install boost_libsystem 1.61.0 &
install boost_libfilesystem 1.61.0 &
install boost_libprogram_options 1.61.0 &
install boost_libregex_icu 1.61.0 &
install webp 0.5.1 libwebp
install gdal 2.1.1 libgdal
install boost 1.61.0
install boost_libsystem 1.61.0
install boost_libfilesystem 1.61.0
install boost_libprogram_options 1.61.0
install boost_libregex_icu 1.61.0
# technically boost thread and python are not a core dep, but installing
# here by default helps make python-mapnik builds easier
install boost_libthread 1.61.0 &
install boost_libpython 1.61.0 &
install freetype 2.6.5 libfreetype &
install harfbuzz 1.3.0 libharfbuzz &
for job in $(jobs -p)
do
wait $job || let "FAIL+=1"
done
if [[ "$FAIL" != "0" ]]; then
exit ${FAIL}
fi
install boost_libthread 1.61.0
install boost_libpython 1.61.0
install freetype 2.6.5 libfreetype
install harfbuzz 1.3.0 libharfbuzz
}
MASON_LINKED_ABS=$(pwd)/mason_packages/.link

View file

@ -43,12 +43,12 @@ namespace agg
{
}
void clip_box(double x1, double y1, double x2, double y2)
void clip_box(double _x1, double _y1, double _x2, double _y2)
{
m_clip_box.x1 = x1;
m_clip_box.y1 = y1;
m_clip_box.x2 = x2;
m_clip_box.y2 = y2;
m_clip_box.x1 = _x1;
m_clip_box.y1 = _y1;
m_clip_box.x2 = _x2;
m_clip_box.y2 = _y2;
m_clip_box.normalize();
}

View file

@ -41,12 +41,12 @@ namespace agg
{
}
void clip_box(double x1, double y1, double x2, double y2)
void clip_box(double _x1, double _y1, double _x2, double _y2)
{
m_clip_box.x1 = x1;
m_clip_box.y1 = y1;
m_clip_box.x2 = x2;
m_clip_box.y2 = y2;
m_clip_box.x1 = _x1;
m_clip_box.y1 = _y1;
m_clip_box.x2 = _x2;
m_clip_box.y2 = _y2;
m_clip_box.normalize();
}

View file

@ -38,7 +38,9 @@ subdirs = [
'text',
'text/placements',
'text/formatting',
'markers_placements'
'markers_placements',
'geometry',
'value'
]
if env['SVG_RENDERER']:

View file

@ -24,7 +24,7 @@
#define MAPNIK_ATTRIBUTE_HPP
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/util/geometry_to_ds_type.hpp>
// stl

View file

@ -51,11 +51,11 @@ template <typename T> class MAPNIK_DECL box2d
public:
using value_type = T;
using box2d_type = box2d<value_type>;
private:
T minx_;
T miny_;
T maxx_;
T maxy_;
private:
friend inline void swap(box2d_type & lhs, box2d_type & rhs)
{
using std::swap;

View file

@ -33,24 +33,35 @@
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/fusion/include/adapt_adt.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_adapt_adt_attributes.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/home/x3.hpp>
#pragma GCC diagnostic pop
// agg
#include "agg_trans_affine.h"
BOOST_FUSION_ADAPT_TPL_ADT(
BOOST_FUSION_ADAPT_TPL_STRUCT(
(T),
(mapnik::box2d)(T),
(T, T, obj.minx(), obj.set_minx(mapnik::safe_cast<T>(val)))
(T, T, obj.miny(), obj.set_miny(mapnik::safe_cast<T>(val)))
(T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast<T>(val)))
(T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast<T>(val))))
(T, minx_),
(T, miny_),
(T, maxx_),
(T, maxy_))
namespace mapnik
namespace mapnik { namespace detail { namespace {
template <typename T>
struct assign
{
template <typename Context>
void operator() (Context & ctx) const
{
_val(ctx) = safe_cast<T>(_attr(ctx));
}
};
} // anonymous
} // detail
template <typename T>
box2d<T>::box2d()
:minx_( std::numeric_limits<T>::max()),
@ -61,13 +72,13 @@ box2d<T>::box2d()
template <typename T>
box2d<T>::box2d(T minx,T miny,T maxx,T maxy)
{
init(minx,miny,maxx,maxy);
init(minx, miny, maxx, maxy);
}
template <typename T>
box2d<T>::box2d(coord<T,2> const& c0, coord<T,2> const& c1)
{
init(c0.x,c0.y,c1.x,c1.y);
init(c0.x, c0.y, c1.x, c1.y);
}
template <typename T>
@ -350,12 +361,15 @@ void box2d<T>::pad(T padding)
template <typename T>
bool box2d<T>::from_string(std::string const& str)
{
boost::spirit::qi::lit_type lit;
boost::spirit::qi::double_type double_;
boost::spirit::ascii::space_type space;
bool r = boost::spirit::qi::phrase_parse(str.begin(),
using boost::spirit::x3::lit;
boost::spirit::x3::double_type double_;
boost::spirit::x3::ascii::space_type space;
bool r = boost::spirit::x3::phrase_parse(str.begin(),
str.end(),
double_ >> -lit(',') >> double_ >> -lit(',') >> double_ >> -lit(',') >> double_,
double_[detail::assign<T>()] >> -lit(',') >>
double_[detail::assign<T>()] >> -lit(',') >>
double_[detail::assign<T>()] >> -lit(',') >>
double_[detail::assign<T>()],
space,
*this);
return r;

View file

@ -38,16 +38,15 @@
namespace mapnik {
class MAPNIK_DECL color
: boost::equality_comparable<color>
class MAPNIK_DECL color : boost::equality_comparable<color>
{
private:
public:
std::uint8_t red_;
std::uint8_t green_;
std::uint8_t blue_;
std::uint8_t alpha_;
bool premultiplied_;
public:
// default ctor
color()
: red_(0xff),

View file

@ -1,67 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
// mapnik
#include <mapnik/color.hpp>
#include <mapnik/util/hsl.hpp>
#include <mapnik/safe_cast.hpp>
// boost
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/qi.hpp>
#pragma GCC diagnostic pop
// stl
#include <string>
namespace mapnik
{
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
using ascii_space_type = boost::spirit::ascii::space_type;
template <typename Iterator>
struct css_color_grammar : qi::grammar<Iterator, color(), ascii_space_type>
{
// ctor
css_color_grammar();
// rules
qi::uint_parser< unsigned, 16, 2, 2 > hex2 ;
qi::uint_parser< unsigned, 16, 1, 1 > hex1 ;
qi::uint_parser< unsigned, 10, 1, 3 > dec3 ;
qi::rule<Iterator, color(), ascii_space_type> rgba_color;
qi::rule<Iterator, color(), ascii_space_type> rgba_percent_color;
qi::rule<Iterator, qi::locals<double,double,double>,color(), ascii_space_type> hsl_percent_color;
qi::rule<Iterator, color(), ascii_space_type> hex_color;
qi::rule<Iterator, color(), ascii_space_type> hex_color_small;
qi::rule<Iterator, color(), ascii_space_type> css_color;
};
}
#endif // MAPNIK_CSS_COLOR_GRAMMAR_HPP

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,12 +20,36 @@
*
*****************************************************************************/
// NOTE: we define this here in a cpp because def is needed twice:
// once by src/color_factory.cpp and once by include/mapnik/image_filter_grammar.hpp
// otherwise it would make sense to simply do `#include <mapnik/css_color_grammar_impl.hpp>`
// in a single file
#include <mapnik/color.hpp>
#include <mapnik/css_color_grammar_impl.hpp>
#include <string>
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
template struct mapnik::css_color_grammar<std::string::const_iterator>;
#include <mapnik/color.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#pragma GCC diagnostic pop
namespace mapnik
{
namespace x3 = boost::spirit::x3;
namespace css_color_grammar
{
struct css_color_class;
using css_color_grammar_type = x3::rule<css_color_class, mapnik::color>;
BOOST_SPIRIT_DECLARE(css_color_grammar_type);
}}
namespace mapnik
{
css_color_grammar::css_color_grammar_type const& color_grammar();
}
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,84 +20,49 @@
*
*****************************************************************************/
// NOTE: This is an implementation header file and is only meant to be included
// from implementation files. It therefore doesn't have an include guard.
// mapnik
#include <mapnik/css_color_grammar.hpp>
// boost
// REF: http://www.w3.org/TR/css3-color/
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
#include <mapnik/css_color_grammar_x3.hpp>
#include <mapnik/util/hsl.hpp>
#include <mapnik/safe_cast.hpp>
#pragma GCC diagnostic push
#include <boost/fusion/include/adapt_adt.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/adapted/struct.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#pragma GCC diagnostic pop
BOOST_FUSION_ADAPT_ADT(
BOOST_FUSION_ADAPT_STRUCT (
mapnik::color,
(unsigned, unsigned, obj.red(), obj.set_red(mapnik::safe_cast<uint8_t>(val)))
(unsigned, unsigned, obj.green(), obj.set_green(mapnik::safe_cast<uint8_t>(val)))
(unsigned, unsigned, obj.blue(), obj.set_blue(mapnik::safe_cast<uint8_t>(val)))
(unsigned, unsigned, obj.alpha(), obj.set_alpha(mapnik::safe_cast<uint8_t>(val)))
(std::uint8_t, red_)
(std::uint8_t, green_)
(std::uint8_t, blue_)
(std::uint8_t, alpha_)
)
namespace mapnik
namespace mapnik {
namespace x3 = boost::spirit::x3;
namespace css_color_grammar {
using x3::lit;
using x3::uint_parser;
using x3::hex;
using x3::symbols;
using x3::omit;
using x3::attr;
using x3::double_;
using x3::no_case;
using x3::no_skip;
struct named_colors_ : x3::symbols<color>
{
namespace phoenix = boost::phoenix;
struct percent_conv_impl
{
using result_type = unsigned;
unsigned operator() (double val) const
{
return safe_cast<uint8_t>(std::lround((255.0 * val)/100.0));
}
};
struct alpha_conv_impl
{
using result_type = unsigned;
unsigned operator() (double val) const
{
return safe_cast<uint8_t>(std::lround((255.0 * val)));
}
};
struct hsl_conv_impl
{
using result_type = void;
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 & c, T1 h, T2 s, T3 l) const
{
double m1,m2;
// normalize values
h /= 360.0;
s /= 100.0;
l /= 100.0;
if (l <= 0.5)
{
m2 = l * (s + 1.0);
}
else
{
m2 = l + s - l*s;
}
m1 = l * 2 - m2;
double r = hue_to_rgb(m1, m2, h + 1.0/3.0);
double g = hue_to_rgb(m1, m2, h);
double b = hue_to_rgb(m1, m2, h - 1.0/3.0);
c.set_red(safe_cast<uint8_t>(std::lround(255.0 * r)));
c.set_green(safe_cast<uint8_t>(std::lround(255.0 * g)));
c.set_blue(safe_cast<uint8_t>(std::lround(255.0 * b)));
}
};
struct named_colors : qi::symbols<char,color>
{
named_colors()
named_colors_()
{
add
("aliceblue", color(240, 248, 255))
@ -249,77 +214,241 @@ struct named_colors : qi::symbols<char,color>
("transparent", color(0, 0, 0, 0))
;
}
} named_colors;
x3::uint_parser<std::uint8_t, 16, 2, 2> hex2;
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
x3::uint_parser<std::uint8_t, 10, 1, 3> dec3;
// starting rule
css_color_grammar_type const css_color("css_color");
// rules
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
x3::rule<class hex1_color, color> const hex1_color("hex1_color");
x3::rule<class rgb_color, color> const rgb_color("rgb_color");
x3::rule<class rgba_color, color> const rgba_color("rgba_color");
x3::rule<class rgb_color_percent, color> const rgb_color_percent("rgb_color_percent");
x3::rule<class rgba_color_percent, color> const rgba_color_percent("rgba_color_percent");
struct clip_opacity
{
static double call(double val)
{
if (val > 1.0) return 1.0;
if (val < 0.0) return 0.0;
return val;
}
};
template <typename Iterator>
css_color_grammar<Iterator>::css_color_grammar()
: css_color_grammar::base_type(css_color)
struct percent_converter
{
qi::lit_type lit;
qi::_val_type _val;
qi::double_type double_;
qi::_1_type _1;
qi::_a_type _a;
qi::_b_type _b;
qi::_c_type _c;
qi::lexeme_type lexeme;
ascii::no_case_type no_case;
using phoenix::at_c;
// symbols
named_colors named;
// functions
phoenix::function<percent_conv_impl> percent_converter;
phoenix::function<alpha_conv_impl> alpha_converter;
phoenix::function<hsl_conv_impl> hsl_converter;
static std::uint8_t call(double val)
{
return safe_cast<std::uint8_t>(std::lround((255.0 * val)/100.0));
}
};
css_color %= rgba_color
| rgba_percent_color
| hsl_percent_color
| hex_color
| hex_color_small
| no_case[named];
auto dec_red = [](auto& ctx)
{
_val(ctx).red_ = _attr(ctx);
};
hex_color = lexeme[ lit('#')
>> hex2 [ at_c<0>(_val) = _1 ]
>> hex2 [ at_c<1>(_val) = _1 ]
>> hex2 [ at_c<2>(_val) = _1 ]
>>-hex2 [ at_c<3>(_val) = _1 ] ]
;
auto dec_green = [](auto& ctx)
{
_val(ctx).green_ = _attr(ctx);
};
hex_color_small = lexeme[ lit('#')
>> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ]
>>-hex1 [ at_c<3>(_val) = _1 | _1 << 4 ] ]
;
auto dec_blue = [](auto& ctx)
{
_val(ctx).blue_ = _attr(ctx);
};
rgba_color = lit("rgb") >> -lit('a')
>> lit('(')
>> dec3 [at_c<0>(_val) = _1] >> ','
>> dec3 [at_c<1>(_val) = _1] >> ','
>> dec3 [at_c<2>(_val) = _1]
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
auto opacity = [](auto& ctx)
{
_val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5);
};
rgba_percent_color = lit("rgb") >> -lit('a')
>> lit('(')
>> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%'
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
auto percent_red = [] (auto & ctx)
{
_val(ctx).red_ = percent_converter::call(_attr(ctx));
};
hsl_percent_color = lit("hsl") >> -lit('a')
>> lit('(')
>> double_ [ _a = _1] >> ',' // hue 0..360
>> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100%
>> double_ [ _c = _1] >> '%' // lightness 0..100%
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1
>> lit (')') [ hsl_converter(_val,_a,_b,_c)]
;
auto percent_green = [] (auto & ctx)
{
_val(ctx).green_ = percent_converter::call(_attr(ctx));
};
auto percent_blue = [] (auto & ctx)
{
_val(ctx).blue_ = percent_converter::call(_attr(ctx));
};
auto hex1_red = [](auto& ctx)
{
_val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4;
};
auto hex1_green = [](auto& ctx)
{
_val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4;
};
auto hex1_blue = [](auto& ctx)
{
_val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4;
};
auto hex1_opacity = [](auto& ctx)
{
_val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4;
};
auto hex2_red = [](auto& ctx)
{
_val(ctx).red_ = _attr(ctx);
};
auto hex2_green = [](auto& ctx)
{
_val(ctx).green_ = _attr(ctx);
};
auto hex2_blue = [](auto& ctx)
{
_val(ctx).blue_ = _attr(ctx);
};
auto hex2_opacity = [](auto& ctx)
{
_val(ctx).alpha_ = _attr(ctx);
};
auto hsl_to_rgba = [] (auto& ctx)
{
double h = std::get<0>(_attr(ctx));
double s = std::get<1>(_attr(ctx));
double l = std::get<2>(_attr(ctx));
double m1;
double m2;
// normalise values
h /= 360.0;
s /= 100.0;
l /= 100.0;
if (l <= 0.5)
{
m2 = l * (s + 1.0);
}
else
{
m2 = l + s - l*s;
}
m1 = l * 2 - m2;
double r = hue_to_rgb(m1, m2, h + 1.0/3.0);
double g = hue_to_rgb(m1, m2, h);
double b = hue_to_rgb(m1, m2, h - 1.0/3.0);
uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5);
_val(ctx) = color(safe_cast<uint8_t>(std::lround(255.0 * r)),
safe_cast<uint8_t>(std::lround(255.0 * g)),
safe_cast<uint8_t>(std::lround(255.0 * b)),
alpha);
};
auto const hex2_color_def = no_skip[lit('#')
>> hex2[hex2_red]
>> hex2[hex2_green]
>> hex2[hex2_blue]
>> (hex2[hex2_opacity] | attr(255)[hex2_opacity])];
auto const hex1_color_def = no_skip[lit('#')
>> hex1[hex1_red]
>> hex1[hex1_green]
>> hex1[hex1_blue]
>> (hex1[hex1_opacity] | attr(15)[hex1_opacity])];
auto const rgb_color_def = lit("rgb")
>> lit('(') >> dec3[dec_red]
>> lit(',') >> dec3[dec_green]
>> lit(',') >> dec3[dec_blue]
>> attr(255) >> lit(')');
auto const rgb_color_percent_def = lit("rgb")
>> lit('(') >> dec3[percent_red] >> lit('%')
>> lit(',') >> dec3[percent_green] >> lit('%')
>> lit(',') >> dec3[percent_blue] >> lit('%')
>> attr(255) >> lit(')');
auto const rgba_color_def = lit("rgba")
>> lit('(') >> dec3[dec_red]
>> lit(',') >> dec3[dec_green]
>> lit(',') >> dec3[dec_blue]
>> lit(',') >> double_[opacity] >> lit(')');
auto const rgba_color_percent_def = lit("rgba")
>> lit('(') >> dec3[percent_red] >> lit('%')
>> lit(',') >> dec3[percent_green] >> lit('%')
>> lit(',') >> dec3[percent_blue] >> lit('%')
>> lit(',') >> double_[opacity] >> lit(')');
auto const hsl_values = x3::rule<class hsl_values, std::tuple<std::uint8_t,std::uint8_t,std::uint8_t, double >> {} =
lit("hsl")
>> lit('(') >> dec3
>> lit(',') >> dec3 >> lit('%')
>> lit(',') >> dec3 >> lit('%')
>> attr(1.0) >> lit(')')
;
auto const hsla_values = x3::rule<class hsla_values, std::tuple<std::uint8_t,std::uint8_t,std::uint8_t, double >> {} =
lit("hsla")
>> lit('(') >> dec3
>> lit(',') >> dec3 >> lit('%')
>> lit(',') >> dec3 >> lit('%')
>> lit(',') >> double_ >> lit(')')
;
auto const hsl_color = x3::rule<class hsl_color, color> {} = hsl_values[hsl_to_rgba];
auto const hsla_color = x3::rule<class hsla_color, color> {} = hsla_values[hsl_to_rgba];
auto const css_color_def =
no_case[named_colors]
|
hex2_color
|
hex1_color
|
rgb_color
|
rgba_color
|
rgb_color_percent
|
rgba_color_percent
|
hsl_color
|
hsla_color
;
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
BOOST_SPIRIT_DEFINE(
css_color,
hex2_color,
hex1_color,
rgb_color,
rgba_color,
rgb_color_percent,
rgba_color_percent
);
#pragma GCC diagnostic pop
} // ns
css_color_grammar::css_color_grammar_type const& color_grammar()
{
return css_color_grammar::css_color;
}
}
} //ns mapnik
#endif //MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP

View file

@ -69,8 +69,8 @@ public:
Raster
};
datasource (parameters const& params)
: params_(params) {}
datasource (parameters const& _params)
: params_(_params) {}
/*!
* @brief Get the configuration parameters of the data source.

View file

@ -43,8 +43,8 @@ struct evaluate_expression
{
using value_type = T;
explicit evaluate_expression(Attributes const& attributes)
: attributes_(attributes) {}
explicit evaluate_expression(Attributes const& _attributes)
: attributes_(_attributes) {}
value_type operator() (attribute const&) const
{

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/attribute.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/function_call.hpp>
#include <mapnik/util/variant.hpp>

View file

@ -1,103 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP
#define MAPNIK_EXPRESSIONS_GRAMMAR_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/expression_node.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/qi.hpp>
#pragma GCC diagnostic pop
namespace mapnik
{
namespace qi = boost::spirit::qi;
namespace standard_wide = boost::spirit::standard_wide;
using standard_wide::space_type;
template <typename T>
struct integer_parser
{
using type = qi::int_parser<T,10,1,-1>;
};
struct unary_function_types : qi::symbols<char, unary_function_impl>
{
unary_function_types();
};
struct binary_function_types : qi::symbols<char, binary_function_impl>
{
binary_function_types();
};
#ifdef __GNUC__
template <typename Iterator>
struct MAPNIK_DECL expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
#else
template <typename Iterator>
struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
#endif
{
using rule_type = qi::rule<Iterator, expr_node(), space_type>;
explicit expression_grammar(std::string const& encoding = "utf-8");
qi::real_parser<double, qi::strict_real_policies<double> > strict_double;
typename integer_parser<mapnik::value_integer>::type int__;
mapnik::transcoder tr_;
rule_type expr;
rule_type equality_expr;
rule_type cond_expr;
rule_type relational_expr;
rule_type logical_expr;
rule_type additive_expr;
rule_type multiplicative_expr;
rule_type unary_expr;
rule_type not_expr;
rule_type primary_expr;
qi::rule<Iterator, unary_function_call() , space_type> unary_function_expr;
qi::rule<Iterator, binary_function_call() , space_type> binary_function_expr;
qi::rule<Iterator, std::string() > regex_match_expr;
qi::rule<Iterator, expr_node(expr_node), qi::locals<std::string,std::string>, space_type> regex_replace_expr;
qi::rule<Iterator, std::string() , space_type> attr;
qi::rule<Iterator, std::string() , space_type> global_attr;
qi::rule<Iterator, std::string(), qi::locals<char> > quoted_ustring;
qi::rule<Iterator, std::string()> unquoted_ustring;
qi::rule<Iterator, std::string(), space_type> ustring;
qi::symbols<char const, char const> unesc_char;
qi::rule<Iterator, char() > quote_char;
qi::symbols<char, expr_node> constant;
unary_function_types unary_func_type;
binary_function_types binary_func_type;
};
} // namespace
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_HPP

View file

@ -1,280 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// NOTE: This is an implementation header file and is only meant to be included
// from implementation files. It therefore doesn't have an include guard.
// mapnik
#include <mapnik/expression_node.hpp>
#include <mapnik/expression_grammar.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/function_call.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/fusion/adapted/struct.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#pragma GCC diagnostic pop
BOOST_FUSION_ADAPT_STRUCT(mapnik::unary_function_call,
(mapnik::unary_function_impl, fun)
(mapnik::unary_function_call::argument_type, arg))
BOOST_FUSION_ADAPT_STRUCT(mapnik::binary_function_call,
(mapnik::binary_function_impl, fun)
(mapnik::binary_function_call::argument_type, arg1)
(mapnik::binary_function_call::argument_type, arg2))
// fwd declare
namespace mapnik {
struct attribute;
struct geometry_type_attribute;
}
namespace mapnik
{
struct unicode_impl
{
using result_type = mapnik::value_unicode_string;
explicit unicode_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
mapnik::value_unicode_string operator()(std::string const& str) const
{
return tr_.transcode(str.c_str());
}
mapnik::transcoder const& tr_;
};
struct regex_match_impl
{
using result_type = expr_node;
explicit regex_match_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
template <typename T0,typename T1>
expr_node operator() (T0 & node, T1 const& pattern) const;
mapnik::transcoder const& tr_;
};
struct regex_replace_impl
{
using result_type = expr_node;
explicit regex_replace_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
template <typename T0,typename T1,typename T2>
expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const;
mapnik::transcoder const& tr_;
};
unary_function_types::unary_function_types()
{
add
("sin", sin_impl())
("cos", cos_impl())
("tan", tan_impl())
("atan", atan_impl())
("exp", exp_impl())
("log", log_impl())
("abs", abs_impl())
("length",length_impl())
;
}
binary_function_types::binary_function_types()
{
add
("min", binary_function_impl(min_impl))
("max", binary_function_impl(max_impl))
("pow", binary_function_impl(pow_impl))
;
}
template <typename T0,typename T1>
expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const
{
return regex_match_node(tr_,node,pattern);
}
template <typename T0,typename T1,typename T2>
expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const& format) const
{
return regex_replace_node(tr_,node,pattern,format);
}
template <typename Iterator>
expression_grammar<Iterator>::expression_grammar(std::string const& encoding)
: expression_grammar::base_type(expr),
tr_(encoding)
{
qi::_1_type _1;
qi::_a_type _a;
qi::_b_type _b;
qi::_r1_type _r1;
qi::no_skip_type no_skip;
qi::_val_type _val;
qi::lit_type lit;
qi::double_type double_;
qi::hex_type hex;
qi::omit_type omit;
qi::alpha_type alpha;
qi::alnum_type alnum;
standard_wide::char_type char_;
standard_wide::no_case_type no_case;
using boost::phoenix::construct;
using boost::phoenix::if_else;
boost::phoenix::function<unicode_impl> unicode = unicode_impl(tr_);
boost::phoenix::function<regex_match_impl> regex_match = regex_match_impl(tr_);
boost::phoenix::function<regex_replace_impl> regex_replace = regex_replace_impl(tr_);
constant.add
("null", mapnik::value_null())
("false", mapnik::value_bool(false))
("true", mapnik::value_bool(true))
("point", mapnik::value_integer(1))
("linestring", mapnik::value_integer(2))
("polygon", mapnik::value_integer(3))
("collection", mapnik::value_integer(4))
("pi", mapnik::value_double(3.1415926535897932384626433832795))
("deg_to_rad", mapnik::value_double(0.017453292519943295769236907684886))
("rad_to_deg", mapnik::value_double(57.295779513082320876798154814105))
;
expr = logical_expr [_val = _1]
//| ustring [_val = unicode(_1)]
;
logical_expr = not_expr [_val = _1]
>>
*( ( ( lit("and") | lit("&&")) >> not_expr [_val && _1] )
| (( lit("or") | lit("||")) >> not_expr [_val || _1])
)
;
not_expr =
cond_expr [_val = _1 ]
| ((lit("not") | lit('!')) >> cond_expr [ _val = !_1 ])
;
cond_expr = equality_expr [_val = _1] | additive_expr [_val = _1]
;
equality_expr =
relational_expr [_val = _1]
>> *( ( (lit("=") | lit("eq") | lit("is")) >> relational_expr [_val == _1])
| (( lit("!=") | lit("<>") | lit("neq") ) >> relational_expr [_val != _1])
)
;
regex_match_expr = lit(".match")
>> lit('(')
>> quoted_ustring [_val = _1]
>> lit(')')
;
regex_replace_expr =
lit(".replace")
>> lit('(')
>> quoted_ustring [_a = _1]
>> lit(',')
>> quoted_ustring [_b = _1]
>> lit(')') [_val = regex_replace(_r1,_a,_b)]
;
relational_expr = additive_expr[_val = _1]
>>
*( ( (lit("<=") | lit("le") ) >> additive_expr [ _val <= _1 ])
| ( (lit('<') | lit("lt") ) >> additive_expr [ _val < _1 ])
| ( (lit(">=") | lit("ge") ) >> additive_expr [ _val >= _1 ])
| ( (lit('>') | lit("gt") ) >> additive_expr [ _val > _1 ])
)
;
additive_expr = multiplicative_expr [_val = _1]
>> * ( '+' >> multiplicative_expr[_val += _1]
| '-' >> multiplicative_expr[_val -= _1]
)
;
multiplicative_expr = unary_expr [_val = _1]
>> *( '*' >> unary_expr [_val *= _1]
| '/' >> unary_expr [_val /= _1]
| '%' >> unary_expr [_val %= construct<mapnik::expr_node>(_1)] //needed by clang++ with -std=c++11
| regex_match_expr[_val = regex_match(_val, _1)]
| regex_replace_expr(_val) [_val = _1]
)
;
unary_function_expr = unary_func_type >> '(' > logical_expr > ')'
;
binary_function_expr = binary_func_type >> '(' > logical_expr > ','
> logical_expr > ')'
;
unary_expr = primary_expr [_val = _1]
| '+' >> primary_expr [_val = _1]
| '-' >> primary_expr [_val = -_1]
;
primary_expr = strict_double [_val = _1]
| int__[_val = _1]
| no_case[constant] [_val = _1]
| quoted_ustring [_val = unicode(_1)]
| attr [if_else(_1 == "mapnik::geometry_type",
_val = construct<mapnik::geometry_type_attribute>(),
_val = construct<mapnik::attribute>(_1))]
| global_attr [_val = construct<mapnik::global_attribute>( _1 )]
| unary_function_expr [_val = _1]
| binary_function_expr [_val = _1]
| '(' > logical_expr [_val = _1 ] > ')'
// TODO: this is a backward compatibility hack to allow unquoted strings
| unquoted_ustring [_val = unicode(_1)]
// ^ https://github.com/mapnik/mapnik/pull/3389
;
unesc_char.add("\\a", '\a')("\\b", '\b')("\\f", '\f')("\\n", '\n')
("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\')
("\\\'", '\'')("\\\"", '\"')
;
ustring %= no_skip[alpha >> *alnum];
quote_char %= char_('\'') | char_('"');
quoted_ustring %= omit[quote_char[_a = _1]]
>> *(unesc_char | "\\x" >> hex | (char_ - lit(_a)))
>> lit(_a);
unquoted_ustring %= no_skip[alpha >> *alnum] - lit("not");
attr %= '[' >> no_skip[+~char_(']')] >> ']';
global_attr %= '@' >> no_skip[alpha >> * (alnum | char_('-'))];
}
}

View file

@ -0,0 +1,51 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
#include <mapnik/expression_node.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#pragma GCC diagnostic pop
namespace mapnik { namespace grammar {
namespace x3 = boost::spirit::x3;
struct transcoder_tag;
struct expression_class; // top-most ID
using expression_grammar_type = x3::rule<expression_class, expr_node>;
BOOST_SPIRIT_DECLARE(expression_grammar_type);
}}
namespace mapnik
{
grammar::expression_grammar_type const& expression_grammar();
}
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP

View file

@ -0,0 +1,43 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP
#include <mapnik/expression_grammar_x3.hpp>
#include <mapnik/unicode.hpp>
#include <string>
namespace mapnik { namespace grammar {
namespace x3 = boost::spirit::x3;
using iterator_type = std::string::const_iterator;
using phrase_context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
// define combined context
using context_type = x3::with_context<transcoder_tag,
std::reference_wrapper<mapnik::transcoder const> const,
phrase_context_type>::type;
}}
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP

View file

@ -0,0 +1,433 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
#include <mapnik/expression_grammar_x3.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/function_call.hpp>
#include <mapnik/unicode.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/std_pair.hpp>
#pragma GCC diagnostic pop
BOOST_FUSION_ADAPT_STRUCT(mapnik::unary_function_call,
(mapnik::unary_function_impl, fun)
(mapnik::unary_function_call::argument_type, arg))
BOOST_FUSION_ADAPT_STRUCT(mapnik::binary_function_call,
(mapnik::binary_function_impl, fun)
(mapnik::binary_function_call::argument_type, arg1)
(mapnik::binary_function_call::argument_type, arg2))
namespace mapnik { namespace grammar {
namespace x3 = boost::spirit::x3;
namespace ascii = boost::spirit::x3::ascii;
using ascii::char_;
using ascii::string;
using x3::lit;
using x3::double_;
using x3::int_;
using x3::bool_;
using x3::_attr;
using x3::_val;
using x3::no_skip;
using x3::lexeme;
using x3::no_case;
using x3::alpha;
using x3::alnum;
using x3::hex;
struct transcoder_tag;
auto do_assign = [] (auto & ctx)
{
_val(ctx) = std::move(_attr(ctx));
};
auto do_negate = [] (auto & ctx)
{
_val(ctx) = std::move(unary_node<mapnik::tags::negate>(_attr(ctx)));
};
auto do_attribute = [] (auto & ctx)
{
_val(ctx) = std::move(attribute(_attr(ctx)));
};
auto do_global_attribute = [] (auto & ctx)
{
_val(ctx) = std::move(global_attribute(_attr(ctx)));
};
auto do_geometry_type_attribute = [] (auto & ctx)
{
_val(ctx) = std::move(geometry_type_attribute());
};
auto do_add = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::plus>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_subt = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::minus>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_mult = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mult>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_div = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::div>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_mod = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mod>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_unicode = [] (auto & ctx)
{
auto & tr = x3::get<transcoder_tag>(ctx).get();
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
};
auto do_null = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::value_null());
};
auto do_not = [] (auto & ctx)
{
mapnik::unary_node<mapnik::tags::logical_not> node(_attr(ctx));
_val(ctx) = std::move(node);
};
auto do_and = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_and>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_or = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_or>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_equal = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_not_equal = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::not_equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_less = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_less_equal = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_greater = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
auto do_greater_equal = [] (auto & ctx)
{
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
};
// regex
auto do_regex_match = [] (auto & ctx)
{
auto const& tr = x3::get<transcoder_tag>(ctx).get();
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)) , std::move(_attr(ctx))));
};
auto do_regex_replace = [] (auto & ctx)
{
auto const& tr = x3::get<transcoder_tag>(ctx).get();
auto const& pattern = std::get<0>(_attr(ctx));
auto const& format = std::get<1>(_attr(ctx));
_val(ctx) = mapnik::regex_replace_node(tr, _val(ctx) , pattern, format);
};
// mapnik::value_integer
auto const mapnik_int = x3::int_parser<value_integer,10,1,-1>();
// mapnik::value_double
auto const mapnik_double = x3::real_parser<value_double, x3::strict_real_policies<value_double>>();
// mapnik::value_bool
struct boolean_ : x3::symbols<mapnik::value_bool>
{
boolean_()
{
add
("true", true)
("false", false)
;
}
} boolean;
struct floating_point_constants : x3::symbols<mapnik::value_double>
{
floating_point_constants()
{
add
("pi", 3.1415926535897932384626433832795)
("deg_to_rad",0.017453292519943295769236907684886)
("rad_to_deg",57.295779513082320876798154814105)
;
}
} float_const;
// unary functions
struct unary_function_types_ : x3::symbols<unary_function_impl>
{
unary_function_types_()
{
add
("sin", sin_impl())
("cos", cos_impl())
("tan", tan_impl())
("atan", atan_impl())
("exp", exp_impl())
("log", log_impl())
("abs", abs_impl())
("length",length_impl())
;
}
} unary_func_types ;
// binary functions
struct binary_function_types_ : x3::symbols<binary_function_impl>
{
binary_function_types_()
{
add
("min", binary_function_impl(min_impl))
("max", binary_function_impl(max_impl))
("pow", binary_function_impl(pow_impl))
;
}
} binary_func_types;
// geometry types
struct geometry_types_ : x3::symbols<mapnik::value_integer>
{
geometry_types_()
{
add
("point", 1)
("linestring", 2)
("polygon",3)
("collection",4)
;
}
} geometry_type;
struct unesc_chars_ : x3::symbols<char>
{
unesc_chars_()
{
add
("\\a", '\a')
("\\b", '\b')
("\\f", '\f')
("\\n", '\n')
("\\r", '\r')
("\\t", '\t')
("\\v", '\v')
("\\\\", '\\')
("\\\'", '\'')
("\\\"", '\"')
;
}
} unesc_char;
// starting rule
expression_grammar_type const expression("expression");
// rules
x3::rule<class logical_expression, mapnik::expr_node> const logical_expression("logical expression");
x3::rule<class not_expression, mapnik::expr_node> const not_expression("not expression");
x3::rule<class conditional_expression, mapnik::expr_node> const conditional_expression("conditional expression");
x3::rule<class equality_expression, mapnik::expr_node> const equality_expression("equality expression");
x3::rule<class relational_expression, mapnik::expr_node> const relational_expression("relational expression");
x3::rule<class additive_expression, mapnik::expr_node> const additive_expression("additive expression");
x3::rule<class multiplicative_expression, mapnik::expr_node> const multiplicative_expression("multiplicative expression");
x3::rule<class unary_func_expression, mapnik::unary_function_call> const unary_func_expression("unary function expression");
x3::rule<class binary_func_expression, mapnik::binary_function_call> const binary_func_expression("binary function expression");
x3::rule<class unary_expression, mapnik::expr_node> const unary_expression("unary expression");
x3::rule<class primary_expression, mapnik::expr_node> const primary_expression("primary expression");
x3::rule<class regex_match_expression, std::string> const regex_match_expression("regex match expression");
x3::rule<class regex_replace_expression, std::pair<std::string,std::string> > const regex_replace_expression("regex replace expression");
// strings
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'') >> no_skip[*(unesc_char | ("\\x" > hex) | (char_ - '\''))] > '\'';
auto const double_quoted_string = x3::rule<class double_quoted_string, std::string> {} = lit('"') >> no_skip[*(unesc_char | ("\\x" > hex) | (char_ - '"'))] > '"';
auto const quoted_string = x3::rule<class quoted_string, std::string> {} = single_quoted_string | double_quoted_string;
auto const unquoted_ustring = x3::rule<class ustring, std::string> {} = no_skip[alpha > *alnum] - lit("not");
// start
auto const expression_def = logical_expression [do_assign]
;
auto const logical_expression_def = not_expression[do_assign] >
*(((lit("and") | lit("&&")) > not_expression[do_and])
|
((lit("or") | lit("||")) > not_expression[do_or]));
auto const not_expression_def = conditional_expression[do_assign]
|
(lit("not") | lit('!')) > conditional_expression[do_not]
;
auto const conditional_expression_def = equality_expression[do_assign]
|
additive_expression[do_assign]
;
auto const equality_expression_def = relational_expression[do_assign] >
*( ( ( lit("=") | lit("eq") | lit("is")) > relational_expression [do_equal])
| (( lit( "!=") | lit("<>") | lit("neq") ) > relational_expression [do_not_equal])
);
auto const relational_expression_def = additive_expression[do_assign] >
*( ( (lit("<=") | lit("le")) > additive_expression [do_less_equal])
|
( (lit("<") | lit("lt")) >> additive_expression[do_less]) // allow backtracking to be able to handle '<' and '<>' correctly
|
( (lit(">=") | lit("ge")) > additive_expression [do_greater_equal])
|
( (lit(">") | lit("gt")) > additive_expression [do_greater]));
auto const additive_expression_def = multiplicative_expression[do_assign]
> *( ('+' > multiplicative_expression[do_add])
|
('-' > multiplicative_expression[do_subt]));
auto const feature_attr = lexeme['[' > +~char_(']') > ']'];
auto const global_attr = x3::rule<class global_attr, std::string> {} = lexeme[lit('@') > alpha > *alnum];
auto const regex_match_expression_def = lit(".match") > '(' > quoted_string > ')';
auto const regex_replace_expression_def = lit(".replace") > '(' > quoted_string > ',' > quoted_string > ')';
auto const multiplicative_expression_def = unary_expression [do_assign]
> *( '*' > unary_expression [do_mult]
|
'/' > unary_expression [do_div]
|
'%' > unary_expression [do_mod]
|
regex_match_expression[do_regex_match]
|
regex_replace_expression[do_regex_replace]
);
auto const unary_func_expression_def = unary_func_types > '(' > expression > ')';
auto const binary_func_expression_def = binary_func_types > '(' > expression > ',' > expression > ')';
auto const unary_expression_def =
primary_expression[do_assign]
|
'+' > primary_expression[do_assign]
|
'-' > primary_expression[do_negate]
;
auto const primary_expression_def =
mapnik_double[do_assign]
|
mapnik_int[do_assign]
|
no_case[boolean][do_assign]
|
no_case["null"][do_null]
|
no_case[geometry_type][do_assign]
|
float_const[do_assign]
|
quoted_string[do_unicode]
|
lit("[mapnik::geometry_type]")[do_geometry_type_attribute]
|
feature_attr[do_attribute]
|
global_attr[do_global_attribute]
|
unary_func_expression[do_assign]
|
binary_func_expression[do_assign]
|
('(' > logical_expression[do_assign] > ')')
|
unquoted_ustring[do_unicode]
// ^ https://github.com/mapnik/mapnik/pull/3389
;
BOOST_SPIRIT_DEFINE (
expression,
logical_expression,
not_expression,
conditional_expression,
equality_expression,
relational_expression,
additive_expression,
regex_match_expression,
regex_replace_expression,
multiplicative_expression,
unary_func_expression,
binary_func_expression,
unary_expression,
primary_expression
);
}}
namespace mapnik
{
grammar::expression_grammar_type const& expression_grammar()
{
return grammar::expression;
}
}
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP

View file

@ -24,7 +24,7 @@
#define MAPNIK_EXPRESSION_NODE_HPP
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/config.hpp>
#include <mapnik/unicode.hpp>
@ -59,7 +59,10 @@ template <> struct make_op<mapnik::tags::logical_or> { using type = std::logica
template <typename Tag>
struct unary_node
{
unary_node (expr_node const& a)
unary_node (expr_node && a)
: expr(std::move(a)) {}
unary_node (expr_node const a)
: expr(a) {}
static const char* type()
@ -73,6 +76,10 @@ struct unary_node
template <typename Tag>
struct binary_node
{
binary_node(expr_node && a, expr_node && b)
: left(std::move(a)),
right(std::move(b)) {}
binary_node(expr_node const& a, expr_node const& b)
: left(a),
right(b) {}
@ -130,81 +137,6 @@ struct MAPNIK_DECL regex_replace_node
std::shared_ptr<_regex_replace_impl> impl_;
};
inline expr_node & operator- (expr_node& expr)
{
return expr = unary_node<mapnik::tags::negate>(expr);
}
inline expr_node & operator += ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::plus>(left,right);
}
inline expr_node & operator -= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::minus>(left,right);
}
inline expr_node & operator *= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::mult>(left,right);
}
inline expr_node & operator /= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::div>(left,right);
}
inline expr_node & operator %= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::mod>(left,right);
}
inline expr_node & operator < ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::less>(left,right);
}
inline expr_node & operator <= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::less_equal>(left,right);
}
inline expr_node & operator > ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::greater>(left,right);
}
inline expr_node & operator >= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::greater_equal>(left,right);
}
inline expr_node & operator == ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::equal_to>(left,right);
}
inline expr_node & operator != ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::not_equal_to>(left,right);
}
inline expr_node & operator ! (expr_node & expr)
{
return expr = unary_node<mapnik::tags::logical_not>(expr);
}
inline expr_node & operator && ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::logical_and>(left,right);
}
inline expr_node & operator || ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::logical_or>(left,right);
}
}

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/util/variant.hpp>
namespace mapnik

View file

@ -25,11 +25,11 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_envelope.hpp>
#include <mapnik/geometry/envelope.hpp>
//
#include <mapnik/feature_kv_iterator.hpp>
#include <mapnik/util/noncopyable.hpp>

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
// boost
//#include <boost/pool/pool_alloc.hpp>

View file

@ -367,10 +367,10 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
continue;
}
std::vector<rule> const& rules = style->get_rules();
std::vector<rule> const& style_rules = style->get_rules();
bool active_rules = false;
rule_cache rc;
for(rule const& r : rules)
for(rule const& r : style_rules)
{
if (r.active(scale_denom))
{

View file

@ -47,7 +47,6 @@ struct exp_impl
{
return std::exp(val.to_double());
}
};
// log
@ -58,7 +57,6 @@ struct log_impl
{
return std::log(val.to_double());
}
};
// sin
@ -102,7 +100,7 @@ struct abs_impl
{
value_type operator() (value_type const& val) const
{
return std::fabs(val.to_double());
return std::abs(val.to_double());
}
};

View file

@ -27,7 +27,7 @@
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
// stl
#include <cmath>
#include <vector>

View file

@ -0,0 +1,121 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
#define MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
#include <mapnik/geometry.hpp>
namespace boost { using mapbox::util::get; }
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/support/attributes.hpp>
namespace boost { namespace spirit { namespace traits
{
template <>
struct not_is_variant<mapnik::geometry::geometry<double>, karma::domain>
: mpl::false_
{};
template <>
struct not_is_variant<mapnik::geometry::geometry<std::int64_t>, karma::domain>
: mpl::false_
{};
template <>
struct variant_which< mapnik::geometry::geometry<double> >
{
static int call(mapnik::geometry::geometry<double> const& v)
{
return v.which();
}
};
template <>
struct variant_which< mapnik::geometry::geometry<std::int64_t> >
{
static int call(mapnik::geometry::geometry<std::int64_t> const& v)
{
return v.which();
}
};
namespace detail {
template <typename T, typename Tuple>
struct has_type;
template <typename T>
struct has_type<T, std::tuple<>> : std::false_type {};
template <typename T, typename U, typename... Types>
struct has_type<T, std::tuple<U, Types...>> : has_type<T, std::tuple<Types...>> {};
template <typename T, typename... Types>
struct has_type<T, std::tuple<T, Types...>> : std::true_type {};
template <typename T, typename Tuple>
struct index;
template <typename T, typename... Types>
struct index<T, std::tuple<T, Types...>>
{
static const std::size_t value = 0;
};
template <typename T, typename U, typename... Types>
struct index<T, std::tuple<U, Types...>>
{
static const std::size_t value = 1 + index<T, std::tuple<Types...>>::value;
};
}
template <typename Expected>
struct compute_compatible_component_variant<mapnik::geometry::geometry<double>, Expected>
: detail::has_type<Expected, mapnik::geometry::geometry<double>::types>
{
using compatible_type = Expected;
static bool is_compatible(int index)
{
return (index == detail::index<compatible_type, mapnik::geometry::geometry<double>::types>::value);
}
};
template <typename Expected>
struct compute_compatible_component_variant<mapnik::geometry::geometry<std::int64_t>, Expected>
: detail::has_type<Expected, mapnik::geometry::geometry<std::int64_t>::types>
{
using compatible_type = Expected;
static bool is_compatible(int index)
{
return (index == detail::index<compatible_type, mapnik::geometry::geometry<std::int64_t>::types>::value);
}
};
}}}
#endif //MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP

View file

@ -24,10 +24,10 @@
#define MAPNIK_GEOMETRY_CENTROID_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry_remove_empty.hpp>
#include <mapnik/geometry/is_empty.hpp>
#include <mapnik/geometry/remove_empty.hpp>
namespace mapnik { namespace geometry {

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_CORRECT_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <mapnik/util/variant.hpp>
#pragma GCC diagnostic push

View file

@ -20,7 +20,7 @@
*
*****************************************************************************/
#include <mapnik/geometry_envelope.hpp>
#include <mapnik/geometry/envelope.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/box2d.hpp>

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
namespace mapnik { namespace geometry { namespace detail {

View file

@ -29,7 +29,7 @@
#if BOOST_VERSION >= 105600
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <boost/geometry/algorithms/is_simple.hpp>
namespace mapnik { namespace geometry {

View file

@ -29,7 +29,7 @@
#if BOOST_VERSION >= 105800
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/validity_failure_type.hpp>
@ -102,7 +102,7 @@ struct geometry_is_valid
struct geometry_is_valid_reason
{
using result_type = bool;
boost::geometry::validity_failure_type & failure_;
geometry_is_valid_reason(boost::geometry::validity_failure_type & failure):
@ -170,7 +170,7 @@ struct geometry_is_valid_reason
struct geometry_is_valid_string
{
using result_type = bool;
std::string & message_;
geometry_is_valid_string(std::string & message):
@ -257,7 +257,7 @@ inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & fai
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
boost::geometry::validity_failure_type & failure)
{
return util::apply_visitor(detail::geometry_is_valid_reason(failure), geom);
@ -270,7 +270,7 @@ inline bool is_valid(T const& geom, std::string & message)
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
std::string & message)
{
return util::apply_visitor(detail::geometry_is_valid_string(message), geom);

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_REMOVE_EMPTY_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry/is_empty.hpp>
namespace mapnik { namespace geometry {

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// mapnik
#include <mapnik/geometry_reprojection.hpp>
#include <mapnik/geometry/reprojection.hpp>
#include <mapnik/geometry.hpp>
namespace mapnik {

View file

@ -23,20 +23,20 @@
#ifndef MAPNIK_GEOMETRY_STRATEGY_HPP
#define MAPNIK_GEOMETRY_STRATEGY_HPP
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <mapnik/util/rounding_cast.hpp>
namespace mapnik {
namespace mapnik {
namespace geometry {
namespace helper
{
template <std::size_t... Ts>
struct index {};
template <std::size_t N, std::size_t... Ts>
struct gen_seq : gen_seq<N - 1, N - 1, Ts...> {};
template <std::size_t... Ts>
struct gen_seq<0, Ts...> : index<Ts...> {};
}
@ -70,7 +70,7 @@ struct strategy_group
template <typename P1, typename P2, typename T, typename ...Args>
inline P2 execute(P1 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P1,P2>(strat.template execute<P1,P1>(p, status), status, args...);
}
@ -79,7 +79,7 @@ struct strategy_group
{
return strat.template execute<P1,P2>(p, status);
}
private:
std::tuple<Strategies const& ...> ops_;
@ -87,7 +87,7 @@ private:
// The difference between this strategy group and the previous is that the conversion from P1 to P2 happens
// in the first strategy rather then the last strategy.
// in the first strategy rather then the last strategy.
template <typename... Strategies>
struct strategy_group_first
{
@ -116,13 +116,13 @@ struct strategy_group_first
template <typename P1, typename P2, typename T, typename ...Args>
inline P2 execute_first(P1 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P2>(strat.template execute<P1,P2>(p, status), status, args...);
}
template <typename P2, typename T, typename ...Args>
inline P2 execute(P2 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P2>(strat.template execute<P2,P2>(p, status), status, args...);
}
@ -131,13 +131,13 @@ struct strategy_group_first
{
return strat.template execute<P2,P2>(p, status);
}
template <typename P2>
inline P2 execute(P2 const& p, bool & status) const
{
return p;
}
private:
std::tuple<Strategies const& ...> ops_;
@ -151,7 +151,7 @@ struct scale_strategy
template <typename P1, typename P2>
inline bool apply(P1 const & p1, P2 & p2) const
{
using p2_type = typename boost::geometry::coordinate_type<P2>::type;
double x = (boost::geometry::get<0>(p1) * scale_) + offset_;
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
@ -159,7 +159,7 @@ struct scale_strategy
boost::geometry::set<1>(p2, static_cast<p2_type>(y));
return true;
}
template <typename P1, typename P2>
inline P2 execute(P1 const& p1, bool & status) const
{
@ -181,7 +181,7 @@ struct scale_rounding_strategy
template <typename P1, typename P2>
inline bool apply(P1 const & p1, P2 & p2) const
{
using p2_type = typename boost::geometry::coordinate_type<P2>::type;
double x = (boost::geometry::get<0>(p1) * scale_) + offset_;
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
@ -189,7 +189,7 @@ struct scale_rounding_strategy
boost::geometry::set<1>(p2, static_cast<p2_type>(std::round(y)));
return true;
}
template <typename P1, typename P2>
inline P2 execute(P1 const& p1, bool & status) const
{

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_TRANSFORM_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <boost/geometry/algorithms/transform.hpp>
namespace mapnik { namespace geometry { namespace detail {

View file

@ -124,9 +124,9 @@ public:
return pixmap_.painted();
}
void painted(bool painted)
void painted(bool _painted)
{
pixmap_.painted(painted);
pixmap_.painted(_painted);
}
inline eAttributeCollectionPolicy attribute_collection_policy() const

View file

@ -52,7 +52,7 @@ public:
hit_grid_view(unsigned x, unsigned y,
unsigned width, unsigned height,
T const& data,
T const& _data,
std::string const& key,
std::string const& id_name,
std::set<std::string> const& names,
@ -63,7 +63,7 @@ public:
y_(y),
width_(width),
height_(height),
data_(data),
data_(_data),
key_(key),
id_name_(id_name),
names_(names),

View file

@ -25,7 +25,7 @@
//mapnik
#include <mapnik/text/symbolizer_helpers.hpp>
#include <mapnik/text/placements/base.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/pixel_position.hpp>
namespace mapnik {

View file

@ -681,7 +681,7 @@ void apply_filter(Src & src, scale_hsla const& transform)
}
template <typename Src, typename ColorBlindFilter>
void color_blind_filter(Src & src, ColorBlindFilter const& op)
void apply_color_blind_filter(Src & src, ColorBlindFilter const& op)
{
using namespace boost::gil;
rgba8_view_t src_view = rgba8_view(src);
@ -804,19 +804,19 @@ void color_blind_filter(Src & src, ColorBlindFilter const& op)
template <typename Src>
void apply_filter(Src & src, color_blind_protanope const& op)
{
color_blind_filter(src, op);
apply_color_blind_filter(src, op);
}
template <typename Src>
void apply_filter(Src & src, color_blind_deuteranope const& op)
{
color_blind_filter(src, op);
apply_color_blind_filter(src, op);
}
template <typename Src>
void apply_filter(Src & src, color_blind_tritanope const& op)
{
color_blind_filter(src, op);
apply_color_blind_filter(src, op);
}
template <typename Src>

View file

@ -1,87 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_IMAGE_FILTER_GRAMMAR_HPP
#define MAPNIK_IMAGE_FILTER_GRAMMAR_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/css_color_grammar.hpp>
#include <mapnik/color.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/qi.hpp>
#pragma GCC diagnostic pop
// stl
#include <cmath>
namespace mapnik {
namespace filter {
struct color_stop;
struct colorize_alpha;
}
namespace qi = boost::spirit::qi;
struct percent_offset_impl
{
using result_type = double;
double operator() (double val) const
{
double result = std::abs(val/100.0);
if (result > 1.0) result = 1.0;
return result;
}
};
template <typename Iterator, typename ContType>
struct image_filter_grammar :
qi::grammar<Iterator, ContType(), qi::ascii::space_type>
{
using alternative_type = qi::rule<Iterator, ContType(), qi::ascii::space_type>;
image_filter_grammar();
qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
qi::rule<Iterator, ContType(), qi::ascii::space_type,
qi::locals<alternative_type*>> filter;
qi::rule<Iterator, qi::ascii::space_type> no_args;
qi::symbols<char, alternative_type*> alternatives;
qi::uint_parser< unsigned, 10, 1, 3 > radius_;
css_color_grammar<Iterator> css_color_;
qi::rule<Iterator, filter::color_stop(), qi::ascii::space_type> color_stop_;
qi::rule<Iterator, double(), qi::ascii::space_type> color_stop_offset;
private:
alternative_type & add(std::string const& symbol);
static constexpr unsigned max_alternatives = 16;
unsigned num_alternatives = 0;
alternative_type alternative_storage[max_alternatives];
};
} // namespace mapnik
#endif // MAPNIK_IMAGE_FILTER_GRAMMAR_HPP

View file

@ -1,141 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/image_filter_types.hpp>
#include <mapnik/image_filter_grammar.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/phoenix.hpp>
#pragma GCC diagnostic pop
namespace { // internal
BOOST_PHOENIX_ADAPT_FUNCTION(
typename std::remove_reference<A1>::type, ovo, // = optional_value_or
boost::get_optional_value_or, 2)
} // namespace internal
namespace mapnik {
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
template <typename Iterator, typename ContType>
image_filter_grammar<Iterator,ContType>::image_filter_grammar()
: image_filter_grammar::base_type(start)
{
qi::lit_type lit;
qi::_val_type _val;
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_5_type _5;
qi::_6_type _6;
qi::_7_type _7;
qi::_8_type _8;
qi::_a_type _a;
qi::attr_type attr;
qi::double_type double_;
qi::hold_type hold;
qi::omit_type omit;
using phoenix::push_back;
using phoenix::construct;
// functions
phoenix::function<percent_offset_impl> percent_offset;
start = -(filter % *lit(','))
;
filter = omit[alternatives[_a = _1]] >> qi::lazy(*_a)
;
add("emboss") = no_args >> attr(construct<mapnik::filter::emboss>());
add("blur") = no_args >> attr(construct<mapnik::filter::blur>());
add("gray") = no_args >> attr(construct<mapnik::filter::gray>());
add("edge-detect") = no_args >> attr(construct<mapnik::filter::edge_detect>());
add("sobel") = no_args >> attr(construct<mapnik::filter::sobel>());
add("sharpen") = no_args >> attr(construct<mapnik::filter::sharpen>());
add("x-gradient") = no_args >> attr(construct<mapnik::filter::x_gradient>());
add("y-gradient") = no_args >> attr(construct<mapnik::filter::y_gradient>());
add("invert") = no_args >> attr(construct<mapnik::filter::invert>());
add("color-blind-protanope") = no_args >> attr(construct<mapnik::filter::color_blind_protanope>());
add("color-blind-deuteranope") = no_args >> attr(construct<mapnik::filter::color_blind_deuteranope>());
add("color-blind-tritanope") = no_args >> attr(construct<mapnik::filter::color_blind_tritanope>());
add("agg-stack-blur") =
(lit('(') >> radius_ >> -( lit(',') >> radius_ ) >> lit(')'))
[push_back(_val, construct<filter::agg_stack_blur>(_1, ovo(_2, _1)))]
|
no_args
[push_back(_val, construct<filter::agg_stack_blur>(1, 1))]
;
add("scale-hsla") =
(lit('(')
>> double_ >> lit(',') >> double_ >> lit(',')
>> double_ >> lit(',') >> double_ >> lit(',')
>> double_ >> lit(',') >> double_ >> lit(',')
>> double_ >> lit(',') >> double_ >> lit(')'))
[push_back(_val, construct<filter::scale_hsla>(_1,_2,_3,_4,_5,_6,_7,_8))]
;
add("colorize-alpha") = qi::as<filter::colorize_alpha>()
[lit('(') >> color_stop_ % lit(',') >> lit(')')]
[push_back(_val, _1)]
;
color_stop_ = (css_color_ >> -color_stop_offset)
[_val = construct<filter::color_stop>(_1, ovo(_2, 0.0))]
;
color_stop_offset = double_[_val = _1]
>> -lit('%')[_val = percent_offset(_val)]
;
add("color-to-alpha") =
hold[lit('(') >> css_color_ >> lit(')')]
[push_back(_val, construct<filter::color_to_alpha>(_1))]
;
no_args = -(lit('(') >> lit(')'));
}
template <typename Iterator, typename ContType>
auto image_filter_grammar<Iterator, ContType>::add(std::string const& symbol)
-> alternative_type &
{
if (num_alternatives >= max_alternatives)
{
throw std::length_error("too many alternatives in image_filter_grammar");
}
alternative_storage[num_alternatives].name(symbol);
alternatives.add(symbol, &alternative_storage[num_alternatives]);
return alternative_storage[num_alternatives++];
}
} // namespace mapnik

View file

@ -0,0 +1,56 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_IMAGE_FILTER_GRAMMAR_X3_HPP
#define MAPNIK_IMAGE_FILTER_GRAMMAR_X3_HPP
//#include <mapnik/image_filter.hpp>
#include <mapnik/image_filter_types.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#pragma GCC diagnostic pop
namespace mapnik
{
namespace x3 = boost::spirit::x3;
namespace image_filter
{
struct image_filter_class;
using image_filter_grammar_type = x3::rule<image_filter_class, std::vector<filter::filter_type> >;
BOOST_SPIRIT_DECLARE(image_filter_grammar_type);
}}
namespace mapnik {
image_filter::image_filter_grammar_type const& image_filter_grammar();
}
#endif // MAPNIK_IMAGE_FILTER_GRAMMAR_X3_HPP

View file

@ -0,0 +1,261 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_IMAGE_FILTER_GRAMMAR_X3_DEF_HPP
#define MAPNIK_IMAGE_FILTER_GRAMMAR_X3_DEF_HPP
#include <mapnik/image_filter_grammar_x3.hpp>
#include <mapnik/image_filter_types.hpp>
#include <mapnik/css_color_grammar_x3.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/home/x3.hpp>
#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/adapted/std_tuple.hpp> // spirit support
#pragma GCC diagnostic pop
BOOST_FUSION_ADAPT_STRUCT(
mapnik::filter::scale_hsla,
(double, h0)
(double, h1)
(double, s0)
(double, s1)
(double, l0)
(double, l1)
(double, a0)
(double, a1)
)
BOOST_FUSION_ADAPT_STRUCT(
mapnik::filter::color_stop,
(mapnik::color, color )
(double, offset)
)
BOOST_FUSION_ADAPT_STRUCT(
mapnik::filter::color_to_alpha,
(mapnik::color, color)
)
namespace mapnik {
namespace x3 = boost::spirit::x3;
namespace image_filter {
using x3::lit;
using x3::uint_parser;
using x3::hex;
using x3::symbols;
using x3::omit;
using x3::attr;
using x3::double_;
using x3::no_case;
using x3::no_skip;
using x3::char_;
auto push_back = [](auto& ctx)
{
_val(ctx).push_back(_attr(ctx));
};
auto set_rx_ry = [](auto & ctx)
{
_val(ctx).rx = _val(ctx).ry = _attr(ctx);
};
auto set_ry = [](auto & ctx)
{
_val(ctx).ry = _attr(ctx);
};
auto offset_value = [](auto & ctx)
{
_val(ctx) = _attr(ctx);
};
auto percent = [](auto & ctx)
{
double val = std::abs(_val(ctx)/100.0);
if (val > 1.0) val = 1.0;
_val(ctx) = val;
};
x3::uint_parser<unsigned, 10, 1, 3> radius;
// Import the expression rule
namespace { auto const& css_color = color_grammar(); }
// starting rule
image_filter_grammar_type const start("start");
// rules
x3::rule<class filter_class, filter::filter_type > const filter("filter");
x3::rule<class emboss_class, filter::emboss> const emboss_filter("emboss");
x3::rule<class blur_class, filter::blur> const blur_filter("blur");
x3::rule<class gray_class, filter::gray> const gray_filter("gray");
x3::rule<class edge_detect_class, filter::edge_detect> const edge_detect_filter("edge-detect");
x3::rule<class sobel_class, filter::sobel> const sobel_filter("sobel");
x3::rule<class sharpen_class, filter::sharpen> const sharpen_filter("sharpen");
x3::rule<class x_gradient_class, filter::x_gradient> const x_gradient_filter("x-gradient");
x3::rule<class y_gradient_class, filter::y_gradient> const y_gradient_filter("y-gradient");
x3::rule<class invert_class, filter::invert> const invert_filter("invert");
x3::rule<class color_blind_protanope_class, filter::color_blind_protanope> const color_blind_protanope_filter("color-blind-protanope");
x3::rule<class color_blind_deuteranope_class, filter::color_blind_deuteranope> const color_blind_deuteranope_filter("color-blind-deuteranope");
x3::rule<class color_blind_tritanope_class, filter::color_blind_tritanope> const color_blind_tritanope_filter("color-blind-tritanope");
x3::rule<class agg_blur_class, filter::agg_stack_blur> const agg_blur_filter("agg blur filter");
x3::rule<class scale_hsla_class, filter::scale_hsla> const scale_hsla_filter("scale-hsla");
x3::rule<class colorize_alpha_class, filter::colorize_alpha> const colorize_alpha_filter("colorize-alpha");
x3::rule<class color_stop_class, filter::color_stop> const color_stop("color-stop");
x3::rule<class offset_class, double> const offset("color-stop-offset");
x3::rule<class color_to_alpha_class, filter::color_to_alpha> const color_to_alpha_filter("color-to-alpha");
auto const no_args = -(lit('(') > lit(')'));
auto const start_def = -(filter[push_back] % *lit(','));
auto const filter_def = (emboss_filter
|
blur_filter
|
gray_filter
|
edge_detect_filter
|
sobel_filter
|
sharpen_filter
|
x_gradient_filter
|
y_gradient_filter
|
invert_filter
|
color_blind_protanope_filter
|
color_blind_deuteranope_filter
|
color_blind_tritanope_filter
|
agg_blur_filter
|
scale_hsla_filter
|
colorize_alpha_filter
|
color_to_alpha_filter
)
;
auto const emboss_filter_def = lit("emboss") > no_args;
auto const blur_filter_def = lit("blur") > no_args;
auto const gray_filter_def = lit("gray") > no_args;
auto const edge_detect_filter_def = lit("edge-detect") > no_args;
auto const sobel_filter_def = lit("sobel") > no_args;
auto const sharpen_filter_def = lit("sharpen") > no_args;
auto const x_gradient_filter_def = lit("x-gradient") > no_args;
auto const y_gradient_filter_def = lit("y-gradient") > no_args;
auto const invert_filter_def = lit("invert") > no_args;
auto const color_blind_protanope_filter_def = lit("color-blind-protanope") > no_args;
auto const color_blind_deuteranope_filter_def = lit("color-blind-deuteranope") > no_args;
auto const color_blind_tritanope_filter_def = lit("color-blind-tritanope") > no_args;
auto const agg_blur_filter_def = lit("agg-stack-blur")
> -(lit('(') > -(radius[set_rx_ry] > -(lit(',') > radius[set_ry])) > lit(')'));
auto const scale_hsla_filter_def = lit("scale-hsla") > lit('(')
> double_ > ','
> double_ > ','
> double_ > ','
> double_ > ','
> double_ > ','
> double_ > ','
> double_ > ','
> double_ > ')' ;
auto const offset_def = double_[offset_value] > -lit('%')[percent];
auto const color_stop_def = css_color > -offset;
auto const colorize_alpha_filter_def = lit("colorize-alpha")
> lit('(')
> color_stop > *(lit(',') > color_stop)
> lit(')') ;
auto const color_to_alpha_filter_def = lit("color-to-alpha") > lit('(')
> -css_color > lit(')');
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
BOOST_SPIRIT_DEFINE(
start,
filter,
emboss_filter,
blur_filter,
gray_filter,
edge_detect_filter,
sobel_filter,
sharpen_filter,
x_gradient_filter,
y_gradient_filter,
invert_filter,
agg_blur_filter,
color_blind_protanope_filter,
color_blind_deuteranope_filter,
color_blind_tritanope_filter,
scale_hsla_filter,
colorize_alpha_filter,
color_stop,
offset,
color_to_alpha_filter
);
#pragma GCC diagnostic pop
} // image_filter
image_filter::image_filter_grammar_type const& image_filter_grammar()
{
return image_filter::start;
}
} //ns mapnik
#endif //MAPNIK_IMAGE_FILTER_GRAMMAR_X3_DEF_HPP

View file

@ -56,32 +56,41 @@ struct y_gradient : image_filter_base {};
struct invert : image_filter_base {};
// http://vision.psychol.cam.ac.uk/jdmollon/papers/colourmaps.pdf
struct color_blind_protanope : image_filter_base
struct color_blind_filter : image_filter_base
{
const double x = 0.7465;
const double y = 0.2535;
const double m = 1.273463;
const double yint = -0.073894;
color_blind_filter(double x_, double y_, double m_, double yint_)
: x(x_), y(y_), m(m_), yint(yint_) {}
double x;
double y;
double m;
double yint;
};
struct color_blind_deuteranope : image_filter_base
struct color_blind_protanope : color_blind_filter
{
const double x = 1.4;
const double y = -0.4;
const double m = 0.968437;
const double yint = 0.003331;
color_blind_protanope()
: color_blind_filter(0.7465, 0.2535, 1.273463, -0.073894) {}
};
struct color_blind_tritanope : image_filter_base
struct color_blind_deuteranope : color_blind_filter
{
const double x = 0.1748;
const double y = 0.0;
const double m = 0.062921;
const double yint = 0.292119;
color_blind_deuteranope()
: color_blind_filter(1.4, -0.4, 0.968437, 0.003331) {}
};
struct color_blind_tritanope : color_blind_filter
{
color_blind_tritanope()
: color_blind_filter(0.1748, 0.0, 0.062921, 0.292119) {}
};
struct agg_stack_blur : image_filter_base
{
agg_stack_blur()
: rx(1), ry(1) {}
agg_stack_blur(unsigned r)
: rx(r), ry(r) {}
agg_stack_blur(unsigned rx_, unsigned ry_)
: rx(rx_),ry(ry_) {}
inline bool operator==(agg_stack_blur const& rhs) const
@ -94,6 +103,7 @@ struct agg_stack_blur : image_filter_base
struct color_to_alpha : image_filter_base
{
color_to_alpha() {}
color_to_alpha(mapnik::color const& c)
: color(c) {}
inline bool operator==(color_to_alpha const& rhs) const
@ -105,6 +115,7 @@ struct color_to_alpha : image_filter_base
struct scale_hsla : image_filter_base
{
scale_hsla() {}
scale_hsla(double _h0, double _h1,
double _s0, double _s1,
double _l0, double _l1,

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/json/extract_bounding_box_grammar.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
// boost
#include <boost/spirit/include/qi_omit.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

View file

@ -63,17 +63,6 @@ struct end_container<mapnik::feature_impl const>
}
};
template <>
struct transform_attribute<const boost::fusion::cons<mapnik::feature_impl const&, boost::fusion::nil>,
mapnik::geometry::geometry<double> const& , karma::domain>
{
using type = mapnik::geometry::geometry<double> const&;
static type pre(const boost::fusion::cons<mapnik::feature_impl const&, boost::fusion::nil>& f)
{
return boost::fusion::at<mpl::int_<0> >(f).get_geometry();
}
};
}}}
namespace mapnik { namespace json {
@ -91,6 +80,15 @@ struct get_id
}
};
struct extract_geometry
{
using result_type = mapnik::geometry::geometry<double> const&;
template <typename T>
result_type operator() (T const& f) const
{
return f.get_geometry();
}
};
template <typename OutputIterator, typename FeatureType>
struct feature_generator_grammar :
@ -101,6 +99,7 @@ struct feature_generator_grammar :
geometry_generator_grammar<OutputIterator, mapnik::geometry::geometry<double> > geometry;
properties_generator_grammar<OutputIterator, FeatureType> properties;
boost::phoenix::function<get_id<FeatureType> > id_;
boost::phoenix::function<extract_geometry> geom_;
};
}}

View file

@ -40,7 +40,7 @@ feature_generator_grammar<OutputIterator, FeatureType>::feature_generator_gramma
feature = lit("{\"type\":\"Feature\",\"id\":")
<< uint_[_1 = id_(_val)]
<< lit(",\"geometry\":") << geometry
<< lit(",\"geometry\":") << geometry[_1 = geom_(_val)]
<< lit(",\"properties\":") << properties
<< lit('}')
;

View file

@ -72,7 +72,8 @@ struct feature_grammar : qi::grammar<Iterator, void(FeatureType&), space_type>
generic_json<Iterator> json_;
// geoJSON
qi::rule<Iterator, void(FeatureType&),space_type> start;
qi::rule<Iterator, qi::locals<bool>, void(FeatureType&),space_type> feature;
qi::rule<Iterator, qi::locals<bool>, void(FeatureType&), space_type> feature;
qi::rule<Iterator, void(FeatureType&, bool&), space_type> feature_part;
qi::rule<Iterator, space_type> feature_type;
qi::rule<Iterator,void(FeatureType &),space_type> properties;
qi::rule<Iterator,qi::locals<std::string>, void(FeatureType &),space_type> attributes;

View file

@ -41,6 +41,7 @@ feature_grammar<Iterator,FeatureType,ErrorHandler>::feature_grammar(mapnik::tran
qi::_4_type _4;
qi::_a_type _a;
qi::_r1_type _r1;
qi::_r2_type _r2;
qi::eps_type eps;
qi::char_type char_;
using qi::fail;
@ -55,16 +56,19 @@ feature_grammar<Iterator,FeatureType,ErrorHandler>::feature_grammar(mapnik::tran
start = feature(_r1);
feature = eps[_a = false] > lit('{') >
(feature_type[_a = true]
|
(lit("\"geometry\"") > lit(':') > geometry_grammar_[set_geometry(_r1, _1)])
|
properties(_r1)
|
json_.key_value) % lit(',')
feature_part(_r1, _a) % lit(',')
> eps(_a) > lit('}')
;
feature_part = feature_type[_r2 = true]
|
(lit("\"geometry\"") > lit(':') > geometry_grammar_[set_geometry(_r1, _1)])
|
properties(_r1)
|
json_.key_value
;
properties = lit("\"properties\"")
> lit(':') > ((lit('{') > -attributes(_r1) > lit('}')) | lit("null"))
;

View file

@ -23,7 +23,7 @@
#ifndef MAPNIK_GENERIC_JSON_HPP
#define MAPNIK_GENERIC_JSON_HPP
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/json/value_converters.hpp>

View file

@ -26,13 +26,10 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_type.hpp>
// boost
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunc
#include <boost/spirit/home/karma/domain.hpp>
#pragma GCC diagnostic pop
@ -43,18 +40,6 @@ namespace karma = boost::spirit::karma;
namespace detail {
template <typename Geometry>
struct get_type
{
using result_type = mapnik::geometry::geometry_types;
template <typename T>
result_type operator() (T const& geom) const
{
auto type = mapnik::geometry::geometry_type(geom);
return type;
}
};
template <typename T>
struct json_coordinate_policy : karma::real_policies<T>
{
@ -88,29 +73,29 @@ struct json_coordinate_policy : karma::real_policies<T>
template <typename OutputIterator, typename Geometry>
struct geometry_generator_grammar :
karma::grammar<OutputIterator, Geometry const&()>
karma::grammar<OutputIterator, Geometry()>
{
using coord_type = typename Geometry::coord_type;
geometry_generator_grammar();
karma::rule<OutputIterator, Geometry const&()> geometry;
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
karma::rule<OutputIterator, geometry::geometry<double> const&()> point;
karma::rule<OutputIterator, geometry::point<double> const&()> point_coord;
karma::rule<OutputIterator, geometry::geometry<double> const&()> linestring;
karma::rule<OutputIterator, geometry::line_string<double> const&()> linestring_coord;
karma::rule<OutputIterator, geometry::geometry<double> const&()> polygon;
karma::rule<OutputIterator, geometry::polygon<double> const&()> polygon_coord;
karma::rule<OutputIterator, geometry::linear_ring<double> const&()> exterior_ring_coord;
karma::rule<OutputIterator, geometry::polygon<double>::rings_container const&()> interior_ring_coord;
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_point;
karma::rule<OutputIterator, geometry::multi_point<double> const& ()> multi_point_coord;
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_linestring;
karma::rule<OutputIterator, geometry::multi_line_string<double> const& ()> multi_linestring_coord;
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_polygon;
karma::rule<OutputIterator, geometry::multi_polygon<double> const& ()> multi_polygon_coord;
karma::rule<OutputIterator, geometry::geometry<double> const& ()> geometry_collection;
karma::rule<OutputIterator, geometry::geometry_collection<double> const& ()> geometries;
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
karma::real_generator<double, detail::json_coordinate_policy<double> > coordinate;
karma::rule<OutputIterator, Geometry()> geometry;
karma::rule<OutputIterator, geometry::point<coord_type>()> point;
karma::rule<OutputIterator, geometry::point<coord_type>()> point_coord;
karma::rule<OutputIterator, geometry::line_string<coord_type>()> linestring;
karma::rule<OutputIterator, geometry::line_string<coord_type>()> linestring_coord;
karma::rule<OutputIterator, geometry::polygon<coord_type>()> polygon;
karma::rule<OutputIterator, geometry::polygon<coord_type>()> polygon_coord;
karma::rule<OutputIterator, geometry::linear_ring<coord_type>()> exterior_ring_coord;
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> >()> interior_ring_coord;
karma::rule<OutputIterator, geometry::multi_point<coord_type>()> multi_point;
karma::rule<OutputIterator, geometry::multi_point<coord_type>()> multi_point_coord;
karma::rule<OutputIterator, geometry::multi_line_string<coord_type>()> multi_linestring;
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> ()> multi_linestring_coord;
karma::rule<OutputIterator, geometry::multi_polygon<coord_type>()> multi_polygon;
karma::rule<OutputIterator, geometry::multi_polygon<coord_type>()> multi_polygon_coord;
karma::rule<OutputIterator, geometry::geometry_collection<coord_type>()> geometry_collection;
karma::rule<OutputIterator, geometry::geometry_collection<coord_type>()> geometries;
//
karma::real_generator<coord_type, detail::json_coordinate_policy<coord_type> > coordinate;
};

View file

@ -22,60 +22,33 @@
// mapnik
#include <mapnik/json/geometry_generator_grammar.hpp>
#include <mapnik/util/spirit_transform_attribute.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
// boost
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/fusion/include/at.hpp>
#pragma GCC diagnostic pop
namespace mapnik { namespace json {
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
template <typename OutputIterator, typename Geometry>
geometry_generator_grammar<OutputIterator, Geometry>::geometry_generator_grammar()
: geometry_generator_grammar::base_type(geometry)
{
boost::spirit::karma::_val_type _val;
boost::spirit::karma::_1_type _1;
boost::spirit::karma::_a_type _a;
boost::spirit::karma::lit_type lit;
boost::spirit::karma::uint_type uint_;
boost::spirit::karma::eps_type eps;
geometry = geometry_dispatch.alias()
;
geometry_dispatch = eps[_a = geometry_type(_val)] <<
(&uint_(geometry::geometry_types::Point)[_1 = _a]
<< (point | lit("null")))
geometry =
point
|
(&uint_(geometry::geometry_types::LineString)[_1 = _a]
<< (linestring | lit("null")))
linestring
|
(&uint_(geometry::geometry_types::Polygon)[_1 = _a]
<< (polygon | lit("null")))
polygon
|
(&uint_(geometry::geometry_types::MultiPoint)[_1 = _a]
<< (multi_point | lit("null")))
multi_point
|
(&uint_(geometry::geometry_types::MultiLineString)[_1 = _a]
<< (multi_linestring | lit("null")))
multi_linestring
|
(&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a]
<< (multi_polygon | lit("null")))
multi_polygon
|
(&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a]
<< (geometry_collection | lit("null")))
geometry_collection
|
lit("null")
;

View file

@ -36,6 +36,8 @@
#include <boost/spirit/include/phoenix_function.hpp>
#pragma GCC diagnostic pop
#include <memory>
namespace mapnik { namespace json {
namespace qi = boost::spirit::qi;
@ -47,6 +49,7 @@ struct geometry_grammar :
geometry_grammar();
qi::rule<Iterator, mapnik::geometry::geometry<double>(), space_type> start;
qi::rule<Iterator, qi::locals<int, mapnik::json::coordinates>, mapnik::geometry::geometry<double>(), space_type> geometry;
qi::rule<Iterator, void(int&, mapnik::json::coordinates&, mapnik::geometry::geometry<double>&), space_type> geometry_part;
qi::rule<Iterator, mapnik::geometry::geometry_collection<double>(), space_type> geometry_collection;
qi::symbols<char, int> geometry_type_dispatch;
positions_grammar<Iterator> coordinates;

View file

@ -24,7 +24,7 @@
#include <mapnik/config.hpp>
#include <mapnik/json/error_handler.hpp>
#include <mapnik/json/geometry_grammar.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
// boost
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
@ -46,21 +46,27 @@ geometry_grammar<Iterator, ErrorHandler>::geometry_grammar()
qi::_4_type _4;
qi::_a_type _a;
qi::_b_type _b;
qi::_r1_type _r1;
qi::_r2_type _r2;
qi::_r3_type _r3;
qi::eps_type eps;
using qi::fail;
using qi::on_error;
using phoenix::push_back;
start = geometry.alias() | lit("null");
geometry = lit('{')[_a = 0]
> (((lit("\"type\"") > lit(':') > geometry_type_dispatch[_a = _1])
|
(lit("\"coordinates\"") > lit(':') > coordinates[_b = _1])
|
(lit("\"geometries\"") > lit(':') > lit('[') > geometry_collection[_val = _1] > lit(']'))
|
json_.key_value) % lit(',')) [create_geometry(_val,_a,_b)]
> lit('}')
> (geometry_part(_a, _b, _val) % lit(','))[create_geometry(_val, _a, _b)]
> lit('}');
geometry_part = ((lit("\"type\"") > lit(':') > geometry_type_dispatch[_r1 = _1])
|
(lit("\"coordinates\"") > lit(':') > coordinates[_r2 = _1])
|
(lit("\"geometries\"") > lit(':') > lit('[') > geometry_collection[_r3 = _1] > lit(']'))
|
json_.key_value)
;
geometry_collection = geometry[push_back(_val, _1)] % lit(',')

View file

@ -24,7 +24,7 @@
#define MAPNIK_JSON_GEOMETRY_UTIL_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_correct.hpp>
#include <mapnik/geometry/correct.hpp>
#include <mapnik/json/positions.hpp>
namespace mapnik { namespace json {

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/json/positions_grammar.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
// boost
#include <boost/spirit/include/qi_omit.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

View file

@ -23,7 +23,7 @@
#ifndef MAPNIK_JSON_PROPERTIES_GENERATOR_GRAMMAR_HPP
#define MAPNIK_JSON_PROPERTIES_GENERATOR_GRAMMAR_HPP
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/value.hpp>
#pragma GCC diagnostic push

View file

@ -23,6 +23,14 @@
#include <mapnik/json/properties_generator_grammar.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#pragma GCC diagnostic pop
namespace mapnik { namespace json {
namespace karma = boost::spirit::karma;

View file

@ -29,8 +29,8 @@
#include <mapnik/json/topology.hpp>
#include <mapnik/json/attribute_value_visitor.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry_correct.hpp>
#include <mapnik/geometry/boost_adapters.hpp>
#include <mapnik/geometry/correct.hpp>
namespace mapnik { namespace topojson {

View file

@ -26,7 +26,7 @@
// mapnik
#include <mapnik/quad_tree.hpp>
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>

View file

@ -23,11 +23,11 @@
#ifndef MAPNIK_MAKE_UNIQUE_HPP
#define MAPNIK_MAKE_UNIQUE_HPP
#include <memory>
// http://stackoverflow.com/questions/14131454/visual-studio-2012-cplusplus-and-c-11
#if defined(_MSC_VER) && _MSC_VER < 1800 || !defined(_MSC_VER) && __cplusplus <= 201103L
#include <memory>
namespace std {
// C++14 backfill from http://herbsutter.com/gotw/_102/

View file

@ -25,8 +25,8 @@
#include <mapnik/feature.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_type.hpp>
#include <mapnik/geometry_centroid.hpp>
#include <mapnik/geometry/geometry_type.hpp>
#include <mapnik/geometry/centroid.hpp>
#include <mapnik/symbolizer.hpp>
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/marker.hpp> // for svg_storage_type

View file

@ -25,7 +25,7 @@
#include <mapnik/markers_placements/point.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
namespace mapnik {

View file

@ -27,7 +27,7 @@
#include <mapnik/view_transform.hpp>
#include <mapnik/vertex_cache.hpp>
#include <mapnik/tolerance_iterator.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
namespace mapnik {

View file

@ -24,7 +24,7 @@
#define MAPNIK_MARKERS_PLACEMENTS_POINT_HPP
#include <mapnik/geom_util.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
#include <mapnik/markers_placements/basic.hpp>
namespace mapnik {

View file

@ -26,7 +26,7 @@
// mapnik
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_envelope.hpp>
#include <mapnik/geometry/envelope.hpp>
#include <mapnik/featureset.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/memory_datasource.hpp>

View file

@ -269,7 +269,7 @@ private:
if (position < -1e-6) return -1;
return 0;
}
void displace2(vertex2d & v1, vertex2d const& v0, vertex2d const& v2, double a, double b) const
{
double sa = offset_ * std::sin(a);
@ -284,14 +284,14 @@ private:
double abs_hcasa = std::abs(hcasa);
double abs_hsa = std::abs(hsa);
double abs_hca = std::abs(hca);
vertex2d v_tmp(vertex2d::no_init);
vertex2d v_tmp(vertex2d::no_init);
v_tmp.x = v1.x - sa - hca;
v_tmp.y = v1.y + ca - hsa;
v_tmp.cmd = v1.cmd;
int same = point_line_position(v0, v2, v_tmp)*point_line_position(v0, v2, v1);
if (same >= 0 && std::abs(h) < 10)
{
v1.x = v_tmp.x;
@ -314,14 +314,14 @@ private:
v1.y = v1.y + ca - hsa;
}
else
{
{
if (abs_hsaca*abs_hsaca + abs_hcasa*abs_hcasa > abs_offset*abs_offset)
{
double d = (abs_hsaca*abs_hsaca + abs_hcasa*abs_hcasa);
d = d < 1e-6 ? 1. : d;
double scale = (abs_offset*abs_offset)/d;
v1.x = v1.x + hcasa*scale;
v1.y = v1.y + hsaca*scale;
v1.y = v1.y + hsaca*scale;
}
else
{
@ -330,8 +330,7 @@ private:
}
}
}
status init_vertices()
{
if (status_ != initial) // already initialized
@ -482,8 +481,9 @@ private:
}
start_v2.x = v2.x;
start_v2.y = v2.y;
vertex2d tmp_prev(vertex2d::no_init);
while (i < points.size())
{
v1 = v2;
@ -576,7 +576,7 @@ private:
tmp_prev.cmd = v1.cmd;
tmp_prev.x = v1.x;
tmp_prev.y = v1.y;
if (v1.cmd == SEG_MOVETO)
{
if (bulge_steps == 0)

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/util/variant.hpp>
#pragma GCC diagnostic push

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/params.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/util/conversions.hpp>

View file

@ -70,9 +70,9 @@ public:
return static_cast<bool>(type_ >> geometry_bits);
}
void set_type(types type)
void set_type(types _type)
{
type_ = type;
type_ = _type;
}
container_type const& data() const

View file

@ -1,62 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/path_expression_grammar.hpp>
#include <mapnik/attribute.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#pragma GCC diagnostic pop
namespace mapnik
{
template <typename Iterator>
path_expression_grammar<Iterator>::path_expression_grammar()
: path_expression_grammar::base_type(expr)
{
standard_wide::char_type char_;
qi::_1_type _1;
qi::_val_type _val;
qi::lit_type lit;
qi::lexeme_type lexeme;
using phoenix::push_back;
using boost::phoenix::construct;
expr =
* (
str [ push_back(_val, _1)]
|
( '[' >> attr [ push_back(_val, construct<mapnik::attribute>( _1 )) ] >> ']')
)
;
attr %= +(char_ - ']');
str %= lexeme[+(char_ -'[')];
}
}

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,40 +20,29 @@
*
*****************************************************************************/
#ifndef MAPNIK_PATH_EXPRESSIONS_GRAMMAR_HPP
#define MAPNIK_PATH_EXPRESSIONS_GRAMMAR_HPP
#ifndef MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_HPP
#define MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_HPP
// mapnik
#include <mapnik/path_expression.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/home/x3.hpp>
#pragma GCC diagnostic pop
// stl
#include <string>
#include <vector>
namespace mapnik { namespace grammar {
namespace mapnik
{
namespace x3 = boost::spirit::x3;
struct path_expression_class; // top-most ID
using path_expression_grammar_type = x3::rule<path_expression_class, path_expression>;
using namespace boost;
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
namespace standard_wide = boost::spirit::standard_wide;
using standard_wide::space_type;
template <typename Iterator>
struct path_expression_grammar : qi::grammar<Iterator, std::vector<path_component>(), space_type>
{
path_expression_grammar();
qi::rule<Iterator, std::vector<path_component>() , space_type> expr;
qi::rule<Iterator, std::string() , space_type> attr;
qi::rule<Iterator, std::string() > str;
};
BOOST_SPIRIT_DECLARE(path_expression_grammar_type);
}
#endif // MAPNIK_PATH_EXPRESSIONS_GRAMMAR_HPP
grammar::path_expression_grammar_type const& path_expression_grammar();
}
#endif // MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_HPP

View file

@ -0,0 +1,63 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
#define MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
// mapnik
#include <mapnik/path_expression_grammar_x3.hpp>
#include <mapnik/attribute.hpp>
namespace mapnik { namespace grammar {
namespace x3 = boost::spirit::x3;
using x3::standard_wide::char_;
using x3::lexeme;
auto create_string = [](auto & ctx) { _val(ctx).push_back(_attr(ctx)); };
auto create_attribute = [](auto & ctx) { _val(ctx).push_back(mapnik::attribute(_attr(ctx))); };
// top-most rule
path_expression_grammar_type const path_expression("path_expression");
// rules
x3::rule<class attr_expression, std::string> const attr_expression("attribute");
x3::rule<class str_expression, std::string> const str_expression("string");
auto const attr_expression_def = +(char_ - ']');
auto const str_expression_def = lexeme[+(char_ -'[')];
auto const path_expression_def = *(str_expression[create_string] | '[' > attr_expression[create_attribute] > ']');
BOOST_SPIRIT_DEFINE(
path_expression,
attr_expression,
str_expression
);
}}
namespace mapnik {
grammar::path_expression_grammar_type const& path_expression_grammar()
{
return grammar::path_expression;
}
}
#endif //MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_DEF_HPP

View file

@ -27,8 +27,10 @@
#include <mapnik/box2d.hpp>
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/make_unique.hpp>
// stl
#include <algorithm>
#include <memory>
#include <new>
#include <vector>
#include <type_traits>
@ -83,12 +85,12 @@ class quad_tree : util::noncopyable
int num_subnodes() const
{
int count = 0;
int _count = 0;
for (int i = 0; i < 4; ++i)
{
if (children_[i]) ++count;
if (children_[i]) ++_count;
}
return count;
return _count;
}
~node () {}
};
@ -164,9 +166,9 @@ public:
int count_items() const
{
int count = 0;
count_items(root_, count);
return count;
int _count = 0;
count_items(root_, _count);
return _count;
}
void trim()
{
@ -276,23 +278,23 @@ private:
if (!n) return 0;
else
{
int count = 1;
int _count = 1;
for (int i = 0; i < 4; ++i)
{
count += count_nodes(n->children_[i]);
_count += count_nodes(n->children_[i]);
}
return count;
return _count;
}
}
void count_items(node const* n,int& count) const
void count_items(node const* n, int& _count) const
{
if (n)
{
count += n->cont_.size();
_count += n->cont_.size();
for (int i = 0; i < 4; ++i)
{
count_items(n->children_[i],count);
count_items(n->children_[i],_count);
}
}
}

View file

@ -40,12 +40,12 @@ public:
using resolution_type = std::tuple<double,double>;
query(box2d<double> const& bbox,
resolution_type const& resolution,
double scale_denominator,
resolution_type const& _resolution,
double _scale_denominator,
box2d<double> const& unbuffered_bbox)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator),
resolution_(_resolution),
scale_denominator_(_scale_denominator),
filter_factor_(1.0),
unbuffered_bbox_(unbuffered_bbox),
names_(),
@ -53,11 +53,11 @@ public:
{}
query(box2d<double> const& bbox,
resolution_type const& resolution,
double scale_denominator = 1.0)
resolution_type const& _resolution,
double _scale_denominator = 1.0)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator),
resolution_(_resolution),
scale_denominator_(_scale_denominator),
filter_factor_(1.0),
unbuffered_bbox_(bbox),
names_(),

View file

@ -52,9 +52,9 @@ public:
data_(std::move(data)),
filter_factor_(filter_factor) {}
void set_nodata(double nodata)
void set_nodata(double _nodata)
{
nodata_ = nodata;
nodata_ = _nodata;
}
boost::optional<double> const& nodata() const

View file

@ -29,9 +29,9 @@
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/geometry_centroid.hpp>
#include <mapnik/geometry_type.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/centroid.hpp>
#include <mapnik/geometry/geometry_type.hpp>
#include <mapnik/geometry/geometry_types.hpp>
#include <mapnik/vertex_adapters.hpp>
#include <mapnik/geom_util.hpp>

View file

@ -176,9 +176,9 @@ public:
span_image_resample_rgba_affine(source_type & src,
interpolator_type & inter,
agg::image_filter_lut const & filter,
agg::image_filter_lut const & _filter,
boost::optional<value_type> const & nodata_value) :
agg::span_image_resample_rgba_affine<Source>(src, inter, filter)
agg::span_image_resample_rgba_affine<Source>(src, inter, _filter)
{ }
};

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// mapnik
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/geometry_types.hpp>
#include <mapnik/svg/geometry_svg_generator.hpp>
namespace mapnik { namespace svg {

View file

@ -30,7 +30,7 @@
#include <mapnik/svg/geometry_svg_generator.hpp>
#include <mapnik/svg/output/svg_output_attributes.hpp>
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
namespace mapnik { namespace svg {

View file

@ -121,12 +121,12 @@ namespace mapnik { namespace svg {
fill_color_("#000000")
{}
rect_output_attributes(const int x, const int y, const unsigned width, const unsigned height, color const& fill_color)
rect_output_attributes(const int x, const int y, const unsigned width, const unsigned height, color const& _fill_color)
: x_(x),
y_(y),
width_(width),
height_(height),
fill_color_(fill_color.to_hex_string())
fill_color_(_fill_color.to_hex_string())
{}
void set_x(const int x);

View file

@ -131,9 +131,9 @@ public:
return painted_;
}
void painted(bool painted)
void painted(bool _painted)
{
painted_ = painted;
painted_ = _painted;
}
inline eAttributeCollectionPolicy attribute_collection_policy() const

View file

@ -27,7 +27,7 @@
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/util/noncopyable.hpp>
#if defined(GRID_RENDERER)

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/path_expression.hpp>
#include <mapnik/symbolizer_keys.hpp>

Some files were not shown because too many files have changed in this diff Show more