Skip to content
Commits on Source (6)
......@@ -8,7 +8,6 @@ env:
global:
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- HEAVY_JOBS="2"
- PREFIX=/tmp/mapnik
- secure: "F6ivqDNMBQQnrDGA9+7IX+GDswuIqQQd7YPJdQqa2Ked9jddAQDeJClb05ig3JlwfOlYLGZOd43ZX0pKuMtI2Gbkwz211agGP9S3YunwlRg8iWtJlO5kYFUdKCmJNhjg4icfkGELCgwXn+zuEWFSLpkPcjqAFKFlQrIJeAJJgKM="
......@@ -23,7 +22,9 @@ matrix:
include:
- os: linux
name: Linux gcc-6
env: JOBS=4 CXX="ccache g++-6" CC="gcc-6"
env: >-
CXX="ccache g++-6"
CC="gcc-6"
addons:
postgresql: "9.4"
apt:
......@@ -31,40 +32,46 @@ matrix:
packages: [ 'libstdc++-6-dev', 'g++-6', 'xutils-dev', 'postgresql-9.4-postgis-2.3' ]
- os: linux
name: Linux clang-3.9
env: JOBS=8 CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9" ENABLE_GLIBC_WORKAROUND=true TRIGGER=true
env: >-
CXX="ccache clang++-3.9 -Qunused-arguments"
CC="clang-3.9"
ENABLE_GLIBC_WORKAROUND=true
before_install:
- export LINKFLAGS="-fuse-ld=gold-2.26"
addons:
postgresql: "9.4"
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'libstdc++-4.9-dev', 'xutils-dev', 'postgresql-9.4-postgis-2.3' ]
packages: [ 'clang-3.9', 'libstdc++-4.9-dev', 'xutils-dev', 'postgresql-9.4-postgis-2.3' ]
- os: linux
name: Linux clang-3.9 + coverage
env: JOBS=8 COVERAGE=true CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9"
env: >-
CXX="ccache clang++-3.9 -Qunused-arguments"
CC="clang-3.9"
COVERAGE=true
before_install:
- export LINKFLAGS="-fuse-ld=gold-2.26"
- export LLVM_COV="llvm-cov-3.9"
addons:
postgresql: "9.4"
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: ['libstdc++-4.9-dev', 'xutils-dev', 'postgresql-9.4-postgis-2.3' ]
packages: [ 'clang-3.9', 'llvm-3.9', 'libstdc++-4.9-dev', 'xutils-dev', 'postgresql-9.4-postgis-2.3' ]
- os: osx
name: OSX clang
# https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode7.3 # upgrades clang from 6 -> 7
env: JOBS=4 CXX="ccache clang++ -Qunused-arguments"
env: >-
CXX="ccache clang++ -Qunused-arguments"
before_install:
install:
- source scripts/travis-common.sh
# workaround travis rvm bug
# http://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
rvm get head || true
fi
- source scripts/travis-common.sh
- on 'osx' rvm get head || true
- export PATH=${PREFIX}/bin:$(pwd)/mason_packages/.link/bin:${PATH}
- export COVERAGE=${COVERAGE:-false}
- export BENCH=${BENCH:-false}
- git_submodule_update --init deps/
install:
- on 'osx' export DATA_PATH=$(brew --prefix)/var/postgres
- on 'osx' rm -rf ${DATA_PATH}
- on 'osx' initdb ${DATA_PATH} -E utf8
......@@ -77,23 +84,17 @@ install:
- enabled ${COVERAGE} chmod +x codecov
before_script:
- export JOBS=${JOBS:-4}
- export HEAVY_JOBS=${HEAVY_JOBS:-2}
- export SCONSFLAGS='--debug=time'
- source bootstrap.sh
- |
if [[ $(uname -s) == 'Linux' ]]; then
mason install clang++ 3.9.1
export PATH=$(mason prefix clang++ 3.9.1)/bin:${PATH}
mason install llvm-cov 3.9.1
export PATH=$(mason prefix llvm-cov 3.9.1)/bin:${PATH}
which llvm-cov
export LLVM_COV="$(mason prefix llvm-cov 3.9.1)/bin/llvm-cov"
fi
- ccache --version
- ccache -p || true
- ccache --show-stats || true
- commit_message_parse
script:
- export SCONSFLAGS='--debug=time'
- git_submodule_update --init deps/
- configure BENCHMARK=${BENCH} ENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-false}
- cat config.log
# we limit the `make` to 40 min
......@@ -107,6 +108,3 @@ script:
- test_ok && enabled ${COVERAGE} coverage
- test_ok && enabled ${BENCH} make bench
- ./scripts/check_glibcxx.sh
after_success:
- enabled ${TRIGGER} trigger_downstream
......@@ -6,6 +6,17 @@ Developers: Please commit along with changes.
For a complete change history, see the git log.
## 3.0.23
Released: February 18, 2020
(Packaged from bdb30f47a)
- Complete build system migration to Py3 syntax (4b0bdd8630f6999e5db346fd767a06b8ceba8fb9)
- Add support for `BOOST_VERSION >= 1_72`
- gdal.input - add support for int32 pixel types (efc65126db5d51977d6374f9b983fc441f334eb6)
## 3.0.22
Released: January 22, 2019
......
......@@ -9,7 +9,6 @@ _/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/
```
[![Build Status Linux](https://api.travis-ci.org/mapnik/mapnik.svg?branch=master)](http://travis-ci.org/mapnik/mapnik)
[![Build Status Windows](https://ci.appveyor.com/api/projects/status/hc9l7okdjtucfqqn?branch=master&svg=true)](https://ci.appveyor.com/project/Mapbox/mapnik)
[![Coverage Status](https://coveralls.io/repos/mapnik/mapnik/badge.svg?branch=master&service=github)](https://coveralls.io/github/mapnik/mapnik?branch=master)
Mapnik is an open source toolkit for developing mapping applications. At the core is a C++ shared library providing algorithms and patterns for spatial data access and visualization.
......
......@@ -274,6 +274,9 @@ def pretty_dep(dep):
return '%s (%s)' % (dep,'more info see: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation & http://www.boost.org')
return dep
def pretty_deps(indent, deps):
return indent + indent.join(pretty_dep(dep) for dep in deps)
DEFAULT_PLUGINS = []
for k,v in PLUGINS.items():
......@@ -1084,6 +1087,7 @@ int main()
return False
def boost_regex_has_icu(context):
context.env.Append(LIBS='icui18n')
if env['RUNTIME_LINK'] == 'static':
# re-order icu libs to ensure linux linker is happy
for lib_name in ['icui18n',env['ICU_LIB_NAME'],'icudata']:
......@@ -1392,6 +1396,7 @@ if not preconfigured:
[env['ICU_LIB_NAME'],'unicode/unistr.h',True,'C++'],
['harfbuzz', 'harfbuzz/hb.h',True,'C++']
]
OPTIONAL_LIBSHEADERS = []
if env.get('FREETYPE_LIBS') or env.get('FREETYPE_INCLUDES'):
REQUIRED_LIBSHEADERS.insert(0,['freetype','ft2build.h',True,'C'])
......@@ -1414,9 +1419,7 @@ if not preconfigured:
except OSError as e:
pass
# libxml2 should be optional but is currently not
# https://github.com/mapnik/mapnik/issues/913
if env.get('XMLPARSER') and env['XMLPARSER'] == 'libxml2':
if env['XMLPARSER'] == 'libxml2':
if env.get('XML2_LIBS') or env.get('XML2_INCLUDES'):
OPTIONAL_LIBSHEADERS.insert(0,['libxml2','libxml/parser.h',True,'C'])
if env.get('XML2_INCLUDES'):
......@@ -1434,9 +1437,7 @@ if not preconfigured:
if conf.CheckHasDlfcn():
env.Append(CPPDEFINES = '-DMAPNIK_HAS_DLCFN')
else:
env['SKIPPED_DEPS'].extend(['dlfcn'])
OPTIONAL_LIBSHEADERS = []
env['SKIPPED_DEPS'].append('dlfcn')
if env['JPEG']:
OPTIONAL_LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], False,'C','-DHAVE_JPEG'])
......@@ -1445,7 +1446,7 @@ if not preconfigured:
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
env['SKIPPED_DEPS'].extend(['jpeg'])
env['SKIPPED_DEPS'].append('jpeg')
if env['PROJ']:
OPTIONAL_LIBSHEADERS.append(['proj', 'proj_api.h', False,'C','-DMAPNIK_USE_PROJ4'])
......@@ -1454,7 +1455,7 @@ if not preconfigured:
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
env['SKIPPED_DEPS'].extend(['proj'])
env['SKIPPED_DEPS'].append('proj')
if env['PNG']:
OPTIONAL_LIBSHEADERS.append(['png', 'png.h', False,'C','-DHAVE_PNG'])
......@@ -1463,7 +1464,7 @@ if not preconfigured:
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
env['SKIPPED_DEPS'].extend(['png'])
env['SKIPPED_DEPS'].append('png')
if env['WEBP']:
OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP'])
......@@ -1472,7 +1473,7 @@ if not preconfigured:
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
env['SKIPPED_DEPS'].extend(['webp'])
env['SKIPPED_DEPS'].append('webp')
if env['TIFF']:
OPTIONAL_LIBSHEADERS.append(['tiff', 'tiff.h', False,'C','-DHAVE_TIFF'])
......@@ -1481,7 +1482,7 @@ if not preconfigured:
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
env['SKIPPED_DEPS'].extend(['tiff'])
env['SKIPPED_DEPS'].append('tiff')
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']:
......@@ -1781,9 +1782,7 @@ if not preconfigured:
)
env["CAIRO_ALL_LIBS"] = ['cairo']
if env['RUNTIME_LINK'] == 'static':
env["CAIRO_ALL_LIBS"].extend(
['pixman-1']
)
env["CAIRO_ALL_LIBS"].append('pixman-1')
# todo - run actual checkLib?
env['HAS_CAIRO'] = True
else:
......@@ -1830,10 +1829,10 @@ if not preconfigured:
if env['MISSING_DEPS']:
# if required dependencies are missing, print warnings and then let SCons finish without building or saving local config
color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']]))
color_print(1,'\nExiting... the following required dependencies were not found:' + pretty_deps('\n - ', env['MISSING_DEPS']))
color_print(1,"\nSee '%s' for details on possible problems." % (fix_path(SCONS_LOCAL_LOG)))
if env['SKIPPED_DEPS']:
color_print(4,'\nAlso, these OPTIONAL dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['SKIPPED_DEPS']]))
color_print(4,'\nAlso, these OPTIONAL dependencies were not found:' + pretty_deps('\n - ', env['SKIPPED_DEPS']))
color_print(4,"\nSet custom paths to these libraries and header files on the command-line or in a file called '%s'" % SCONS_LOCAL_CONFIG)
color_print(4," ie. $ python scons/scons.py BOOST_INCLUDES=/usr/local/include BOOST_LIBS=/usr/local/lib")
color_print(4, "\nOnce all required dependencies are found a local '%s' will be saved and then install:" % SCONS_LOCAL_CONFIG)
......@@ -1860,7 +1859,7 @@ if not preconfigured:
color_print(4,"Did not use user config file, no custom path variables will be saved...")
if env['SKIPPED_DEPS']:
color_print(4,'\nNote: will build without these OPTIONAL dependencies:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['SKIPPED_DEPS']]))
color_print(4,'\nNote: will build without these OPTIONAL dependencies:' + pretty_deps('\n - ', env['SKIPPED_DEPS']))
print
# fetch the mapnik version header in order to set the
......@@ -1908,13 +1907,13 @@ if not preconfigured:
# Enable logging in debug mode (always) and release mode (when specified)
if env['DEFAULT_LOG_SEVERITY']:
if env['DEFAULT_LOG_SEVERITY'] not in severities:
severities_list = ', '.join(["'%s'" % s for s in severities])
severities_list = ', '.join("'%s'" % s for s in severities)
color_print(1,"Cannot set default logger severity to '%s', available options are %s." % (env['DEFAULT_LOG_SEVERITY'], severities_list))
Exit(1)
else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else:
severities_list = ', '.join(["'%s'" % s for s in severities])
severities_list = ', '.join("'%s'" % s for s in severities)
color_print(1,"No logger severity specified, available options are %s." % severities_list)
Exit(1)
......
......@@ -3,8 +3,8 @@ import random
im = mapnik.Image(256,256)
for x in xrange(0,im.width()):
for y in xrange(0,im.height()):
for x in range(im.width()):
for y in range(im.height()):
r = int(random.random() * 255)
g = random.random() * 255
b = random.random() * 255
......
mapnik (3.0.22+ds1-2) UNRELEASED; urgency=medium
mapnik (3.0.23+ds-1~exp1) experimental; urgency=medium
* New upstream release.
* Bump Standards-Version to 4.5.0, no changes.
* Drop Name field from upstream metadata.
* Add patch to use pkg-config for libxml2.
(closes: #949412)
* Refresh patches.
* Add lintian override for file-references-package-build-path.
-- Bas Couwenberg <sebastic@debian.org> Mon, 30 Sep 2019 19:24:02 +0200
-- Bas Couwenberg <sebastic@debian.org> Tue, 18 Feb 2020 14:50:36 +0100
mapnik (3.0.22+ds1-1) unstable; urgency=medium
......
# Cannot easily be fixed
file-references-package-build-path usr/bin/mapnik-config
......@@ -6,15 +6,15 @@ Bug-Debian: https://bugs.debian.org/892451
--- a/SConstruct
+++ b/SConstruct
@@ -1393,6 +1393,7 @@ if not preconfigured:
['harfbuzz', 'harfbuzz/hb.h',True,'C++']
@@ -1398,6 +1398,7 @@ if not preconfigured:
]
OPTIONAL_LIBSHEADERS = []
+ CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
if env.get('FREETYPE_LIBS') or env.get('FREETYPE_INCLUDES'):
REQUIRED_LIBSHEADERS.insert(0,['freetype','ft2build.h',True,'C'])
if env.get('FREETYPE_INCLUDES'):
@@ -1401,6 +1402,21 @@ if not preconfigured:
@@ -1406,6 +1407,21 @@ if not preconfigured:
if env.get('FREETYPE_LIBS'):
lib_path = env['FREETYPE_LIBS']
env.AppendUnique(LIBPATH = fix_path(lib_path))
......@@ -36,7 +36,7 @@ Bug-Debian: https://bugs.debian.org/892451
elif conf.parse_config('FREETYPE_CONFIG'):
# check if freetype links to bz2
if env['RUNTIME_LINK'] == 'static':
@@ -1634,9 +1650,6 @@ if not preconfigured:
@@ -1635,9 +1651,6 @@ if not preconfigured:
color_print(1,'%s not detected on your system' % env['QUERIED_ICU_DATA'] )
env['MISSING_DEPS'].append('ICU_DATA')
......
......@@ -7,7 +7,7 @@ Applied-Upstream: https://github.com/mapnik/mapnik/commit/fe893134a5dc3ea5433601
--- a/SConstruct
+++ b/SConstruct
@@ -1441,6 +1441,21 @@ if not preconfigured:
@@ -1444,6 +1444,21 @@ if not preconfigured:
if env.get('XML2_LIBS'):
lib_path = env['XML2_LIBS']
env.AppendUnique(LIBPATH = fix_path(lib_path))
......
......@@ -5,11 +5,13 @@
#include <boost/version.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#include <boost/gil/extension/toolbox/color_spaces/hsv.hpp>
#include <boost/gil/extension/toolbox/color_spaces/hsl.hpp>
#else
#include <boost/gil/gil_all.hpp>
#endif
#include <boost/gil/extension/toolbox/hsv.hpp>
#include <boost/gil/extension/toolbox/hsl.hpp>
#endif
#pragma GCC diagnostic pop
namespace agg
......
......@@ -208,6 +208,11 @@ public:
return geom_;
}
inline geometry::geometry<double> & get_geometry()
{
return geom_;
}
inline box2d<double> envelope() const
{
return mapnik::geometry::envelope(geom_);
......
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2017 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
......@@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2017 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -63,17 +63,18 @@ struct end_container<mapnik::feature_impl const>
}
};
#if BOOST_VERSION >= 106900
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();
}
};
struct transform_attribute<const mapnik::feature_impl, const mapnik::feature_impl &, boost::spirit::karma::domain, void>
: detail::transform_attribute_base<mapnik::feature_impl const, mapnik::feature_impl const&, boost::spirit::karma::domain>
{};
template <>
struct transform_attribute<const boost::fusion::cons<const mapnik::feature_impl &, boost::fusion::nil_>, const mapnik::feature_impl &,
boost::spirit::karma::domain, void>
: detail::transform_attribute_base<const boost::fusion::cons<const mapnik::feature_impl &, boost::fusion::nil_>, mapnik::feature_impl const&, boost::spirit::karma::domain>
{};
#endif
}}}
namespace mapnik { namespace json {
......@@ -91,6 +92,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 +111,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_;
};
}}
......
......@@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2017 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -22,11 +22,6 @@
#include <mapnik/json/feature_generator_grammar.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/fusion/include/at.hpp>
namespace mapnik { namespace json {
template <typename OutputIterator, typename FeatureType>
......@@ -40,7 +35,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('}')
;
......
......@@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2017 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -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,30 +73,28 @@ 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>()> linear_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;
};
}}
......
......@@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2017 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -22,92 +22,78 @@
// 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>
// 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)
geometry =
point
|
(&uint_(geometry::geometry_types::LineString)[_1 = _a]
<< (linestring | "{\"type\":\"LineString\",\"coordinates\":[]}"))
linestring
|
(&uint_(geometry::geometry_types::Polygon)[_1 = _a]
<< (polygon | "{\"type\":\"Polygon\",\"coordinates\":[[]]}"))
polygon
|
(&uint_(geometry::geometry_types::MultiPoint)[_1 = _a]
<< (multi_point | "{\"type\":\"MultiPoint\",\"coordinates\":[]}"))
multi_point
|
(&uint_(geometry::geometry_types::MultiLineString)[_1 = _a]
<< (multi_linestring | "{\"type\":\"MultiLineString\",\"coordinates\":[[]]}"))
multi_linestring
|
(&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a]
<< (multi_polygon | "{\"type\":\"MultiPolygon\",\"coordinates\":[[[]]]}"))
multi_polygon
|
(&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a] << geometry_collection)
geometry_collection
|
lit("null")
lit("null") // geometry_empty
;
point = lit("{\"type\":\"Point\",\"coordinates\":") << point_coord << lit("}")
;
linestring = lit("{\"type\":\"LineString\",\"coordinates\":[") << linestring_coord << lit("]}")
linestring = lit("{\"type\":\"LineString\",\"coordinates\":") << linestring_coord << lit("}")
;
polygon = lit("{\"type\":\"Polygon\",\"coordinates\":[") << polygon_coord << lit("]}")
polygon = lit("{\"type\":\"Polygon\",\"coordinates\":") << polygon_coord << lit("}")
;
multi_point = lit("{\"type\":\"MultiPoint\",\"coordinates\":[") << multi_point_coord << lit("]}")
multi_point = lit("{\"type\":\"MultiPoint\",\"coordinates\":") << multi_point_coord << lit("}")
;
multi_linestring = lit("{\"type\":\"MultiLineString\",\"coordinates\":[") << multi_linestring_coord << lit("]}")
multi_linestring = lit("{\"type\":\"MultiLineString\",\"coordinates\":") << multi_linestring_coord << lit("}")
;
multi_polygon = lit("{\"type\":\"MultiPolygon\",\"coordinates\":[") << multi_polygon_coord << lit("]}")
multi_polygon = lit("{\"type\":\"MultiPolygon\",\"coordinates\":") << multi_polygon_coord << lit("}")
;
geometry_collection = lit("{\"type\":\"GeometryCollection\",\"geometries\":[") << geometries << lit("]}")
;
point_coord = lit('[') << coordinate << lit(',') << coordinate << lit(']')
;
linestring_coord = (point_coord % lit(','))
;
polygon_coord = lit('[') << exterior_ring_coord << lit(']') << interior_ring_coord
linestring_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
;
exterior_ring_coord = linestring_coord.alias()
linear_ring_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
;
interior_ring_coord = *(lit(",[") << exterior_ring_coord << lit(']'))
polygon_coord = lit('[') << linear_ring_coord << *(lit(',') << linear_ring_coord)<< lit(']');
;
multi_point_coord = linestring_coord.alias()
multi_point_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
;
multi_linestring_coord = (lit('[') << linestring_coord << lit(']')) % lit(',')
multi_linestring_coord = lit('[') << linestring_coord % lit(',') << lit(']')
;
multi_polygon_coord = (lit('[') << polygon_coord << lit(']')) % lit(',')
multi_polygon_coord = lit('[') << polygon_coord % lit(',') << lit("]")
;
geometries = geometry % lit(',')
;
}
......
......@@ -23,6 +23,12 @@
#include <mapnik/json/properties_generator_grammar.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#pragma GCC diagnostic pop
namespace mapnik { namespace json {
namespace karma = boost::spirit::karma;
......@@ -63,14 +69,13 @@ properties_generator_grammar<OutputIterator,KeyValueStore>::properties_generator
boost::spirit::karma::string_type kstring;
boost::spirit::karma::eps_type eps;
using boost::phoenix::at_c;
properties = lit('{')
<< -(pair % lit(','))
<< lit('}')
;
pair = lit('"')
<< kstring[_1 = boost::phoenix::at_c<0>(_val)] << lit('"')
<< kstring[_1 = at_c<0>(_val)] << lit('"')
<< lit(':')
<< value[_1 = extract_string_(at_c<1>(_val))]
;
......@@ -80,13 +85,6 @@ properties_generator_grammar<OutputIterator,KeyValueStore>::properties_generator
kstring[_1 = at_c<0>(_val)]
;
// FIXME http://boost-spirit.com/home/articles/karma-examples/creating-your-own-generator-component-for-spirit-karma/
//value = (value_null_| bool_ | int__ | double_ | ustring)//[_1 = value_base_(_r1)]
// ;
//value_null_ = kstring[_1 = "null"]
// ;
//ustring = escaped_string_(quote_.c_str())[_1 = utf8_(_val)]
// ;
}
}}
......@@ -141,7 +141,7 @@ struct coordinate_policy : karma::real_policies<T>
template <typename OutputIterator, typename Path>
struct svg_path_generator :
karma::grammar<OutputIterator, Path const& ()>
karma::grammar<OutputIterator, Path()>
{
using path_type = Path;
......@@ -149,12 +149,12 @@ struct svg_path_generator :
svg_path_generator();
// rules
karma::rule<OutputIterator, path_type const& ()> svg;
karma::rule<OutputIterator, path_type const& ()> point;
karma::rule<OutputIterator, path_type const& ()> linestring;
karma::rule<OutputIterator, path_type const& ()> polygon;
karma::rule<OutputIterator, path_type()> svg;
karma::rule<OutputIterator, path_type()> point;
karma::rule<OutputIterator, path_type()> linestring;
karma::rule<OutputIterator, path_type()> polygon;
karma::rule<OutputIterator, coord_type()> svg_point;
karma::rule<OutputIterator, path_type const& ()> svg_path;
karma::rule<OutputIterator, path_type()> svg_path;
// phoenix functions
phoenix::function<svg_detail::get_type<path_type> > _type;
......
......@@ -27,7 +27,7 @@
#define MAPNIK_MAJOR_VERSION 3
#define MAPNIK_MINOR_VERSION 0
#define MAPNIK_PATCH_VERSION 22
#define MAPNIK_PATCH_VERSION 23
#define MAPNIK_VERSION (MAPNIK_MAJOR_VERSION*100000) + (MAPNIK_MINOR_VERSION*100) + (MAPNIK_PATCH_VERSION)
......
......@@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2017 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,12 +26,10 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_type.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/phoenix_function.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
......@@ -39,22 +37,9 @@
namespace mapnik { namespace wkt {
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
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 wkt_coordinate_policy : karma::real_policies<T>
{
......@@ -102,33 +87,29 @@ struct coordinate_generator<std::int64_t>
template <typename OutputIterator, typename Geometry>
struct wkt_generator_grammar :
karma::grammar<OutputIterator, Geometry const& ()>
karma::grammar<OutputIterator, Geometry()>
{
using coord_type = typename Geometry::coord_type;
using coordinate_type = typename Geometry::coord_type;
wkt_generator_grammar();
// rules
karma::rule<OutputIterator, Geometry const&()> geometry;
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> point;
karma::rule<OutputIterator, geometry::point<coord_type> const&()> point_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> linestring;
karma::rule<OutputIterator, geometry::line_string<coord_type> const&()> linestring_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> polygon;
karma::rule<OutputIterator, geometry::polygon<coord_type> const&()> polygon_coord;
karma::rule<OutputIterator, geometry::linear_ring<coord_type> const&()> exterior_ring_coord;
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> > const&()> interior_ring_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_point;
karma::rule<OutputIterator, geometry::multi_point<coord_type> const& ()> multi_point_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_linestring;
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> const& ()> multi_linestring_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_polygon;
karma::rule<OutputIterator, geometry::multi_polygon<coord_type> const& ()> multi_polygon_coord;
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> geometry_collection;
karma::rule<OutputIterator, geometry::geometry_collection<coord_type> const& ()> geometries;
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
karma::rule<OutputIterator, Geometry()> geometry;
karma::rule<OutputIterator, geometry::point<coordinate_type>()> point;
karma::rule<OutputIterator, geometry::point<coordinate_type>()> point_coord;
karma::rule<OutputIterator, geometry::line_string<coordinate_type>()> linestring;
karma::rule<OutputIterator, geometry::line_string<coordinate_type>()> linestring_coord;
karma::rule<OutputIterator, geometry::polygon<coordinate_type>()> polygon;
karma::rule<OutputIterator, geometry::polygon<coordinate_type>()> polygon_coord;
karma::rule<OutputIterator, geometry::linear_ring<coordinate_type>()> linear_ring_coord;
karma::rule<OutputIterator, geometry::multi_point<coordinate_type>()> multi_point;
karma::rule<OutputIterator, geometry::multi_point<coordinate_type>()> multi_point_coord;
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type>()> multi_linestring;
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type>()> multi_linestring_coord;
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type>()> multi_polygon;
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type>()> multi_polygon_coord;
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type>()> geometry_collection;
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type>()> geometries;
//
typename detail::coordinate_generator<coord_type>::generator coordinate;
typename detail::coordinate_generator<coordinate_type>::generator coordinate;
};
}}
......