Merge branch 'master' of github.com:mapnik/mapnik into jh-min-repeat-distance
This commit is contained in:
commit
726274c2c9
208 changed files with 6385 additions and 4844 deletions
48
.travis.yml
48
.travis.yml
|
@ -2,7 +2,12 @@ language: cpp
|
|||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
# - gcc
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEBUG=True ENABLE_LOG=True DEFAULT_LOG_SEVERITY=debug XMLPARSER="libxml2" DEMO=False BENCHMARK=False CUSTOM_CXXFLAGS="" CUSTOM_LDFLAGS=""
|
||||
- DEBUG=False ENABLE_LOG=False DEFAULT_LOG_SEVERITY=none XMLPARSER="ptree" DEMO=False BENCHMARK=False CUSTOM_CXXFLAGS="-flto" CUSTOM_LDFLAGS="-flto"
|
||||
|
||||
addons:
|
||||
postgresql: "9.3"
|
||||
|
@ -18,27 +23,36 @@ before_install:
|
|||
# more recent boost
|
||||
- sudo add-apt-repository -y ppa:boost-latest/ppa
|
||||
- sudo apt-get update -y
|
||||
- sudo apt-get install -y gcc-4.8 g++-4.8 make boost1.55 libgdal-dev libgdal1-dev libgdal1h=1.10.0-1~precise1 python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libwebp-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev libcairo-dev python-cairo-dev libsqlite3-dev
|
||||
- wget http://mapnik.s3.amazonaws.com/deps/harfbuzz-0.9.32.tar.bz2
|
||||
- tar xf harfbuzz-0.9.32.tar.bz2
|
||||
- cd harfbuzz-0.9.32
|
||||
- ./configure --with-icu --with-cairo=no --with-glib=no --with-gobject=no --with-graphite2=no --with-freetype --with-uniscribe=no --with-coretext=no && make && sudo make install
|
||||
- sudo ldconfig
|
||||
- sudo apt-get install -y libstdc++6 libstdc++-4.8-dev make boost1.55 libgdal-dev libgdal1-dev libgdal1h=1.10.0-1~precise1 python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libwebp-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev libcairo-dev python-cairo-dev libsqlite3-dev
|
||||
- sudo apt-get install -y binutils-gold
|
||||
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
|
||||
- sudo apt-get install clang-3.4
|
||||
- export PATH=/usr/bin:${PATH}
|
||||
- echo `which clang`
|
||||
- echo `which clang++`
|
||||
- sudo ln -s /usr/lib/llvm-3.4/lib/LLVMgold.so /usr/lib/LLVMgold.so
|
||||
- sudo ln -s /usr/lib/llvm-3.4/lib/libLTO.so /usr/lib/libLTO.so
|
||||
- if [[ "${CXX}" == 'g++' ]]; then sudo apt-get install gcc-4.8 g++-4.8; export CXX="$(which g++-4.8)"; export CC="$(which gcc-4.8)"; fi;
|
||||
- if [[ "${CXX}" == 'clang++' ]]; then export CXX="$(which clang++)"; export CC="$(which clang)"; fi;
|
||||
- wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.34.tar.bz2
|
||||
- tar xf harfbuzz-0.9.34.tar.bz2
|
||||
- cd harfbuzz-0.9.34
|
||||
- ./configure --prefix=/usr --with-icu --with-cairo=no --with-glib=no --with-gobject=no --with-graphite2=no --with-freetype --with-uniscribe=no --with-coretext=no && make && sudo make install
|
||||
- cd ../
|
||||
|
||||
install:
|
||||
- if [[ "${CXX}" == 'g++' ]]; then export CXX="g++-4.8" && export CC="gcc-4.8"; fi;
|
||||
- ./configure CXX="${CXX}" CC="${CC}" DEMO=True BENCHMARK=True CPP_TESTS=True CAIRO=True FAST=True
|
||||
- if [[ "${CXX}" == 'g++-4.8' ]]; then JOBS=3 make; else JOBS=10 make; fi;
|
||||
- export RANLIB=/bin/true
|
||||
- ./configure CXX="${CXX}" CC="${CC}" CUSTOM_CXXFLAGS="${CUSTOM_CXXFLAGS}" CUSTOM_LDFLAGS="${CUSTOM_LDFLAGS}" XML_PARSER=${XML_PARSER} ENABLE_LOG=${ENABLE_LOG} DEBUG=${DEBUG} DEMO=${DEMO} BENCHMARK=${BENCHMARK} CPP_TESTS=True CAIRO=True FAST=True || cat config.log
|
||||
# workaround ar bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13256
|
||||
- echo 'ar "$@" --plugin /usr/lib/LLVMgold.so' > ar-lto && chmod +x ./ar-lto && export AR=$(pwd)/ar-lto
|
||||
- if [[ "${CXX}" == 'g++-4.8' ]]; then JOBS=2 make; else JOBS=6 make; fi;
|
||||
|
||||
before_script:
|
||||
- make test
|
||||
|
||||
script:
|
||||
- make bench
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "irc.freenode.org#mapnik"
|
||||
use_notice: true
|
||||
- if [[ ${BENCHMARK} != False ]]; then make bench; fi;
|
||||
# install some exotic fonts to ensure we don't crash registering them
|
||||
- sudo apt-get install ttf-wqy-microhei
|
||||
- source localize.sh
|
||||
- python -c "import mapnik;mapnik.logger.set_severity(mapnik.severity_type.Debug);mapnik.register_fonts('/usr/share/fonts/');mapnik.register_fonts('/usr/share/fonts/');print '\n'.join(list(mapnik.FontEngine.instance().face_names()))"
|
||||
|
|
|
@ -1531,7 +1531,7 @@ if not preconfigured:
|
|||
env["CAIRO_ALL_LIBS"] = ['cairo']
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
env["CAIRO_ALL_LIBS"].extend(
|
||||
['pixman-1','expat','fontconfig']
|
||||
['pixman-1','expat']
|
||||
)
|
||||
# todo - run actual checkLib?
|
||||
env['HAS_CAIRO'] = True
|
||||
|
@ -1785,7 +1785,7 @@ if not preconfigured:
|
|||
else:
|
||||
# TODO - add back -fvisibility-inlines-hidden
|
||||
# https://github.com/mapnik/mapnik/issues/1863
|
||||
env.Append(CXXFLAGS = common_cxx_flags + '-O%s -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION']))
|
||||
env.Append(CXXFLAGS = common_cxx_flags + '-O%s -fno-strict-aliasing -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION']))
|
||||
if env['DEBUG_UNDEFINED']:
|
||||
env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv')
|
||||
|
||||
|
|
|
@ -794,24 +794,6 @@ class _TextSymbolizer(TextSymbolizer,_injector):
|
|||
self.format.text_opacity = text_opacity
|
||||
|
||||
|
||||
@property
|
||||
def wrap_char(self):
|
||||
return self.format.wrap_char
|
||||
|
||||
@wrap_char.setter
|
||||
def wrap_char(self, wrap_char):
|
||||
self.format.wrap_char = wrap_char
|
||||
|
||||
|
||||
@property
|
||||
def wrap_character(self):
|
||||
return self.format.wrap_character
|
||||
|
||||
@wrap_char.setter
|
||||
def wrap_character(self, wrap_character):
|
||||
self.format.wrap_character = wrap_character
|
||||
|
||||
|
||||
@property
|
||||
def wrap_before(self):
|
||||
return self.format.wrap_before
|
||||
|
|
|
@ -226,7 +226,6 @@ void export_feature()
|
|||
class_<mapnik::feature_impl,std::shared_ptr<mapnik::feature_impl>,
|
||||
boost::noncopyable>("Feature",init<context_ptr,mapnik::value_integer>("Default ctor."))
|
||||
.def("id",&mapnik::feature_impl::id)
|
||||
.def("__str__",&mapnik::feature_impl::to_string)
|
||||
.def("add_geometries_from_wkb", &feature_add_geometries_from_wkb)
|
||||
.def("add_geometries_from_wkt", &feature_add_geometries_from_wkt)
|
||||
.def("add_geometry", &mapnik::feature_impl::add_geometry)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
|
||||
void export_gamma_method()
|
||||
|
|
|
@ -253,6 +253,9 @@ void export_image()
|
|||
.value("saturation", mapnik::saturation)
|
||||
.value("color", mapnik::_color)
|
||||
.value("value", mapnik::_value)
|
||||
.value("linear_dodge", mapnik::linear_dodge)
|
||||
.value("linear_burn", mapnik::linear_burn)
|
||||
.value("divide", mapnik::divide)
|
||||
;
|
||||
|
||||
class_<image_32,std::shared_ptr<image_32> >("Image","This class represents a 32 bit RGBA image.",init<int,int>())
|
||||
|
|
|
@ -59,7 +59,7 @@ mapnik::coord2d forward_transform_c(mapnik::proj_transform& t, mapnik::coord2d c
|
|||
if (!t.forward(x,y,z)) {
|
||||
std::ostringstream s;
|
||||
s << "Failed to forward project "
|
||||
<< c << " from " << t.source().params() << " to: " << t.dest().params();
|
||||
<< "from " << t.source().params() << " to: " << t.dest().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return mapnik::coord2d(x,y);
|
||||
|
@ -73,7 +73,7 @@ mapnik::coord2d backward_transform_c(mapnik::proj_transform& t, mapnik::coord2d
|
|||
if (!t.backward(x,y,z)) {
|
||||
std::ostringstream s;
|
||||
s << "Failed to back project "
|
||||
<< c << " from " << t.dest().params() << " to: " << t.source().params();
|
||||
<< "from " << t.dest().params() << " to: " << t.source().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return mapnik::coord2d(x,y);
|
||||
|
@ -85,7 +85,7 @@ mapnik::box2d<double> forward_transform_env(mapnik::proj_transform& t, mapnik::b
|
|||
if (!t.forward(new_box)) {
|
||||
std::ostringstream s;
|
||||
s << "Failed to forward project "
|
||||
<< box << " from " << t.source().params() << " to: " << t.dest().params();
|
||||
<< "from " << t.source().params() << " to: " << t.dest().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return new_box;
|
||||
|
@ -97,7 +97,7 @@ mapnik::box2d<double> backward_transform_env(mapnik::proj_transform& t, mapnik::
|
|||
if (!t.backward(new_box)){
|
||||
std::ostringstream s;
|
||||
s << "Failed to back project "
|
||||
<< box << " from " << t.dest().params() << " to: " << t.source().params();
|
||||
<< "from " << t.dest().params() << " to: " << t.source().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return new_box;
|
||||
|
@ -109,7 +109,7 @@ mapnik::box2d<double> forward_transform_env_p(mapnik::proj_transform& t, mapnik:
|
|||
if (!t.forward(new_box,points)) {
|
||||
std::ostringstream s;
|
||||
s << "Failed to forward project "
|
||||
<< box << " from " << t.source().params() << " to: " << t.dest().params();
|
||||
<< "from " << t.source().params() << " to: " << t.dest().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return new_box;
|
||||
|
@ -121,7 +121,7 @@ mapnik::box2d<double> backward_transform_env_p(mapnik::proj_transform& t, mapnik
|
|||
if (!t.backward(new_box,points)){
|
||||
std::ostringstream s;
|
||||
s << "Failed to back project "
|
||||
<< box << " from " << t.dest().params() << " to: " << t.source().params();
|
||||
<< "from " << t.dest().params() << " to: " << t.source().params();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
return new_box;
|
||||
|
|
|
@ -241,7 +241,7 @@ void render3(mapnik::Map const& map,
|
|||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_renderer<mapnik::cairo_surface_ptr> ren(map,surface,scale_factor,offset_x,offset_y);
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> ren(map,mapnik::create_context(surface),scale_factor,offset_x,offset_y);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ void render4(mapnik::Map const& map, PycairoSurface* py_surface)
|
|||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_renderer<mapnik::cairo_surface_ptr> ren(map,surface);
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> ren(map,mapnik::create_context(surface));
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ void render_with_detector4(
|
|||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_renderer<mapnik::cairo_surface_ptr> ren(map, surface, detector);
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> ren(map, mapnik::create_context(surface), detector);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ void render_with_detector5(
|
|||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_renderer<mapnik::cairo_surface_ptr> ren(map, surface, detector, scale_factor, offset_x, offset_y);
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> ren(map, mapnik::create_context(surface), detector, scale_factor, offset_x, offset_y);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
|
|
@ -464,8 +464,6 @@ void export_text_placement()
|
|||
.def_readwrite("character_spacing", &detail::evaluated_format_properties::character_spacing)
|
||||
.def_readwrite("line_spacing", &detail::evaluated_format_properties::line_spacing)
|
||||
.def_readwrite("text_opacity", &detail::evaluated_format_properties::text_opacity)
|
||||
.def_readwrite("wrap_char", &detail::evaluated_format_properties::wrap_char)
|
||||
.def_readwrite("wrap_character", &detail::evaluated_format_properties::wrap_char)
|
||||
.def_readwrite("fill", &detail::evaluated_format_properties::fill)
|
||||
.def_readwrite("halo_fill", &detail::evaluated_format_properties::halo_fill)
|
||||
.def_readwrite("halo_radius", &evaluated_format_properties::halo_radius)
|
||||
|
@ -529,8 +527,6 @@ void export_text_placement()
|
|||
.def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing)
|
||||
.def_readwrite_convert("line_spacing", &formatting::format_node::line_spacing)
|
||||
.def_readwrite_convert("text_opacity", &formatting::format_node::text_opacity)
|
||||
.def_readwrite_convert("wrap_char", &formatting::format_node::wrap_char)
|
||||
.def_readwrite_convert("wrap_character", &formatting::format_node::wrap_char)
|
||||
.def_readwrite_convert("text_transform", &formatting::format_node::text_transform)
|
||||
.def_readwrite_convert("fill", &formatting::format_node::fill)
|
||||
.def_readwrite_convert("halo_fill", &formatting::format_node::halo_fill)
|
||||
|
@ -568,8 +564,6 @@ void export_text_placement()
|
|||
.def_readwrite("character_spacing", &formatting::expression_format::character_spacing)
|
||||
.def_readwrite("line_spacing", &formatting::expression_format::line_spacing)
|
||||
.def_readwrite("text_opacity", &formatting::expression_format::text_opacity)
|
||||
.def_readwrite("wrap_char", &formatting::expression_format::wrap_char)
|
||||
.def_readwrite("wrap_character", &formatting::expression_format::wrap_char)
|
||||
.def_readwrite("fill", &formatting::expression_format::fill)
|
||||
.def_readwrite("halo_fill", &formatting::expression_format::halo_fill)
|
||||
.def_readwrite("halo_radius", &formatting::expression_format::halo_radius)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
|
||||
|
||||
|
|
665
deps/agg/include/agg_pixfmt_rgba.h
vendored
665
deps/agg/include/agg_pixfmt_rgba.h
vendored
File diff suppressed because it is too large
Load diff
2
deps/agg/src/agg_curves.cpp
vendored
2
deps/agg/src/agg_curves.cpp
vendored
|
@ -21,7 +21,7 @@ namespace agg
|
|||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
const double curve_distance_epsilon = 1e-30;
|
||||
//const double curve_distance_epsilon = 1e-30;
|
||||
const double curve_collinearity_epsilon = 1e-30;
|
||||
const double curve_angle_tolerance_epsilon = 0.01;
|
||||
enum curve_recursion_limit_e { curve_recursion_limit = 32 };
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define MAPNIK_AGG_HELPERS_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_gamma_functions.h"
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
#include <mapnik/image_compositing.hpp> // for composite_mode_e
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/request.hpp>
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
#include <mapnik/image_data.hpp>
|
||||
// boost
|
||||
|
||||
// stl
|
||||
#include <memory>
|
||||
|
||||
// fwd declaration to avoid dependence on agg headers
|
||||
|
@ -54,6 +53,7 @@ namespace mapnik {
|
|||
class marker;
|
||||
class proj_transform;
|
||||
struct rasterizer;
|
||||
class image_32;
|
||||
}
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -146,22 +146,6 @@ public:
|
|||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
|
||||
inline box2d<double> clipping_extent() const
|
||||
{
|
||||
if (common_.t_.offset() > 0)
|
||||
{
|
||||
box2d<double> box = common_.query_extent_;
|
||||
double scale = static_cast<double>(common_.query_extent_.width())/static_cast<double>(common_.width_);
|
||||
// 3 is used here because at least 3 was needed for the 'style-level-compositing-tiled-0,1' visual test to pass
|
||||
// TODO - add more tests to hone in on a more robust #
|
||||
scale *= common_.t_.offset()*3;
|
||||
box.pad(scale);
|
||||
return box;
|
||||
}
|
||||
return common_.query_extent_;
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename R>
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent,
|
||||
|
@ -182,7 +166,7 @@ private:
|
|||
void setup(Map const& m);
|
||||
};
|
||||
|
||||
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr);
|
||||
extern template class MAPNIK_DECL agg_renderer<image_32>;
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ struct expression_attributes : boost::static_visitor<void>
|
|||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
names_.insert(attr.name());
|
||||
names_.emplace(attr.name());
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
|
@ -289,7 +289,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
|
|||
{
|
||||
std::string col_idx_name = col_name;
|
||||
boost::replace_all(col_idx_name, "%", col_idx_str);
|
||||
names_.insert(col_idx_name);
|
||||
names_.emplace(col_idx_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
|
|||
{
|
||||
// This is not an indexed column, or we are ignoring indexes.
|
||||
// Insert the name as is.
|
||||
names_.insert(col_name);
|
||||
names_.emplace(col_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,18 +107,6 @@ private:
|
|||
int precision_;
|
||||
};
|
||||
|
||||
template <typename charT,typename traits>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
attribute_descriptor const& ad)
|
||||
{
|
||||
out << "name=" << ad.get_name() << "\n";
|
||||
out << "type=" << ad.get_type() << "\n";
|
||||
out << "size=" << ad.get_size() << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||
|
|
|
@ -22,17 +22,22 @@
|
|||
#ifndef MAPNIK_BOOLEAN_HPP
|
||||
#define MAPNIK_BOOLEAN_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
// std
|
||||
#include <istream>
|
||||
#include <iosfwd>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
//#include <istream>
|
||||
//#include <ostream>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
// Helper for class bool
|
||||
class boolean_type {
|
||||
class MAPNIK_DECL boolean_type
|
||||
{
|
||||
public:
|
||||
boolean_type()
|
||||
: b_(false) {}
|
||||
|
@ -63,25 +68,12 @@ template <typename charT, typename traits>
|
|||
std::basic_istream<charT, traits> &
|
||||
operator >> ( std::basic_istream<charT, traits> & s, boolean_type & b )
|
||||
{
|
||||
std::string word;
|
||||
s >> word;
|
||||
std::transform(word.begin(), word.end(), word.begin(), ::tolower);
|
||||
if ( s )
|
||||
{
|
||||
if ( word == "true" || word == "yes" || word == "on" ||
|
||||
word == "1")
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else if ( word == "false" || word == "no" || word == "off" ||
|
||||
word == "0")
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setstate( std::ios::failbit );
|
||||
}
|
||||
std::string word;
|
||||
s >> word;
|
||||
bool result;
|
||||
if (util::string2bool(word,result)) b = result;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
|
||||
// boost
|
||||
// stl
|
||||
#include <memory>
|
||||
|
||||
// cairo
|
||||
|
@ -412,6 +412,60 @@ private:
|
|||
cairo_ptr cairo_;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct line_pattern_rasterizer
|
||||
{
|
||||
line_pattern_rasterizer(Context & context, cairo_pattern & pattern, unsigned width, unsigned height)
|
||||
: context_(context),
|
||||
pattern_(pattern),
|
||||
width_(width),
|
||||
height_(height) {}
|
||||
|
||||
template <typename T>
|
||||
void add_path(T & path, unsigned start_index = 0)
|
||||
{
|
||||
double length = 0.0;
|
||||
double x0 = 0.0;
|
||||
double y0 = 0.0;
|
||||
double x, y;
|
||||
path.rewind(start_index);
|
||||
for (unsigned cm = path.vertex(&x, &y); cm != SEG_END; cm = path.vertex(&x, &y))
|
||||
{
|
||||
if (cm == SEG_MOVETO)
|
||||
{
|
||||
length = 0.0;
|
||||
}
|
||||
else if (cm == SEG_LINETO)
|
||||
{
|
||||
double dx = x - x0;
|
||||
double dy = y - y0;
|
||||
double angle = std::atan2(dy, dx);
|
||||
double offset = std::fmod(length, static_cast<double>(width_));
|
||||
|
||||
cairo_matrix_t matrix;
|
||||
cairo_matrix_init_identity(&matrix);
|
||||
cairo_matrix_translate(&matrix, x0, y0);
|
||||
cairo_matrix_rotate(&matrix, angle);
|
||||
cairo_matrix_translate(&matrix, -offset, 0.5 * height_);
|
||||
cairo_matrix_invert(&matrix);
|
||||
pattern_.set_matrix(matrix);
|
||||
context_.set_pattern(pattern_);
|
||||
context_.move_to(x0, y0);
|
||||
context_.line_to(x, y);
|
||||
context_.stroke();
|
||||
length = length + std::hypot(x - x0, y - y0);
|
||||
}
|
||||
|
||||
x0 = x;
|
||||
y0 = y;
|
||||
}
|
||||
}
|
||||
|
||||
Context & context_;
|
||||
cairo_pattern & pattern_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,22 +20,30 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
|
||||
#ifndef MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
#define MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace agg { struct trans_affine; }
|
||||
|
||||
static const char * gamma_method_strings[] = {
|
||||
"power", //agg::gamma_power
|
||||
"linear", //agg::gamma_linear
|
||||
"none", //agg::gamma_none
|
||||
"threshold", //agg::gamma_threshold
|
||||
"multiply", //agg::gamma_multiply",
|
||||
""
|
||||
};
|
||||
namespace mapnik {
|
||||
|
||||
IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings )
|
||||
class cairo_context;
|
||||
struct pixel_position;
|
||||
template <typename T> class box2d;
|
||||
namespace svg { struct path_attributes; }
|
||||
|
||||
void render_vector_marker(cairo_context & context, pixel_position const& pos,
|
||||
svg::svg_path_adapter & svg_path, box2d<double> const& bbox,
|
||||
agg::pod_bvector<svg::path_attributes> const & attributes,
|
||||
agg::trans_affine const& tr, double opacity, bool recenter);
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
|
||||
#endif
|
|
@ -28,22 +28,13 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/feature_style_processor.hpp>
|
||||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/request.hpp>
|
||||
#include <mapnik/rule.hpp> // for all symbolizers
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/rule.hpp> // for all symbolizers
|
||||
#include <mapnik/cairo/cairo_context.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/ctrans.hpp> // for CoordTransform
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
|
||||
// cairo
|
||||
#include <cairo.h>
|
||||
|
||||
// boost
|
||||
|
||||
// stl
|
||||
#include <memory>
|
||||
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
|
@ -51,34 +42,57 @@ struct trans_affine;
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
class Map;
|
||||
class feature_impl;
|
||||
class feature_type_style;
|
||||
class label_collision_detector4;
|
||||
class layer;
|
||||
class marker;
|
||||
|
||||
class MAPNIK_DECL cairo_renderer_base : private mapnik::noncopyable
|
||||
class proj_transform;
|
||||
class request;
|
||||
struct pixel_position;
|
||||
struct cairo_save_restore
|
||||
{
|
||||
protected:
|
||||
cairo_renderer_base(Map const& m,
|
||||
cairo_ptr const& cairo,
|
||||
attributes const& vars,
|
||||
cairo_save_restore(cairo_context & context)
|
||||
: context_(context)
|
||||
{
|
||||
context_.save();
|
||||
}
|
||||
~cairo_save_restore()
|
||||
{
|
||||
context_.restore();
|
||||
}
|
||||
cairo_context & context_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer<T> >,
|
||||
private mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
using processor_impl_type = cairo_renderer<T>;
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer_base(Map const& m,
|
||||
cairo_renderer(Map const& m,
|
||||
request const& req,
|
||||
cairo_ptr const& cairo,
|
||||
attributes const& vars,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer_base(Map const& m,
|
||||
cairo_ptr const& cairo,
|
||||
attributes const& vars,
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
std::shared_ptr<label_collision_detector4> detector,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
public:
|
||||
~cairo_renderer_base();
|
||||
|
||||
~cairo_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
|
||||
void end_layer_processing(layer const& lay);
|
||||
void start_style_processing(feature_type_style const& st);
|
||||
|
@ -158,34 +172,11 @@ protected:
|
|||
renderer_common common_;
|
||||
cairo_face_manager face_manager_;
|
||||
void setup(Map const& m);
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer<T> >,
|
||||
public cairo_renderer_base
|
||||
{
|
||||
public:
|
||||
using processor_impl_type = cairo_renderer_base;
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
std::shared_ptr<label_collision_detector4> detector,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
void end_map_processing(Map const& map);
|
||||
};
|
||||
extern template class MAPNIK_DECL cairo_renderer<cairo_ptr>;
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDERER_HPP
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
// boost
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
// stl
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
namespace mapnik {
|
||||
template <typename T,int dim>
|
||||
struct coord {
|
||||
|
@ -185,39 +181,6 @@ private:
|
|||
using coord2d = coord<double,2>;
|
||||
using coord2i = coord<int,2>;
|
||||
|
||||
|
||||
template <typename charT,typename traits,typename T ,int dim>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const coord<T,dim>& c);
|
||||
|
||||
template <typename charT,typename traits,typename T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const coord<T,2>& c)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s << "coord2(" << std::setprecision(16)
|
||||
<< c.x << "," << c.y<< ")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename charT,typename traits,typename T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const coord<T,3>& c)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s << "coord3(" << std::setprecision(16)
|
||||
<< c.x << "," << c.y<< "," << c.z<<")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAPNIK_COORD_HPP
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
#include <memory>
|
||||
|
||||
// stl
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
@ -61,6 +58,9 @@ private:
|
|||
bool registered_;
|
||||
std::set<std::string> plugin_directories_;
|
||||
};
|
||||
|
||||
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_CACHE_HPP
|
||||
|
|
|
@ -29,19 +29,16 @@
|
|||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
#include <unordered_map>
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
// std
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
#include <unordered_map>
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
|
|
@ -333,8 +333,8 @@ operator>>(std::istream & is, mapnik::enumeration<ENUM, THE_MAX> & e)
|
|||
*/
|
||||
|
||||
#define IMPLEMENT_ENUM( name, strings ) \
|
||||
template <> const char ** name ::our_strings_ = strings; \
|
||||
template <> std::string name ::our_name_ = #name; \
|
||||
template <> bool name ::our_verified_flag_( name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
template <> MAPNIK_DECL const char ** name ::our_strings_ = strings; \
|
||||
template <> MAPNIK_DECL std::string name ::our_name_ = #name; \
|
||||
template <> MAPNIK_DECL bool name ::our_verified_flag_( name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
|
||||
#endif // MAPNIK_ENUMERATION_HPP
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/color_factory.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
|
|
@ -67,13 +67,13 @@ public:
|
|||
inline size_type push(key_type const& name)
|
||||
{
|
||||
size_type index = mapping_.size();
|
||||
mapping_.insert(std::make_pair(name, index));
|
||||
mapping_.emplace(name, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
inline void add(key_type const& name, size_type index)
|
||||
{
|
||||
mapping_.insert(std::make_pair(name, index));
|
||||
mapping_.emplace(name, index);
|
||||
}
|
||||
|
||||
inline size_type size() const { return mapping_.size(); }
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
#include <mapnik/attribute_descriptor.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -88,21 +87,6 @@ private:
|
|||
std::vector<attribute_descriptor> desc_ar_;
|
||||
};
|
||||
|
||||
template <typename charT,typename traits>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
layer_descriptor const& ld)
|
||||
{
|
||||
out << "name: " << ld.get_name() << "\n";
|
||||
out << "encoding: " << ld.get_encoding() << "\n";
|
||||
std::vector<attribute_descriptor> const& desc_ar = ld.get_descriptors();
|
||||
std::vector<attribute_descriptor>::const_iterator pos = desc_ar.begin();
|
||||
while (pos != desc_ar.end())
|
||||
{
|
||||
out << *pos++ << "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAPNIK_FEATURE_LAYER_DESC_HPP
|
||||
|
|
|
@ -28,18 +28,16 @@
|
|||
#include <mapnik/font_set.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
// stl
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <utility> // pair
|
||||
#include <vector>
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
||||
struct FT_LibraryRec_;
|
||||
struct FT_MemoryRec_;
|
||||
namespace boost { template <class T> class optional; }
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
|
||||
// boost
|
||||
|
||||
// stl
|
||||
#include <memory>
|
||||
|
||||
// fwd declaration to avoid depedence on agg headers
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
/*
|
||||
|
@ -60,8 +57,6 @@ static inline void scale_grid(mapnik::grid::data_type & target,
|
|||
unsigned yprt1 = 0;
|
||||
unsigned xprt = 0;
|
||||
unsigned xprt1 = 0;
|
||||
boost::ignore_unused_variable_warning(yprt1);
|
||||
boost::ignore_unused_variable_warning(xprt1);
|
||||
|
||||
//no scaling or subpixel offset
|
||||
if (target_height == source_height && target_width == source_width && offs_x == 0 && offs_y == 0){
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace mapnik
|
|||
* be rendered atomically when the filter attached to
|
||||
* this rule is matched.
|
||||
*/
|
||||
struct group_rule
|
||||
struct MAPNIK_DECL group_rule
|
||||
{
|
||||
using symbolizers = std::vector<symbolizer>;
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include <mapnik/palette.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/range/algorithm.hpp>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
@ -261,7 +258,7 @@ public:
|
|||
|
||||
// find closest match based on mean of r,g,b,a
|
||||
std::vector<rgba>::const_iterator pit =
|
||||
boost::lower_bound(sorted_pal_, c, rgba::mean_sort_cmp());
|
||||
std::lower_bound(sorted_pal_.begin(),sorted_pal_.end(), c, rgba::mean_sort_cmp());
|
||||
ind = pit-sorted_pal_.begin();
|
||||
if (ind == sorted_pal_.size())
|
||||
ind--;
|
||||
|
@ -334,7 +331,7 @@ public:
|
|||
create_palette_rek(sorted_pal_, root_.get());
|
||||
|
||||
// sort palette for binary searching in quantization
|
||||
boost::sort(sorted_pal_, rgba::mean_sort_cmp());
|
||||
std::sort(sorted_pal_.begin(), sorted_pal_.end(), rgba::mean_sort_cmp());
|
||||
// returned palette is rearanged, so that colors with a<255 are at the begining
|
||||
pal_remap_.resize(sorted_pal_.size());
|
||||
palette.clear();
|
||||
|
|
|
@ -74,7 +74,10 @@ enum composite_mode_e
|
|||
hue,
|
||||
saturation,
|
||||
_color,
|
||||
_value
|
||||
_value,
|
||||
linear_dodge,
|
||||
linear_burn,
|
||||
divide
|
||||
};
|
||||
|
||||
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
// stl
|
||||
#include <cassert>
|
||||
|
@ -34,7 +35,7 @@
|
|||
namespace mapnik
|
||||
{
|
||||
template <typename T>
|
||||
class ImageData
|
||||
class MAPNIK_DECL ImageData
|
||||
{
|
||||
public:
|
||||
using pixel_type = T;
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
// boost
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/gil/gil_all.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
|
@ -176,11 +174,8 @@ void process_channel_impl (Src const& src, Dst & dst, Conv const& k)
|
|||
}
|
||||
|
||||
template <typename Src, typename Dst, typename Conv>
|
||||
void process_channel (Src const& src, Dst & dst, Conv const& k)
|
||||
void process_channel (Src const&, Dst &, Conv const&)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(src);
|
||||
boost::ignore_unused_variable_warning(dst);
|
||||
boost::ignore_unused_variable_warning(k);
|
||||
}
|
||||
|
||||
template <typename Src, typename Dst>
|
||||
|
|
|
@ -25,10 +25,8 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <mapnik/graphics.hpp>
|
||||
#endif
|
||||
#include <mapnik/image_data.hpp>
|
||||
#include <mapnik/image_view.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
@ -37,6 +35,7 @@
|
|||
// stl
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -132,44 +131,43 @@ void save_as_jpeg(std::string const& filename,
|
|||
T const& image);
|
||||
#endif
|
||||
|
||||
inline bool is_png (std::string const& filename)
|
||||
inline bool is_png(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".png"));
|
||||
}
|
||||
|
||||
inline bool is_jpeg (std::string const& filename)
|
||||
inline bool is_jpeg(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".jpg")) ||
|
||||
boost::algorithm::iends_with(filename,std::string(".jpeg"));
|
||||
}
|
||||
|
||||
inline bool is_tiff (std::string const& filename)
|
||||
inline bool is_tiff(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".tif")) ||
|
||||
boost::algorithm::iends_with(filename,std::string(".tiff"));
|
||||
}
|
||||
|
||||
inline bool is_pdf (std::string const& filename)
|
||||
inline bool is_pdf(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".pdf"));
|
||||
}
|
||||
|
||||
inline bool is_svg (std::string const& filename)
|
||||
inline bool is_svg(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".svg"));
|
||||
}
|
||||
|
||||
inline bool is_ps (std::string const& filename)
|
||||
inline bool is_ps(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".ps"));
|
||||
}
|
||||
|
||||
inline bool is_webp (std::string const& filename)
|
||||
inline bool is_webp(std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::iends_with(filename,std::string(".webp"));
|
||||
}
|
||||
|
||||
|
||||
inline boost::optional<std::string> type_from_filename(std::string const& filename)
|
||||
|
||||
{
|
||||
|
@ -193,15 +191,6 @@ inline std::string guess_type( std::string const& filename )
|
|||
return "<unknown>";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
double distance(T x0,T y0,T x1,T y1)
|
||||
{
|
||||
double dx = x1-x0;
|
||||
double dy = y1-y0;
|
||||
return std::sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
|
||||
// add 1-px border around image - useful for debugging alignment issues
|
||||
template <typename T>
|
||||
void add_border(T & image)
|
||||
|
@ -257,53 +246,53 @@ MAPNIK_DECL void save_to_stream(image_32 const& image,
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&);
|
||||
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&);
|
||||
|
||||
extern template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
#ifdef _MSC_VER
|
||||
template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
|
||||
std::string const&);
|
||||
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
std::string const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&);
|
||||
|
||||
template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 const&,
|
||||
std::string const&);
|
||||
|
||||
template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&);
|
||||
|
||||
template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
|
||||
std::string const&,
|
||||
rgba_palette const&);
|
||||
|
||||
template MAPNIK_DECL void save_to_stream<image_data_32>(
|
||||
image_data_32 const& image,
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
|
||||
#if defined(HAVE_JPEG)
|
||||
|
||||
#include <mapnik/global.hpp>
|
||||
|
||||
#include <new>
|
||||
#include <ostream>
|
||||
|
||||
extern "C"
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// icu
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -29,10 +29,11 @@
|
|||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/interprocess/interprocess_fwd.hpp>
|
||||
|
||||
namespace boost { namespace interprocess { class mapped_region; } }
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ class MAPNIK_DECL mapped_memory_cache :
|
|||
private mapnik::noncopyable
|
||||
{
|
||||
friend class CreateStatic<mapped_memory_cache>;
|
||||
boost::unordered_map<std::string,mapped_region_ptr> cache_;
|
||||
std::unordered_map<std::string,mapped_region_ptr> cache_;
|
||||
public:
|
||||
bool insert(std::string const& key, mapped_region_ptr);
|
||||
boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
|
||||
|
|
|
@ -24,23 +24,20 @@
|
|||
#define MAPNIK_MARKER_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/image_data.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/svg/svg_storage.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_path_storage.h"
|
||||
#include "agg_array.h"
|
||||
|
||||
// boost
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
// stl
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <mapnik/markers_placements/line.hpp>
|
||||
#include <mapnik/markers_placements/point.hpp>
|
||||
#include <mapnik/markers_placements/interior.hpp>
|
||||
#include <mapnik/markers_placements/vertext_first.hpp>
|
||||
#include <mapnik/markers_placements/vertext_last.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
@ -41,7 +43,9 @@ class markers_placement_finder : mapnik::noncopyable
|
|||
public:
|
||||
using markers_placement = boost::variant<markers_point_placement<Locator, Detector>,
|
||||
markers_line_placement<Locator, Detector>,
|
||||
markers_interior_placement<Locator, Detector>>;
|
||||
markers_interior_placement<Locator, Detector>,
|
||||
markers_vertex_first_placement<Locator, Detector>,
|
||||
markers_vertex_last_placement<Locator, Detector>>;
|
||||
|
||||
class get_point_visitor : public boost::static_visitor<bool>
|
||||
{
|
||||
|
@ -74,22 +78,14 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
/** Get a point where the marker should be placed.
|
||||
* Each time this function is called a new point is returned.
|
||||
* \param x Return value for x position
|
||||
* \param y Return value for x position
|
||||
* \param angle Return value for rotation angle
|
||||
* \param ignore_placement Whether to add selected position to detector
|
||||
* \return True if a place is found, false if none is found.
|
||||
*/
|
||||
// Get next point where the marker should be placed. Returns true if a place is found, false if none is found.
|
||||
bool get_point(double &x, double &y, double &angle, bool ignore_placement)
|
||||
{
|
||||
return boost::apply_visitor(get_point_visitor(x, y, angle, ignore_placement), placement_);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Factory function for particular placement implementations.
|
||||
*/
|
||||
// Factory function for particular placement implementations.
|
||||
static markers_placement create(marker_placement_e placement_type,
|
||||
Locator &locator,
|
||||
box2d<double> const& size,
|
||||
|
@ -110,7 +106,9 @@ private:
|
|||
{
|
||||
{ MARKER_POINT_PLACEMENT, boost::value_factory<markers_point_placement<Locator, Detector>>() },
|
||||
{ MARKER_INTERIOR_PLACEMENT, boost::value_factory<markers_interior_placement<Locator, Detector>>() },
|
||||
{ MARKER_LINE_PLACEMENT, boost::value_factory<markers_line_placement<Locator, Detector>>() }
|
||||
{ MARKER_LINE_PLACEMENT, boost::value_factory<markers_line_placement<Locator, Detector>>() },
|
||||
{ MARKER_VERTEX_FIRST_PLACEMENT, boost::value_factory<markers_vertex_first_placement<Locator, Detector>>() },
|
||||
{ MARKER_VERTEX_LAST_PLACEMENT, boost::value_factory<markers_vertex_last_placement<Locator, Detector>>() }
|
||||
};
|
||||
return factories.at(placement_type)(locator, size, tr, detector, spacing, max_error, allow_overlap);
|
||||
}
|
||||
|
|
|
@ -206,13 +206,13 @@ private:
|
|||
double last_y;
|
||||
double next_x;
|
||||
double next_y;
|
||||
/** If a marker could not be placed at the exact point where it should
|
||||
* go the next marker's distance will be a bit lower. */
|
||||
// If a marker could not be placed at the exact point where it should
|
||||
// go the next marker's distance will be a bit lower.
|
||||
double error_;
|
||||
double spacing_left_;
|
||||
unsigned marker_nr_;
|
||||
|
||||
/** Set spacing_left_, adjusts error_ and performs sanity checks. */
|
||||
// Set spacing_left_, adjusts error_ and performs sanity checks.
|
||||
void set_spacing_left(double sl, bool allow_negative=false)
|
||||
{
|
||||
double delta_error = sl - spacing_left_;
|
||||
|
|
|
@ -55,27 +55,16 @@ public:
|
|||
{
|
||||
rewind();
|
||||
}
|
||||
virtual ~markers_point_placement() {}
|
||||
|
||||
/** Start again at first marker.
|
||||
* \note Returns the same list of markers only works when they were NOT added
|
||||
* to the detector.
|
||||
*/
|
||||
virtual void rewind()
|
||||
// Start again at first marker. Returns the same list of markers only works when they were NOT added to the detector.
|
||||
void rewind()
|
||||
{
|
||||
locator_.rewind(0);
|
||||
done_ = false;
|
||||
}
|
||||
|
||||
/** Get a point where the marker should be placed.
|
||||
* Each time this function is called a new point is returned.
|
||||
* \param x Return value for x position
|
||||
* \param y Return value for x position
|
||||
* \param angle Return value for rotation angle
|
||||
* \param ignore_placement Whether to add selected position to detector
|
||||
* \return True if a place is found, false if none is found.
|
||||
*/
|
||||
virtual bool get_point(double &x, double &y, double &angle, bool ignore_placement)
|
||||
// Get next point where the marker should be placed. Returns true if a place is found, false if none is found.
|
||||
bool get_point(double &x, double &y, double &angle, bool ignore_placement)
|
||||
{
|
||||
if (done_)
|
||||
{
|
||||
|
@ -129,7 +118,7 @@ protected:
|
|||
double marker_width_;
|
||||
bool done_;
|
||||
|
||||
/** Rotates the size_ box and translates the position. */
|
||||
// Rotates the size_ box and translates the position.
|
||||
box2d<double> perform_transform(double angle, double dx, double dy)
|
||||
{
|
||||
double x1 = size_.minx();
|
||||
|
@ -156,4 +145,3 @@ protected:
|
|||
}
|
||||
|
||||
#endif // MAPNIK_MARKERS_PLACEMENTS_POINT_HPP
|
||||
|
||||
|
|
98
include/mapnik/markers_placements/vertext_first.hpp
Normal file
98
include/mapnik/markers_placements/vertext_first.hpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP
|
||||
#define MAPNIK_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP
|
||||
|
||||
#include <mapnik/markers_placements/point.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename Locator, typename Detector>
|
||||
class markers_vertex_first_placement : public markers_point_placement<Locator, Detector>
|
||||
{
|
||||
public:
|
||||
markers_vertex_first_placement(
|
||||
Locator &locator,
|
||||
box2d<double> const& size,
|
||||
agg::trans_affine const& tr,
|
||||
Detector &detector,
|
||||
double spacing,
|
||||
double max_error,
|
||||
bool allow_overlap)
|
||||
: markers_point_placement<Locator, Detector>(
|
||||
locator, size, tr, detector,
|
||||
spacing, max_error, allow_overlap)
|
||||
{
|
||||
}
|
||||
|
||||
bool get_point(double &x, double &y, double &angle, bool ignore_placement)
|
||||
{
|
||||
if (this->done_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->locator_.type() == mapnik::geometry_type::types::Point)
|
||||
{
|
||||
return markers_point_placement<Locator, Detector>::get_point(x, y, angle, ignore_placement);
|
||||
}
|
||||
|
||||
double x0, y0;
|
||||
|
||||
if (agg::is_stop(this->locator_.vertex(&x0, &y0)))
|
||||
{
|
||||
this->done_ = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
x = x0;
|
||||
y = y0;
|
||||
angle = 0;
|
||||
|
||||
double x1, y1;
|
||||
|
||||
if (agg::is_line_to(this->locator_.vertex(&x1, &y1)))
|
||||
{
|
||||
angle = std::atan2(y1 - y0, x1 - x0);
|
||||
}
|
||||
|
||||
box2d<double> box = this->perform_transform(angle, x, y);
|
||||
|
||||
if (!this->allow_overlap_ && !this->detector_.has_placement(box))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ignore_placement)
|
||||
{
|
||||
this->detector_.insert(box);
|
||||
}
|
||||
|
||||
this->done_ = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP
|
103
include/mapnik/markers_placements/vertext_last.hpp
Normal file
103
include/mapnik/markers_placements/vertext_last.hpp
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP
|
||||
#define MAPNIK_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP
|
||||
|
||||
#include <mapnik/markers_placements/point.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename Locator, typename Detector>
|
||||
class markers_vertex_last_placement : public markers_point_placement<Locator, Detector>
|
||||
{
|
||||
public:
|
||||
markers_vertex_last_placement(
|
||||
Locator &locator,
|
||||
box2d<double> const& size,
|
||||
agg::trans_affine const& tr,
|
||||
Detector &detector,
|
||||
double spacing,
|
||||
double max_error,
|
||||
bool allow_overlap)
|
||||
: markers_point_placement<Locator, Detector>(
|
||||
locator, size, tr, detector,
|
||||
spacing, max_error, allow_overlap)
|
||||
{
|
||||
}
|
||||
|
||||
bool get_point(double &x, double &y, double &angle, bool ignore_placement)
|
||||
{
|
||||
if (this->done_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double next_x, next_y;
|
||||
double x0, y0;
|
||||
double x1, y1;
|
||||
unsigned command0, command1 = agg::path_cmd_stop;
|
||||
|
||||
while (!agg::is_stop(command0 = this->locator_.vertex(&next_x, &next_y)))
|
||||
{
|
||||
command1 = command0;
|
||||
x1 = x0;
|
||||
y1 = y0;
|
||||
x0 = next_x;
|
||||
y0 = next_y;
|
||||
}
|
||||
|
||||
// If path stopped on the very firts vertex.
|
||||
if (agg::is_stop(command1))
|
||||
{
|
||||
this->done_ = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
x = x0;
|
||||
y = y0;
|
||||
|
||||
if (agg::is_line_to(command1))
|
||||
{
|
||||
angle = std::atan2(y0 - y1, x0 - x1);
|
||||
}
|
||||
|
||||
box2d<double> box = this->perform_transform(angle, x, y);
|
||||
|
||||
if (!this->allow_overlap_ && !this->detector_.has_placement(box))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ignore_placement)
|
||||
{
|
||||
this->detector_.insert(box);
|
||||
}
|
||||
|
||||
this->done_ = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP
|
|
@ -26,6 +26,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/featureset.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/memory_datasource.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
|
|
|
@ -387,10 +387,6 @@ private:
|
|||
|
||||
void push_vertex(vertex2d const& v)
|
||||
{
|
||||
#ifdef MAPNIK_LOG
|
||||
MAPNIK_LOG_DEBUG(ctrans) << "offset_converter: " << v;
|
||||
#endif
|
||||
|
||||
vertices_.push_back(v);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#ifndef MAPNIK_PIXEL_POSITION_HPP
|
||||
#define MAPNIK_PIXEL_POSITION_HPP
|
||||
|
||||
// stl
|
||||
#include <iomanip>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
@ -33,8 +30,12 @@ struct pixel_position
|
|||
{
|
||||
double x;
|
||||
double y;
|
||||
pixel_position(double x_, double y_) : x(x_), y(y_) { }
|
||||
pixel_position() : x(0), y(0) { }
|
||||
pixel_position(double x_, double y_)
|
||||
: x(x_),
|
||||
y(y_) {}
|
||||
pixel_position()
|
||||
: x(0),
|
||||
y(0) {}
|
||||
pixel_position operator+ (pixel_position const& other) const
|
||||
{
|
||||
return pixel_position(x + other.x, y + other.y);
|
||||
|
@ -74,20 +75,6 @@ inline pixel_position operator* (double factor, pixel_position const& pos)
|
|||
return pixel_position(factor * pos.x, factor * pos.y);
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const pixel_position& e)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s << '(' << std::fixed << std::setprecision(16)
|
||||
<< e.x << ", " << e.y << ')';
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
49
include/mapnik/renderer_common/clipping_extent.hpp
Normal file
49
include/mapnik/renderer_common/clipping_extent.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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_CLIPPING_EXTENT_HPP
|
||||
#define MAPNIK_CLIPPING_EXTENT_HPP
|
||||
|
||||
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T>
|
||||
box2d<double> clipping_extent(T const& common)
|
||||
{
|
||||
if (common.t_.offset() > 0)
|
||||
{
|
||||
box2d<double> box = common.query_extent_;
|
||||
double scale = static_cast<double>(common.query_extent_.width())/static_cast<double>(common.width_);
|
||||
// 3 is used here because at least 3 was needed for the 'style-level-compositing-tiled-0,1' visual test to pass
|
||||
// TODO - add more tests to hone in on a more robust #
|
||||
scale *= common.t_.offset() * 3;
|
||||
box.pad(scale);
|
||||
return box;
|
||||
}
|
||||
return common.query_extent_;
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CLIPPING_EXTENT_HPP
|
|
@ -23,6 +23,12 @@
|
|||
#ifndef MAPNIK_RENDERER_COMMON_PROCESS_BUILDING_SYMBOLIZER_HPP
|
||||
#define MAPNIK_RENDERER_COMMON_PROCESS_BUILDING_SYMBOLIZER_HPP
|
||||
|
||||
#include <mapnik/segment.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename F1, typename F2, typename F3>
|
||||
|
@ -106,4 +112,4 @@ void render_building_symbolizer(mapnik::feature_impl &feature,
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif /* MAPNIK_RENDERER_COMMON_PROCESS_BUILDING_SYMBOLIZER_HPP */
|
||||
#endif // MAPNIK_RENDERER_COMMON_PROCESS_BUILDING_SYMBOLIZER_HPP
|
||||
|
|
|
@ -23,28 +23,29 @@
|
|||
#ifndef MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP
|
||||
#define MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/attribute_collector.hpp>
|
||||
#include <mapnik/group/group_layout.hpp>
|
||||
#include <mapnik/group/group_layout_manager.hpp>
|
||||
#include <mapnik/group/group_rule.hpp>
|
||||
#include <mapnik/group/group_symbolizer_helper.hpp>
|
||||
#include <mapnik/group/group_symbolizer_properties.hpp>
|
||||
#include <mapnik/renderer_common/process_point_symbolizer.hpp>
|
||||
#include <mapnik/text/placements_list.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
|
||||
// agg
|
||||
#include <agg_trans_affine.h>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class proj_transform;
|
||||
struct glyph_info;
|
||||
class text_symbolizer_helper;
|
||||
|
||||
// General:
|
||||
|
||||
|
@ -268,7 +269,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
|
|||
*(rule->get_filter())).to_bool())
|
||||
{
|
||||
// add matched rule and feature to the list of things to draw
|
||||
matches.push_back(std::make_pair(rule, sub_feature));
|
||||
matches.emplace_back(rule, sub_feature);
|
||||
|
||||
// construct a bounding box around all symbolizers for the matched rule
|
||||
bound_box bounds;
|
||||
|
@ -335,4 +336,4 @@ void render_group_symbolizer(group_symbolizer const& sym,
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif /* MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP */
|
||||
#endif // MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
#include <mapnik/marker_helpers.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -24,8 +24,11 @@
|
|||
#define MAPNIK_RENDERER_COMMON_PROCESS_POINT_SYMBOLIZER_HPP
|
||||
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
|
|
@ -23,15 +23,17 @@
|
|||
#ifndef MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP
|
||||
#define MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP
|
||||
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename vertex_converter_type, typename rasterizer_type, typename F>
|
||||
void render_polygon_symbolizer(polygon_symbolizer const &sym,
|
||||
mapnik::feature_impl &feature,
|
||||
proj_transform const &prj_trans,
|
||||
renderer_common &common,
|
||||
box2d<double> const &clip_box,
|
||||
rasterizer_type &ras,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans,
|
||||
renderer_common & common,
|
||||
box2d<double> const& clip_box,
|
||||
rasterizer_type & ras,
|
||||
F fill_func)
|
||||
{
|
||||
agg::trans_affine tr;
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/warp.hpp>
|
||||
#include <mapnik/raster.hpp>
|
||||
#include <mapnik/raster_colorizer.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -136,4 +140,4 @@ void render_raster_symbolizer(raster_symbolizer const &sym,
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif /* MAPNIK_RENDERER_COMMON_PROCESS_RASTER_SYMBOLIZER_HPP */
|
||||
#endif // MAPNIK_RENDERER_COMMON_PROCESS_RASTER_SYMBOLIZER_HPP
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
* Copyright (C) 2014 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,24 +20,29 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_GAMMA_METHOD_HPP
|
||||
#define MAPNIK_GAMMA_METHOD_HPP
|
||||
#ifndef MAPNIK_RENDER_PATTERN_HPP
|
||||
#define MAPNIK_RENDER_PATTERN_HPP
|
||||
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <mapnik/image_data.hpp>
|
||||
#include <memory>
|
||||
|
||||
// fwd decl
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
}
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
enum gamma_method_enum {
|
||||
GAMMA_POWER, //agg::gamma_power
|
||||
GAMMA_LINEAR, //agg::gamma_linear
|
||||
GAMMA_NONE, //agg::gamma_none
|
||||
GAMMA_THRESHOLD, //agg::gamma_threshold
|
||||
GAMMA_MULTIPLY, //agg::gamma_multiply
|
||||
gamma_method_enum_MAX
|
||||
};
|
||||
// fwd decl
|
||||
struct rasterizer;
|
||||
class marker;
|
||||
|
||||
DEFINE_ENUM (gamma_method_e, gamma_method_enum );
|
||||
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity);
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GAMMA_METHOD_HPP
|
||||
|
||||
#endif // MAPNIK_RENDER_PATTERN_HPP
|
|
@ -31,7 +31,7 @@ namespace mapnik
|
|||
|
||||
using segment_t = std::tuple<double,double,double,double>;
|
||||
|
||||
static bool y_order(segment_t const& first,segment_t const& second)
|
||||
static inline bool y_order(segment_t const& first,segment_t const& second)
|
||||
{
|
||||
double miny0 = std::min(std::get<1>(first), std::get<3>(first));
|
||||
double miny1 = std::min(std::get<1>(second), std::get<3>(second));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/image_scaling.hpp>
|
||||
#include <mapnik/image_compositing.hpp>
|
||||
#include <mapnik/simplify.hpp>
|
||||
#include <mapnik/expression.hpp>
|
||||
|
@ -38,7 +39,6 @@
|
|||
#include <mapnik/raster_colorizer.hpp>
|
||||
#include <mapnik/group/group_symbolizer_properties.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include <mapnik/util/dasharray_parser.hpp>
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
|||
#include <functional>
|
||||
// boost
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
namespace agg { struct trans_affine; }
|
||||
|
||||
|
@ -163,10 +162,8 @@ struct evaluate_path_wrapper
|
|||
{
|
||||
using result_type = T;
|
||||
template <typename T1, typename T2>
|
||||
result_type operator() (T1 const& expr, T2 const& feature) const
|
||||
result_type operator() (T1 const&, T2 const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(expr);
|
||||
boost::ignore_unused_variable_warning(feature);
|
||||
return result_type();
|
||||
}
|
||||
|
||||
|
@ -185,14 +182,7 @@ struct evaluate_path_wrapper<std::string>
|
|||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct enum_traits
|
||||
{
|
||||
using result_type = boost::optional<T>;
|
||||
static result_type from_string(std::string const& str)
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
struct enum_traits {};
|
||||
|
||||
template <>
|
||||
struct enum_traits<composite_mode_e>
|
||||
|
@ -204,6 +194,16 @@ struct enum_traits<composite_mode_e>
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct enum_traits<scaling_method_e>
|
||||
{
|
||||
using result_type = boost::optional<scaling_method_e>;
|
||||
static result_type from_string(std::string const& str)
|
||||
{
|
||||
return scaling_method_from_string(str);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct enum_traits<simplify_algorithm_e>
|
||||
{
|
||||
|
@ -232,16 +232,22 @@ template <> struct enum_traits<e> { \
|
|||
} \
|
||||
};\
|
||||
|
||||
ENUM_FROM_STRING( pattern_alignment_enum )
|
||||
ENUM_FROM_STRING( line_join_enum )
|
||||
ENUM_FROM_STRING( line_cap_enum )
|
||||
ENUM_FROM_STRING( line_join_enum )
|
||||
ENUM_FROM_STRING( point_placement_enum )
|
||||
ENUM_FROM_STRING( marker_placement_enum )
|
||||
ENUM_FROM_STRING( gamma_method_enum )
|
||||
ENUM_FROM_STRING( line_rasterizer_enum )
|
||||
ENUM_FROM_STRING( marker_placement_enum )
|
||||
ENUM_FROM_STRING( marker_multi_policy_enum )
|
||||
ENUM_FROM_STRING( debug_symbolizer_mode_enum )
|
||||
ENUM_FROM_STRING( pattern_alignment_enum )
|
||||
ENUM_FROM_STRING( halo_rasterizer_enum )
|
||||
ENUM_FROM_STRING( label_placement_enum )
|
||||
ENUM_FROM_STRING( vertical_alignment_enum )
|
||||
ENUM_FROM_STRING( horizontal_alignment_enum )
|
||||
ENUM_FROM_STRING( justify_alignment_enum )
|
||||
ENUM_FROM_STRING( text_transform_enum )
|
||||
ENUM_FROM_STRING( text_upright_enum )
|
||||
ENUM_FROM_STRING( gamma_method_enum )
|
||||
|
||||
// enum
|
||||
template <typename T, bool is_enum = true>
|
||||
|
@ -282,9 +288,8 @@ template <typename T>
|
|||
struct enumeration_result<T,false>
|
||||
{
|
||||
using result_type = T;
|
||||
static result_type convert(enumeration_wrapper const& e)
|
||||
static result_type convert(enumeration_wrapper const&)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(e);
|
||||
return result_type();// FAIL
|
||||
}
|
||||
};
|
||||
|
@ -302,10 +307,7 @@ struct put_impl
|
|||
}
|
||||
else
|
||||
{
|
||||
// NOTE: we use insert here instead of emplace
|
||||
// because of lacking std::map emplace support in libstdc++
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44436
|
||||
sym.properties.insert(std::make_pair(key, enumeration_wrapper(val)));
|
||||
sym.properties.emplace(key, enumeration_wrapper(val));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -322,7 +324,7 @@ struct put_impl<T, false>
|
|||
}
|
||||
else
|
||||
{
|
||||
sym.properties.insert(std::make_pair(key, val));
|
||||
sym.properties.emplace(key, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -419,9 +421,8 @@ struct extract_value : public boost::static_visitor<T>
|
|||
}
|
||||
|
||||
template <typename T1>
|
||||
auto operator() (T1 const& val) const -> result_type
|
||||
auto operator() (T1 const&) const -> result_type
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return result_type();
|
||||
}
|
||||
|
||||
|
@ -452,20 +453,20 @@ struct extract_raw_value : public boost::static_visitor<T1>
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
void put(symbolizer_base & sym, keys key, T const& val)
|
||||
MAPNIK_DECL void put(symbolizer_base & sym, keys key, T const& val)
|
||||
{
|
||||
constexpr bool enum_ = std::is_enum<T>::value;
|
||||
detail::put_impl<T, enum_ >::apply(sym, key, val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool has_key(symbolizer_base const& sym, keys key)
|
||||
MAPNIK_DECL bool has_key(symbolizer_base const& sym, keys key)
|
||||
{
|
||||
return (sym.properties.count(key) == 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars, T const& _default_value = T())
|
||||
MAPNIK_DECL T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars, T const& _default_value = T())
|
||||
{
|
||||
using const_iterator = symbolizer_base::cont_type::const_iterator;
|
||||
const_iterator itr = sym.properties.find(key);
|
||||
|
@ -477,7 +478,7 @@ T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_optional(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars)
|
||||
MAPNIK_DECL boost::optional<T> get_optional(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars)
|
||||
{
|
||||
using const_iterator = symbolizer_base::cont_type::const_iterator;
|
||||
const_iterator itr = sym.properties.find(key);
|
||||
|
@ -489,7 +490,7 @@ boost::optional<T> get_optional(symbolizer_base const& sym, keys key, mapnik::fe
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
T get(symbolizer_base const& sym, keys key, T const& _default_value = T())
|
||||
MAPNIK_DECL T get(symbolizer_base const& sym, keys key, T const& _default_value = T())
|
||||
{
|
||||
using const_iterator = symbolizer_base::cont_type::const_iterator;
|
||||
const_iterator itr = sym.properties.find(key);
|
||||
|
@ -501,7 +502,7 @@ T get(symbolizer_base const& sym, keys key, T const& _default_value = T())
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_optional(symbolizer_base const& sym, keys key)
|
||||
MAPNIK_DECL boost::optional<T> get_optional(symbolizer_base const& sym, keys key)
|
||||
{
|
||||
using const_iterator = symbolizer_base::cont_type::const_iterator;
|
||||
const_iterator itr = sym.properties.find(key);
|
||||
|
@ -519,8 +520,8 @@ constexpr auto to_integral(Enum e) -> typename std::underlying_type<Enum>::type
|
|||
}
|
||||
|
||||
using property_meta_type = std::tuple<const char*, mapnik::symbolizer_base::value_type, std::function<std::string(enumeration_wrapper)>, property_types>;
|
||||
property_meta_type const& get_meta(mapnik::keys key);
|
||||
mapnik::keys get_key(std::string const& name);
|
||||
MAPNIK_DECL property_meta_type const& get_meta(mapnik::keys key);
|
||||
MAPNIK_DECL mapnik::keys get_key(std::string const& name);
|
||||
|
||||
// concrete symbolizer types
|
||||
struct MAPNIK_DECL point_symbolizer : public symbolizer_base {};
|
||||
|
|
|
@ -102,6 +102,8 @@ enum marker_placement_enum
|
|||
MARKER_POINT_PLACEMENT,
|
||||
MARKER_INTERIOR_PLACEMENT,
|
||||
MARKER_LINE_PLACEMENT,
|
||||
MARKER_VERTEX_FIRST_PLACEMENT,
|
||||
MARKER_VERTEX_LAST_PLACEMENT,
|
||||
marker_placement_enum_MAX
|
||||
};
|
||||
|
||||
|
@ -184,6 +186,17 @@ enum text_upright_enum
|
|||
|
||||
DEFINE_ENUM(text_upright_e, text_upright_enum);
|
||||
|
||||
enum gamma_method_enum {
|
||||
GAMMA_POWER, //agg::gamma_power
|
||||
GAMMA_LINEAR, //agg::gamma_linear
|
||||
GAMMA_NONE, //agg::gamma_none
|
||||
GAMMA_THRESHOLD, //agg::gamma_threshold
|
||||
GAMMA_MULTIPLY, //agg::gamma_multiply
|
||||
gamma_method_enum_MAX
|
||||
};
|
||||
|
||||
DEFINE_ENUM (gamma_method_e, gamma_method_enum );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -87,18 +87,7 @@ struct hash_visitor : boost::static_visitor<std::size_t>
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<mapnik::symbolizer>
|
||||
{
|
||||
std::size_t operator()(mapnik::symbolizer const& sym) const
|
||||
{
|
||||
return boost::apply_visitor(mapnik::hash_visitor(),sym);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MAPNIK_SYMBOLIZER_HASH_HPP
|
||||
|
|
|
@ -127,9 +127,8 @@ struct symbolizer_name_impl : public boost::static_visitor<std::string>
|
|||
{
|
||||
public:
|
||||
template <typename Symbolizer>
|
||||
std::string operator () (Symbolizer const& sym) const
|
||||
std::string operator () (Symbolizer const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(sym);
|
||||
return symbolizer_traits<Symbolizer>::name();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ extern "C"
|
|||
}
|
||||
|
||||
//stl
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -47,6 +47,7 @@ namespace mapnik
|
|||
class font_face : mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
using glyph_info_cache_type = std::unordered_map<glyph_index_t, glyph_info>;
|
||||
font_face(FT_Face face);
|
||||
|
||||
std::string family_name() const
|
||||
|
@ -69,13 +70,13 @@ public:
|
|||
bool set_character_sizes(double size);
|
||||
bool set_unscaled_character_sizes();
|
||||
|
||||
void glyph_dimensions(glyph_info &glyph) const;
|
||||
bool glyph_dimensions(glyph_info &glyph) const;
|
||||
|
||||
~font_face();
|
||||
|
||||
private:
|
||||
FT_Face face_;
|
||||
mutable std::map<glyph_index_t, glyph_info> dimension_cache_;
|
||||
mutable glyph_info_cache_type glyph_info_cache_;
|
||||
mutable double char_height_;
|
||||
};
|
||||
using face_ptr = std::shared_ptr<font_face>;
|
||||
|
|
|
@ -50,7 +50,6 @@ public:
|
|||
boost::optional<symbolizer_base::value_type> line_spacing;
|
||||
boost::optional<symbolizer_base::value_type> text_opacity;
|
||||
boost::optional<symbolizer_base::value_type> wrap_before;
|
||||
boost::optional<symbolizer_base::value_type> wrap_char;
|
||||
boost::optional<symbolizer_base::value_type> text_transform;
|
||||
boost::optional<symbolizer_base::value_type> fill;
|
||||
boost::optional<symbolizer_base::value_type> halo_fill;
|
||||
|
|
|
@ -48,7 +48,6 @@ static void shape_text(text_line & line,
|
|||
{
|
||||
unsigned start = line.first_char();
|
||||
unsigned end = line.last_char();
|
||||
mapnik::value_unicode_string const& text = itemizer.text();
|
||||
size_t length = end - start;
|
||||
if (!length) return;
|
||||
line.reserve(length);
|
||||
|
@ -58,20 +57,22 @@ static void shape_text(text_line & line,
|
|||
const std::unique_ptr<hb_buffer_t, decltype(hb_buffer_deleter)> buffer(hb_buffer_create(),hb_buffer_deleter);
|
||||
hb_buffer_set_unicode_funcs(buffer.get(), hb_icu_get_unicode_funcs());
|
||||
hb_buffer_pre_allocate(buffer.get(), length);
|
||||
mapnik::value_unicode_string const& text = itemizer.text();
|
||||
|
||||
for (auto const& text_item : list)
|
||||
{
|
||||
face_set_ptr face_set = font_manager.get_face_set(text_item.format->face_name, text_item.format->fontset);
|
||||
double size = text_item.format->text_size * scale_factor;
|
||||
face_set->set_unscaled_character_sizes();
|
||||
font_face_set::iterator face_itr = face_set->begin(), face_end = face_set->end();
|
||||
for (; face_itr != face_end; ++face_itr)
|
||||
std::size_t num_faces = face_set->size();
|
||||
std::size_t pos = 0;
|
||||
for (auto const& face : *face_set)
|
||||
{
|
||||
++pos;
|
||||
hb_buffer_clear_contents(buffer.get());
|
||||
hb_buffer_add_utf16(buffer.get(), text.getBuffer(), text.length(), text_item.start, text_item.end - text_item.start);
|
||||
hb_buffer_set_direction(buffer.get(), (text_item.rtl == UBIDI_RTL)?HB_DIRECTION_RTL:HB_DIRECTION_LTR);
|
||||
hb_buffer_set_script(buffer.get(), hb_icu_script_to_script(text_item.script));
|
||||
face_ptr const& face = *face_itr;
|
||||
hb_font_t *font(hb_ft_font_create(face->get_face(), nullptr));
|
||||
hb_shape(font, buffer.get(), nullptr, 0);
|
||||
hb_font_destroy(font);
|
||||
|
@ -91,7 +92,7 @@ static void shape_text(text_line & line,
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!font_has_all_glyphs && face_itr+1 != face_end)
|
||||
if (!font_has_all_glyphs && (pos < num_faces))
|
||||
{
|
||||
//Try next font in fontset
|
||||
continue;
|
||||
|
@ -101,8 +102,8 @@ static void shape_text(text_line & line,
|
|||
{
|
||||
glyph_info tmp;
|
||||
tmp.glyph_index = glyphs[i].codepoint;
|
||||
face->glyph_dimensions(tmp);
|
||||
|
||||
if (face->glyph_dimensions(tmp))
|
||||
{
|
||||
tmp.char_index = glyphs[i].cluster;
|
||||
tmp.face = face;
|
||||
tmp.format = text_item.format;
|
||||
|
@ -112,7 +113,8 @@ static void shape_text(text_line & line,
|
|||
|
||||
tmp.offset.set(positions[i].x_offset * tmp.scale_multiplier, positions[i].y_offset * tmp.scale_multiplier);
|
||||
width_map[glyphs[i].cluster] += tmp.advance();
|
||||
line.add_glyph(std::move(tmp), scale_factor);
|
||||
line.add_glyph(tmp, scale_factor);
|
||||
}
|
||||
}
|
||||
line.update_max_char_height(face->get_char_height(size));
|
||||
break; //When we reach this point the current font had all glyphs.
|
||||
|
|
|
@ -107,7 +107,7 @@ static void shape_text(text_line & line,
|
|||
face->glyph_dimensions(tmp);
|
||||
tmp.scale_multiplier = size / face->get_face()->units_per_EM;
|
||||
width_map[i] += tmp.advance();
|
||||
line.add_glyph(std::move(tmp), scale_factor);
|
||||
line.add_glyph(tmp, scale_factor);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
108
include/mapnik/text/placement_finder_impl.hpp
Normal file
108
include/mapnik/text/placement_finder_impl.hpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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/debug.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/ctrans.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
#include <mapnik/text/placement_finder.hpp>
|
||||
#include <mapnik/text/text_layout.hpp>
|
||||
#include <mapnik/text/text_properties.hpp>
|
||||
#include <mapnik/text/placements_list.hpp>
|
||||
#include <mapnik/text/vertex_cache.hpp>
|
||||
#include <mapnik/text/tolerance_iterator.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
bool placement_finder::find_line_placements(T & path, bool points)
|
||||
{
|
||||
if (!layouts_.line_count()) return true; //TODO
|
||||
vertex_cache pp(path);
|
||||
|
||||
bool success = false;
|
||||
while (pp.next_subpath())
|
||||
{
|
||||
if (points)
|
||||
{
|
||||
if (pp.length() <= 0.001)
|
||||
{
|
||||
success = find_point_placement(pp.current_position()) || success;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((pp.length() < info_.properties.minimum_path_length * scale_factor_)
|
||||
||
|
||||
(pp.length() <= 0.001) // Clipping removed whole geometry
|
||||
||
|
||||
(pp.length() < layouts_.width()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
double spacing = get_spacing(pp.length(), points ? 0. : layouts_.width());
|
||||
|
||||
//horizontal_alignment_e halign = layouts_.back()->horizontal_alignment();
|
||||
|
||||
// halign == H_LEFT -> don't move
|
||||
if (horizontal_alignment_ == H_MIDDLE || horizontal_alignment_ == H_AUTO)
|
||||
{
|
||||
pp.forward(spacing/2.0);
|
||||
}
|
||||
else if (horizontal_alignment_ == H_RIGHT)
|
||||
{
|
||||
pp.forward(pp.length());
|
||||
}
|
||||
|
||||
if (move_dx_ != 0.0) path_move_dx(pp, move_dx_);
|
||||
|
||||
do
|
||||
{
|
||||
tolerance_iterator tolerance_offset(info_.properties.label_position_tolerance * scale_factor_, spacing); //TODO: Handle halign
|
||||
while (tolerance_offset.next())
|
||||
{
|
||||
vertex_cache::scoped_state state(pp);
|
||||
if (pp.move(tolerance_offset.get())
|
||||
&& (
|
||||
(points && find_point_placement(pp.current_position()))
|
||||
|| (!points && single_line_placement(pp, info_.properties.upright))))
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (pp.forward(spacing));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
}// ns mapnik
|
|
@ -25,8 +25,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/text/placements/base.hpp>
|
||||
// boost
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -30,9 +30,37 @@
|
|||
#include <mapnik/text/placement_finder.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/ctrans.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T>
|
||||
struct placement_finder_adapter
|
||||
{
|
||||
using placement_finder_type = T;
|
||||
placement_finder_adapter(T & finder, bool points_on_line)
|
||||
: finder_(finder),
|
||||
points_on_line_(points_on_line) {}
|
||||
|
||||
template <typename PathT>
|
||||
void add_path(PathT & path)
|
||||
{
|
||||
status_ = finder_.find_line_placements(path, points_on_line_);
|
||||
}
|
||||
|
||||
bool status() const { return status_;}
|
||||
// Place text at points on a line instead of following the line (used for ShieldSymbolizer)
|
||||
placement_finder_type & finder_;
|
||||
bool points_on_line_;
|
||||
mutable bool status_ = false;
|
||||
|
||||
};
|
||||
|
||||
using conv_types = boost::mpl::vector<clip_line_tag , transform_tag, affine_transform_tag, simplify_tag, smooth_tag>;
|
||||
using vertex_converter_type = vertex_converter<box2d<double>, placement_finder_adapter<placement_finder> , symbolizer_base,
|
||||
CoordTransform, proj_transform, agg::trans_affine,
|
||||
conv_types, feature_impl>;
|
||||
|
||||
class base_symbolizer_helper
|
||||
{
|
||||
public:
|
||||
|
@ -94,7 +122,8 @@ public:
|
|||
CoordTransform const& t,
|
||||
FaceManagerT & font_manager,
|
||||
DetectorT & detector,
|
||||
box2d<double> const& query_extent);
|
||||
box2d<double> const& query_extent,
|
||||
agg::trans_affine const&);
|
||||
|
||||
template <typename FaceManagerT, typename DetectorT>
|
||||
text_symbolizer_helper(shield_symbolizer const& sym,
|
||||
|
@ -107,7 +136,8 @@ public:
|
|||
CoordTransform const& t,
|
||||
FaceManagerT & font_manager,
|
||||
DetectorT & detector,
|
||||
box2d<double> const& query_extent);
|
||||
box2d<double> const& query_extent,
|
||||
agg::trans_affine const&);
|
||||
|
||||
// Return all placements.
|
||||
placements_list const& get();
|
||||
|
@ -117,12 +147,12 @@ protected:
|
|||
|
||||
placement_finder finder_;
|
||||
|
||||
// Place text at points on a line instead of following the line (used for ShieldSymbolizer)
|
||||
bool points_on_line_;
|
||||
|
||||
placement_finder_adapter<placement_finder> adapter_;
|
||||
vertex_converter_type converter_;
|
||||
//ShieldSymbolizer only
|
||||
void init_marker();
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif // SYMBOLIZER_HELPERS_HPP
|
||||
|
|
|
@ -23,20 +23,30 @@
|
|||
#define MAPNIK_TEXT_LAYOUT_HPP
|
||||
|
||||
//mapnik
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include <mapnik/text/text_properties.hpp>
|
||||
#include <mapnik/text/text_line.hpp>
|
||||
#include <mapnik/text/itemizer.hpp>
|
||||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include <mapnik/text/glyph_info.hpp>
|
||||
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
|
||||
#include <mapnik/text/harfbuzz_shaper.hpp>
|
||||
#include <mapnik/text/rotation.hpp>
|
||||
|
||||
//stl
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
class feature_impl;
|
||||
class text_layout;
|
||||
|
||||
using text_layout_ptr = std::shared_ptr<text_layout>;
|
||||
using text_layout_vector = std::vector<text_layout_ptr>;
|
||||
|
||||
|
@ -46,7 +56,6 @@ public:
|
|||
using line_vector = std::vector<text_line>;
|
||||
using const_iterator = line_vector::const_iterator;
|
||||
using child_iterator = text_layout_vector::const_iterator;
|
||||
using shaper_type = harfbuzz_shaper;
|
||||
|
||||
text_layout(face_manager_freetype & font_manager, double scale_factor, text_layout_properties const& properties);
|
||||
|
||||
|
|
|
@ -22,15 +22,14 @@
|
|||
#ifndef MAPNIK_TEXT_LINE_HPP
|
||||
#define MAPNIK_TEXT_LINE_HPP
|
||||
|
||||
//mapnik
|
||||
#include <mapnik/text/glyph_info.hpp>
|
||||
#include <mapnik/text/text_properties.hpp>
|
||||
//stl
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
struct glyph_info;
|
||||
|
||||
// This class stores all glyphs of a line in left to right order.
|
||||
// It can be used for rendering but no text processing (like line breaking)
|
||||
// should be done!
|
||||
|
@ -43,10 +42,8 @@ public:
|
|||
|
||||
text_line(unsigned first_char, unsigned last_char);
|
||||
|
||||
// Get glyph vector.
|
||||
glyph_vector const& glyphs() const { return glyphs_; }
|
||||
// Append glyph.
|
||||
void add_glyph(glyph_info && glyph, double scale_factor_);
|
||||
void add_glyph(glyph_info const& glyph, double scale_factor_);
|
||||
|
||||
// Preallocate memory.
|
||||
void reserve(glyph_vector::size_type length);
|
||||
|
@ -80,8 +77,8 @@ public:
|
|||
unsigned size() const;
|
||||
private:
|
||||
glyph_vector glyphs_;
|
||||
double line_height_; //Includes line spacing (returned by freetype)
|
||||
double max_char_height_; //Height of 'X' character of the largest font in this run. //TODO: Initialize this!
|
||||
double line_height_; // Includes line spacing (returned by freetype)
|
||||
double max_char_height_; // Height of 'X' character of the largest font in this run. //TODO: Initialize this!
|
||||
double width_;
|
||||
unsigned first_char_;
|
||||
unsigned last_char_;
|
||||
|
|
|
@ -45,6 +45,17 @@ namespace mapnik { namespace detail {
|
|||
|
||||
struct evaluated_format_properties
|
||||
{
|
||||
evaluated_format_properties() :
|
||||
face_name(),
|
||||
text_size(0.0),
|
||||
character_spacing(0.0),
|
||||
line_spacing(0.0),
|
||||
text_opacity(1.0),
|
||||
halo_opacity(1.0),
|
||||
text_transform(NONE),
|
||||
fill(0,0,0),
|
||||
halo_fill(0,0,0),
|
||||
halo_radius(0.0) {}
|
||||
std::string face_name;
|
||||
boost::optional<font_set> fontset;
|
||||
double text_size;
|
||||
|
@ -52,8 +63,7 @@ struct evaluated_format_properties
|
|||
double line_spacing;
|
||||
double text_opacity;
|
||||
double halo_opacity;
|
||||
unsigned wrap_char;
|
||||
text_transform_e text_transform; //Per expression
|
||||
text_transform_e text_transform;
|
||||
color fill;
|
||||
color halo_fill;
|
||||
double halo_radius;
|
||||
|
@ -80,7 +90,6 @@ struct MAPNIK_DECL format_properties
|
|||
symbolizer_base::value_type line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen
|
||||
symbolizer_base::value_type text_opacity;
|
||||
symbolizer_base::value_type halo_opacity;
|
||||
symbolizer_base::value_type wrap_char;
|
||||
symbolizer_base::value_type fill;
|
||||
symbolizer_base::value_type halo_fill;
|
||||
symbolizer_base::value_type halo_radius;
|
||||
|
@ -150,7 +159,7 @@ struct MAPNIK_DECL text_symbolizer_properties
|
|||
void to_xml(boost::property_tree::ptree & node, bool explicit_defaults,
|
||||
text_symbolizer_properties const& dfl = text_symbolizer_properties()) const;
|
||||
|
||||
// Takes a feature and produces formated text as output.
|
||||
// Takes a feature and produces formatted text as output.
|
||||
// The output object has to be created by the caller and passed in for thread safety.
|
||||
void process(text_layout &output, feature_impl const& feature, attributes const& vars);
|
||||
void evaluate_text_properties(feature_impl const& feature, attributes const& attrs);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
|
@ -40,8 +41,8 @@ namespace mapnik
|
|||
class vertex_cache;
|
||||
using vertex_cache_ptr = std::shared_ptr<vertex_cache>;
|
||||
|
||||
/** Caches all path points and their lengths. Allows easy moving in both directions. */
|
||||
class vertex_cache
|
||||
// Caches all path points and their lengths. Allows easy moving in both directions.
|
||||
class MAPNIK_DECL vertex_cache
|
||||
{
|
||||
struct segment
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ class vertex_cache
|
|||
double length;
|
||||
};
|
||||
|
||||
/* The first segment always has the length 0 and just defines the starting point. */
|
||||
// The first segment always has the length 0 and just defines the starting point.
|
||||
struct segment_vector
|
||||
{
|
||||
segment_vector() : vector(), length(0.) {}
|
||||
|
@ -65,8 +66,8 @@ class vertex_cache
|
|||
};
|
||||
|
||||
public:
|
||||
/** This class has no public members to avoid acciedential modification.
|
||||
* It should only be used with save_state/restore_state. */
|
||||
// This class has no public members to avoid acciedential modification.
|
||||
// It should only be used with save_state/restore_state.
|
||||
class state
|
||||
{
|
||||
segment_vector::iterator current_segment;
|
||||
|
@ -92,7 +93,7 @@ public:
|
|||
bool restored_;
|
||||
};
|
||||
|
||||
/********************************************************************************************/
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T> vertex_cache(T &path);
|
||||
|
||||
|
@ -104,73 +105,72 @@ public:
|
|||
double linear_position() const { return position_; }
|
||||
|
||||
|
||||
/** Returns a parallel line in the specified distance. */
|
||||
vertex_cache &get_offseted(double offset, double region_width);
|
||||
// Returns a parallel line in the specified distance.
|
||||
vertex_cache & get_offseted(double offset, double region_width);
|
||||
|
||||
|
||||
/** Skip a certain amount of space.
|
||||
*
|
||||
* This function automatically calculates new points if the position is not exactly
|
||||
* on a point on the path.
|
||||
*/
|
||||
// Skip a certain amount of space.
|
||||
// This function automatically calculates new points if the position is not exactly
|
||||
// on a point on the path.
|
||||
|
||||
bool forward(double length);
|
||||
/** Go backwards. */
|
||||
// Go backwards.
|
||||
bool backward(double length);
|
||||
/** Move in any direction (based on sign of length). Returns false if it reaches either end of the path. */
|
||||
// Move in any direction (based on sign of length). Returns false if it reaches either end of the path.
|
||||
bool move(double length);
|
||||
/** Work on next subpath. Returns false if the is no next subpath. */
|
||||
// Work on next subpath. Returns false if the is no next subpath.
|
||||
bool next_subpath();
|
||||
|
||||
// Compatibility with standard path interface
|
||||
void rewind(unsigned);
|
||||
unsigned vertex(double *x, double *y);
|
||||
|
||||
//State
|
||||
// State
|
||||
state save_state() const;
|
||||
void restore_state(state const& s);
|
||||
/** Go back to initial state. */
|
||||
// Go back to initial state.
|
||||
void reset();
|
||||
|
||||
/** position on this line closest to the target position */
|
||||
// position on this line closest to the target position
|
||||
double position_closest_to(pixel_position const &target_pos);
|
||||
|
||||
private:
|
||||
void rewind_subpath();
|
||||
bool next_segment();
|
||||
bool previous_segment();
|
||||
/** Position as calculated by last move/forward/next call. */
|
||||
// Position as calculated by last move/forward/next call.
|
||||
pixel_position current_position_;
|
||||
/** First pixel of current segment. */
|
||||
// First pixel of current segment.
|
||||
pixel_position segment_starting_point_;
|
||||
/** List of all subpaths. */
|
||||
// List of all subpaths.
|
||||
std::vector<segment_vector> subpaths_;
|
||||
/** Currently active subpath. */
|
||||
// Currently active subpath.
|
||||
std::vector<segment_vector>::iterator current_subpath_;
|
||||
/** Current segment for normal operation (move()). */
|
||||
// Current segment for normal operation (move()).
|
||||
segment_vector::iterator current_segment_;
|
||||
/** Current segment in compatibility mode (vertex(), rewind()). */
|
||||
// Current segment in compatibility mode (vertex(), rewind()).
|
||||
segment_vector::iterator vertex_segment_;
|
||||
/** Currently active subpath in compatibility mode. */
|
||||
// Currently active subpath in compatibility mode.
|
||||
std::vector<segment_vector>::iterator vertex_subpath_;
|
||||
/** State is initialized (after first call to next_subpath()). */
|
||||
// State is initialized (after first call to next_subpath()).
|
||||
bool initialized_;
|
||||
/** Position from start of segment. */
|
||||
// Position from start of segment.
|
||||
double position_in_segment_;
|
||||
/** Angle for current segment. */
|
||||
// Angle for current segment.
|
||||
mutable double angle_;
|
||||
/** Is the value in angle_ valid?
|
||||
* Used to avoid unnecessary calculations. */
|
||||
// Is the value in angle_ valid?
|
||||
// Used to avoid unnecessary calculations.
|
||||
mutable bool angle_valid_;
|
||||
using offseted_lines_map = std::map<double, vertex_cache_ptr>;
|
||||
/** Cache of all offseted lines already computed. */
|
||||
// Cache of all offseted lines already computed.
|
||||
offseted_lines_map offseted_lines_;
|
||||
/** Linear position, i.e distance from start of line. */
|
||||
// Linear position, i.e distance from start of line.
|
||||
double position_;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
vertex_cache::vertex_cache(T &path)
|
||||
vertex_cache::vertex_cache(T & path)
|
||||
: current_position_(),
|
||||
segment_starting_point_(),
|
||||
subpaths_(),
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#ifdef MAPNIK_LOG
|
||||
#include <mapnik/debug.hpp>
|
||||
#endif
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/transform_expression.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
|
@ -35,7 +32,7 @@
|
|||
// boost
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
// agg
|
||||
#include <agg_trans_affine.h>
|
||||
|
||||
|
@ -60,9 +57,8 @@ struct transform_processor
|
|||
attribute_collector(Container& names)
|
||||
: collect_(names) {}
|
||||
|
||||
void operator() (identity_node const& node) const
|
||||
void operator() (identity_node const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(node);
|
||||
}
|
||||
|
||||
void operator() (matrix_node const& node) const
|
||||
|
@ -116,9 +112,8 @@ struct transform_processor
|
|||
vars_(v),
|
||||
scale_factor_(scale_factor) {}
|
||||
|
||||
void operator() (identity_node const& node)
|
||||
void operator() (identity_node const&)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(node);
|
||||
}
|
||||
|
||||
void operator() (matrix_node const& node)
|
||||
|
@ -212,22 +207,11 @@ struct transform_processor
|
|||
{
|
||||
node_evaluator eval(tr, feat, vars, scale_factor);
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr));
|
||||
#endif
|
||||
|
||||
for (transform_node const& node : boost::adaptors::reverse(list))
|
||||
transform_list::const_reverse_iterator rit;
|
||||
for (rit = list.rbegin(); rit!= list.rend(); ++rit)
|
||||
{
|
||||
boost::apply_visitor(eval, *node);
|
||||
#ifdef MAPNIK_LOG
|
||||
MAPNIK_LOG_DEBUG(transform) << "transform: apply " << to_string(*node);
|
||||
MAPNIK_LOG_DEBUG(transform) << "transform: result " << to_string(matrix_node(tr));
|
||||
#endif
|
||||
boost::apply_visitor(eval, *(*rit));
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
MAPNIK_LOG_DEBUG(transform) << "transform: end";
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::string to_string(transform_node const& node)
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
// stl
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
|
||||
namespace mapnik { namespace util {
|
||||
|
||||
|
|
|
@ -196,13 +196,13 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
|
|||
if (command == SEG_MOVETO)
|
||||
{
|
||||
rings.push_back(new linear_ring); // start new loop
|
||||
rings.back().push_back(std::make_pair(x,y));
|
||||
rings.back().emplace_back(x,y);
|
||||
size += 4; // num_points
|
||||
size += 2 * 8; // point
|
||||
}
|
||||
else if (command == SEG_LINETO)
|
||||
{
|
||||
rings.back().push_back(std::make_pair(x,y));
|
||||
rings.back().emplace_back(x,y);
|
||||
size += 2 * 8; // point
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,23 +26,18 @@
|
|||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/unique_lock.hpp>
|
||||
|
||||
// boost
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
// stl
|
||||
#include <stdexcept> // std::runtime_error
|
||||
#include <cstdlib> // std::atexit
|
||||
#include <new> // operator new
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
using std::mutex;
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
class CreateUsingNew
|
||||
{
|
||||
|
@ -119,7 +114,7 @@ template <typename T,
|
|||
protected:
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
static mutex mutex_;
|
||||
static std::mutex mutex_;
|
||||
#endif
|
||||
singleton() {}
|
||||
public:
|
||||
|
@ -152,7 +147,7 @@ protected:
|
|||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
template <typename T,
|
||||
template <typename U> class CreatePolicy> mutex singleton<T,CreatePolicy>::mutex_;
|
||||
template <typename U> class CreatePolicy> std::mutex singleton<T,CreatePolicy>::mutex_;
|
||||
#endif
|
||||
|
||||
template <typename T,
|
||||
|
|
|
@ -29,12 +29,8 @@
|
|||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant/recursive_wrapper.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include "hash_variant.hpp"
|
||||
|
||||
|
@ -42,6 +38,9 @@
|
|||
#include <string>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
// icu
|
||||
#include <unicode/unistr.h>
|
||||
|
@ -122,7 +121,7 @@ struct equals
|
|||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator() (T const& /*lhs*/, U const& /*rhs*/) const
|
||||
bool operator() (T const&, U const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -182,9 +181,8 @@ struct not_equals
|
|||
// back compatibility shim to equate empty string with null for != test
|
||||
// https://github.com/mapnik/mapnik/issues/1859
|
||||
// TODO - consider removing entire specialization at Mapnik 3.x
|
||||
bool operator() (value_null lhs, value_unicode_string const& rhs) const
|
||||
bool operator() (value_null, value_unicode_string const& rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
if (rhs.isEmpty()) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -357,15 +355,13 @@ struct add : public boost::static_visitor<V>
|
|||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs, value_null rhs) const
|
||||
value_type operator() (value_unicode_string const& lhs, value_null) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_null lhs, value_unicode_string const& rhs) const
|
||||
value_type operator() (value_null, value_unicode_string const& rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
return rhs;
|
||||
}
|
||||
|
||||
|
@ -421,11 +417,9 @@ struct sub : public boost::static_visitor<V>
|
|||
return lhs - rhs ;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
value_type operator() (value_unicode_string const&,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return value_type();
|
||||
}
|
||||
|
||||
|
@ -460,11 +454,9 @@ struct mult : public boost::static_visitor<V>
|
|||
return lhs * rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
value_type operator() (value_unicode_string const&,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return value_type();
|
||||
}
|
||||
|
||||
|
@ -478,10 +470,8 @@ struct mult : public boost::static_visitor<V>
|
|||
return lhs * rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
value_type operator() (value_bool, value_bool) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
@ -503,18 +493,14 @@ struct div: public boost::static_visitor<V>
|
|||
return lhs / rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
value_type operator() (value_bool, value_bool) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return false;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
value_type operator() (value_unicode_string const&,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return value_type();
|
||||
}
|
||||
|
||||
|
@ -547,19 +533,15 @@ struct mod: public boost::static_visitor<V>
|
|||
return lhs % rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
value_type operator() (value_unicode_string const&,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return value_type();
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs,
|
||||
value_bool rhs) const
|
||||
value_type operator() (value_bool,
|
||||
value_bool) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -600,9 +582,8 @@ struct negate : public boost::static_visitor<V>
|
|||
return val ? value_integer(-1) : value_integer(0);
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& ustr) const
|
||||
value_type operator() (value_unicode_string const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(ustr);
|
||||
return value_type();
|
||||
}
|
||||
};
|
||||
|
@ -624,9 +605,8 @@ struct convert<value_bool> : public boost::static_visitor<value_bool>
|
|||
return !ustr.isEmpty();
|
||||
}
|
||||
|
||||
value_bool operator() (value_null const& val) const
|
||||
value_bool operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -670,9 +650,8 @@ struct convert<value_double> : public boost::static_visitor<value_double>
|
|||
return operator()(utf8);
|
||||
}
|
||||
|
||||
value_double operator() (value_null const& val) const
|
||||
value_double operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return 0.0;
|
||||
}
|
||||
};
|
||||
|
@ -710,9 +689,8 @@ struct convert<value_integer> : public boost::static_visitor<value_integer>
|
|||
return operator()(utf8);
|
||||
}
|
||||
|
||||
value_integer operator() (value_null const& val) const
|
||||
value_integer operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
@ -743,9 +721,8 @@ struct convert<std::string> : public boost::static_visitor<std::string>
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string operator() (value_null const& val) const
|
||||
std::string operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
@ -774,9 +751,8 @@ struct to_unicode : public boost::static_visitor<value_unicode_string>
|
|||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
|
||||
value_unicode_string operator() (value_null const& val) const
|
||||
value_unicode_string operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return value_unicode_string("");
|
||||
}
|
||||
};
|
||||
|
@ -809,9 +785,8 @@ struct to_expression_string : public boost::static_visitor<std::string>
|
|||
return val ? "true":"false";
|
||||
}
|
||||
|
||||
std::string operator() (value_null const& val) const
|
||||
std::string operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return "null";
|
||||
}
|
||||
};
|
||||
|
@ -980,7 +955,8 @@ operator << (std::basic_ostream<charT,traits>& out,
|
|||
return out;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(const value& val) {
|
||||
inline std::size_t hash_value(value const& val)
|
||||
{
|
||||
return hash_value(val.base());
|
||||
}
|
||||
|
||||
|
@ -998,16 +974,14 @@ struct is_null : public boost::static_visitor<bool>
|
|||
return val.is_null();
|
||||
}
|
||||
|
||||
bool operator() (value_null const& val) const
|
||||
bool operator() (value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T const& val) const
|
||||
bool operator() (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,14 +23,19 @@
|
|||
#ifndef MAPNIK_VALUE_TYPES_HPP
|
||||
#define MAPNIK_VALUE_TYPES_HPP
|
||||
|
||||
// icu
|
||||
#include <unicode/unistr.h> // for UnicodeString
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/concept_check.hpp>
|
||||
// icu
|
||||
#include <unicode/uversion.h> // for U_NAMESPACE_QUALIFIER
|
||||
|
||||
// stl
|
||||
#include <iosfwd> // for ostream
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
|
||||
namespace U_ICU_NAMESPACE {
|
||||
class UnicodeString;
|
||||
}
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -45,84 +50,73 @@ using value_double = double;
|
|||
using value_unicode_string = U_NAMESPACE_QUALIFIER UnicodeString;
|
||||
using value_bool = bool;
|
||||
|
||||
struct value_null
|
||||
struct MAPNIK_DECL value_null
|
||||
{
|
||||
bool operator==(value_null const& other) const
|
||||
bool operator==(value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(T const& other) const
|
||||
bool operator==(T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator!=(value_null const& other) const
|
||||
bool operator!=(value_null const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(T const& other) const
|
||||
bool operator!=(T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator+ (T const& other) const
|
||||
value_null operator+ (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator- (T const& other) const
|
||||
value_null operator- (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator* (T const& other) const
|
||||
value_null operator* (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator/ (T const& other) const
|
||||
value_null operator/ (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator% (T const& other) const
|
||||
value_null operator% (T const&) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::size_t hash_value(const value_null& val)
|
||||
inline std::size_t hash_value(value_null const&)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream & out,value_null const& v)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
template <typename TChar, typename TTraits>
|
||||
inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, value_null const& v) {
|
||||
return out;
|
||||
}
|
||||
inline std::istream& operator>> ( std::istream & s, value_null & null )
|
||||
|
||||
inline std::istream& operator>> ( std::istream & s, value_null & )
|
||||
{
|
||||
boost::ignore_unused_variable_warning(null);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef MAPNIK_VERTEX_HPP
|
||||
#define MAPNIK_VERTEX_HPP
|
||||
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -103,43 +103,6 @@ private:
|
|||
using vertex2d = vertex<double,2>;
|
||||
using vertex2i = vertex<int,2>;
|
||||
|
||||
template <class charT,class traits,class T,int dim>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const vertex<T,dim>& c);
|
||||
|
||||
template <class charT,class traits,class T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const vertex<T,2>& v)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
switch (v.cmd)
|
||||
{
|
||||
case SEG_END: s << "End "; break;
|
||||
case SEG_MOVETO: s << "MoveTo "; break;
|
||||
case SEG_LINETO: s << "LineTo "; break;
|
||||
case SEG_CLOSE: s << "Close "; break;
|
||||
}
|
||||
s << "(" << v.x << ", " << v.y << ")";
|
||||
return out << s.str();
|
||||
}
|
||||
|
||||
template <class charT,class traits,class T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const vertex<T,3>& v)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s<<"vertex3("<<v.x<<","<<v.y<<","<<v.z<<",cmd="<<v.cmd<<")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_VERTEX_HPP
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/ctrans.hpp>
|
||||
#include <mapnik/offset_converter.hpp>
|
||||
#include <mapnik/simplify.hpp>
|
||||
#include <mapnik/simplify_converter.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
|
|
@ -30,17 +30,16 @@
|
|||
// webp
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
extern "C"
|
||||
{
|
||||
#include <webp/encode.h>
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
// boost
|
||||
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -194,7 +194,7 @@ struct do_xml_attribute_cast<mapnik::expression_ptr>
|
|||
else
|
||||
{
|
||||
mapnik::expression_ptr expr = parse_expression(source);
|
||||
tree.expr_cache_.insert(std::make_pair(source,expr));
|
||||
tree.expr_cache_.emplace(source,expr);
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
|
||||
#include <gdal_version.h>
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
}
|
||||
else
|
||||
{
|
||||
MAPNIK_LOG_ERROR(gdal) << "warning: nodata value (" << raster_nodata << ") used to set transparency instead of alpha band";
|
||||
MAPNIK_LOG_WARN(gdal) << "warning: nodata value (" << raster_nodata << ") used to set transparency instead of alpha band";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ processor_context_ptr postgis_datasource::get_context(feature_style_context_map
|
|||
}
|
||||
else
|
||||
{
|
||||
return ctx.insert(std::make_pair(ds_name,std::make_shared<postgis_processor_context>())).first->second;
|
||||
return ctx.emplace(ds_name,std::make_shared<postgis_processor_context>()).first->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ python_datasource::python_datasource(parameters const& params)
|
|||
{
|
||||
if((kv.first != "type") && (kv.first != "factory"))
|
||||
{
|
||||
kwargs_.insert(std::make_pair(kv.first, *params.get<std::string>(kv.first)));
|
||||
kwargs_.emplace(kv.first, *params.get<std::string>(kv.first));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -502,39 +502,6 @@ void agg_renderer<T0,T1>::draw_geo_extent(box2d<double> const& extent, mapnik::c
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr)
|
||||
{
|
||||
using pixfmt = agg::pixfmt_rgba32_pre;
|
||||
using renderer_base = agg::renderer_base<pixfmt>;
|
||||
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
//double width = marker.width();
|
||||
//double height = marker.height();
|
||||
|
||||
mapnik::box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box() * tr;
|
||||
mapnik::coord<double,2> c = bbox.center();
|
||||
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
||||
mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height());
|
||||
mtx = tr * mtx;
|
||||
|
||||
std::shared_ptr<mapnik::image_data_32> image = std::make_shared<mapnik::image_data_32>(bbox.width(), bbox.height());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4);
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage((*marker.get_vector_data())->source());
|
||||
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
||||
mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes>,
|
||||
renderer_solid,
|
||||
agg::pixfmt_rgba32_pre > svg_renderer(svg_path,
|
||||
(*marker.get_vector_data())->attributes());
|
||||
|
||||
svg_renderer.render(ras, sl, renb, mtx, 1.0, bbox);
|
||||
return image;
|
||||
}
|
||||
|
||||
template class agg_renderer<image_32>;
|
||||
template void agg_renderer<image_32>::debug_draw_box<agg::rendering_buffer>(
|
||||
agg::rendering_buffer& buf,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/renderer_common/process_group_symbolizer.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
// agg
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
|
@ -106,7 +106,7 @@ void agg_renderer<T0,T1>::process(group_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
render_group_symbolizer(
|
||||
sym, feature, common_.vars_, prj_trans, clipping_extent(), common_,
|
||||
sym, feature, common_.vars_, prj_trans, clipping_extent(common_), common_,
|
||||
[&](render_thunk_list const& thunks, pixel_position const& render_offset)
|
||||
{
|
||||
thunk_renderer ren(*this, current_buffer_, common_, render_offset);
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include <mapnik/vertex_converters.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
#include <mapnik/renderer_common/render_pattern.hpp>
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
|
@ -105,6 +106,8 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
boost::optional<mapnik::marker_ptr> marker_ptr = marker_cache::instance().find(filename, true);
|
||||
if (!marker_ptr || !(*marker_ptr)) return;
|
||||
boost::optional<image_ptr> pat;
|
||||
// TODO - re-implement at renderer level like polygon_pattern symbolizer
|
||||
double opacity = get<value_double>(sym, keys::opacity, feature, common_.vars_,1.0);
|
||||
if ((*marker_ptr)->is_bitmap())
|
||||
{
|
||||
pat = (*marker_ptr)->get_bitmap_data();
|
||||
|
@ -114,13 +117,12 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
|
||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||
if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr, opacity);
|
||||
}
|
||||
|
||||
if (!pat) return;
|
||||
|
||||
bool clip = get<value_bool>(sym, keys::clip, feature, common_.vars_, false);
|
||||
//double opacity = get<value_double>(sym,keys::stroke_opacity,feature, 1.0); TODO
|
||||
double offset = get<value_double>(sym, keys::offset, feature, common_.vars_, 0.0);
|
||||
double simplify_tolerance = get<value_double>(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0);
|
||||
double smooth = get<value_double>(sym, keys::smooth, feature, common_.vars_, false);
|
||||
|
@ -140,7 +142,7 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/pixmap_.width());
|
||||
|
@ -153,7 +155,10 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
clip_box.pad(padding);
|
||||
}
|
||||
|
||||
using conv_types = boost::mpl::vector<clip_line_tag,transform_tag,offset_transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
|
||||
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
|
||||
affine_transform_tag,
|
||||
simplify_tag,smooth_tag,
|
||||
offset_transform_tag>;
|
||||
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl>
|
||||
converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -130,7 +130,7 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
|
|||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
bool clip = get<value_bool>(sym, keys::clip, feature, common_.vars_, false);
|
||||
double width = get<value_double>(sym, keys::stroke_width, feature, common_.vars_, 1.0);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/renderer_common/process_markers_symbolizer.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_renderer_base.h"
|
||||
|
@ -90,7 +90,7 @@ void agg_renderer<T0,T1>::process(markers_symbolizer const& sym,
|
|||
}
|
||||
|
||||
buf_type render_buffer(current_buffer_->raw_data(), current_buffer_->width(), current_buffer_->height(), current_buffer_->width() * 4);
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
auto renderer_context = std::tie(render_buffer,*ras_ptr,pixmap_);
|
||||
using context_type = decltype(renderer_context);
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#include <mapnik/svg/svg_converter.hpp>
|
||||
#include <mapnik/svg/svg_renderer_agg.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
#include <mapnik/renderer_common/render_pattern.hpp>
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -73,7 +74,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
|
|||
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
|
||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||
if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr, 1.0);
|
||||
}
|
||||
|
||||
if (!pat) return;
|
||||
|
@ -98,7 +99,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
|
|||
double simplify_tolerance = get<value_double>(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0);
|
||||
double smooth = get<value_double>(sym, keys::smooth, feature, common_.vars_, false);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
using color = agg::rgba8;
|
||||
using order = agg::order_rgba;
|
||||
|
@ -128,7 +129,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
|
|||
agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf);
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
||||
pattern_alignment_enum alignment = get<pattern_alignment_enum>(sym, keys::alignment, feature, common_.vars_, LOCAL_ALIGNMENT);
|
||||
pattern_alignment_enum alignment = get<pattern_alignment_enum>(sym, keys::alignment, feature, common_.vars_, GLOBAL_ALIGNMENT);
|
||||
unsigned offset_x=0;
|
||||
unsigned offset_y=0;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
#include <mapnik/renderer_common/process_polygon_symbolizer.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -64,7 +64,7 @@ void agg_renderer<T0,T1>::process(polygon_symbolizer const& sym,
|
|||
gamma_ = gamma;
|
||||
}
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
|
||||
render_polygon_symbolizer<vertex_converter_type>(
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <mapnik/text/symbolizer_helpers.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/text/renderer.hpp>
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -36,13 +37,16 @@ void agg_renderer<T0,T1>::process(shield_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
agg::trans_affine tr;
|
||||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
text_symbolizer_helper helper(
|
||||
sym, feature, common_.vars_, prj_trans,
|
||||
common_.width_, common_.height_,
|
||||
common_.scale_factor_,
|
||||
common_.t_, common_.font_manager_, *common_.detector_,
|
||||
clip_box);
|
||||
clip_box, tr);
|
||||
|
||||
halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature, common_.vars_, HALO_RASTERIZER_FULL);
|
||||
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/text/symbolizer_helpers.hpp>
|
||||
#include <mapnik/text/renderer.hpp>
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -36,13 +37,16 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
agg::trans_affine tr;
|
||||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
text_symbolizer_helper helper(
|
||||
sym, feature, common_.vars_, prj_trans,
|
||||
common_.width_, common_.height_,
|
||||
common_.scale_factor_,
|
||||
common_.t_, common_.font_manager_, *common_.detector_,
|
||||
clip_box);
|
||||
clip_box, tr);
|
||||
|
||||
halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer,feature, common_.vars_, HALO_RASTERIZER_FULL);
|
||||
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
|
||||
|
@ -54,6 +58,7 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
|
|||
common_.scale_factor_,
|
||||
common_.font_manager_.get_stroker());
|
||||
|
||||
{ // halo transform
|
||||
agg::trans_affine halo_transform;
|
||||
auto transform = get_optional<transform_type>(sym, keys::halo_transform);
|
||||
if (transform)
|
||||
|
@ -61,6 +66,8 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
|
|||
evaluate_transform(halo_transform, feature, common_.vars_, *transform);
|
||||
ren.set_halo_transform(halo_transform);
|
||||
}
|
||||
}
|
||||
|
||||
placements_list const& placements = helper.get();
|
||||
for (glyph_positions_ptr glyphs : placements)
|
||||
{
|
||||
|
|
18
src/build.py
18
src/build.py
|
@ -168,7 +168,6 @@ source = Split(
|
|||
feature_type_style.cpp
|
||||
font_engine_freetype.cpp
|
||||
font_set.cpp
|
||||
gamma_method.cpp
|
||||
gradient.cpp
|
||||
graphics.cpp
|
||||
parse_path.cpp
|
||||
|
@ -231,6 +230,7 @@ source = Split(
|
|||
config_error.cpp
|
||||
color_factory.cpp
|
||||
renderer_common.cpp
|
||||
renderer_common/render_pattern.cpp
|
||||
renderer_common/process_group_symbolizer.cpp
|
||||
"""
|
||||
)
|
||||
|
@ -272,8 +272,20 @@ if env['HAS_CAIRO']:
|
|||
lib_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
||||
libmapnik_defines.append('-DHAVE_CAIRO')
|
||||
lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
|
||||
source.insert(0,'cairo/cairo_renderer.cpp')
|
||||
source.insert(0,'cairo/cairo_context.cpp')
|
||||
source.append('cairo/cairo_context.cpp')
|
||||
source.append('cairo/cairo_renderer.cpp')
|
||||
source.append('cairo/cairo_render_vector.cpp')
|
||||
source.append('cairo/process_markers_symbolizer.cpp')
|
||||
source.append('cairo/process_text_symbolizer.cpp')
|
||||
source.append('cairo/process_group_symbolizer.cpp')
|
||||
source.append('cairo/process_line_symbolizer.cpp')
|
||||
source.append('cairo/process_line_pattern_symbolizer.cpp')
|
||||
source.append('cairo/process_polygon_symbolizer.cpp')
|
||||
source.append('cairo/process_polygon_pattern_symbolizer.cpp')
|
||||
source.append('cairo/process_debug_symbolizer.cpp')
|
||||
source.append('cairo/process_point_symbolizer.cpp')
|
||||
source.append('cairo/process_raster_symbolizer.cpp')
|
||||
source.append('cairo/process_building_symbolizer.cpp')
|
||||
|
||||
for cpp in enabled_imaging_libraries:
|
||||
source.append(cpp)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -179,6 +179,9 @@ void cairo_context::set_operator(composite_mode_e comp_op)
|
|||
case saturation:
|
||||
case _color:
|
||||
case _value:
|
||||
case linear_dodge:
|
||||
case linear_burn:
|
||||
case divide:
|
||||
//case colorize_alpha:
|
||||
break;
|
||||
}
|
||||
|
@ -522,9 +525,8 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face)
|
|||
else
|
||||
{
|
||||
entry = std::make_shared<cairo_face>(font_engine_, face);
|
||||
cache_.insert(std::make_pair(face, entry));
|
||||
cache_.emplace(face, entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
131
src/cairo/cairo_render_vector.cpp
Normal file
131
src/cairo/cairo_render_vector.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
#include <mapnik/cairo/cairo_render_vector.hpp>
|
||||
#include <mapnik/cairo/cairo_context.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
void render_vector_marker(cairo_context & context, pixel_position const& pos,
|
||||
svg::svg_path_adapter & svg_path, box2d<double> const& bbox,
|
||||
agg::pod_bvector<svg::path_attributes> const & attributes,
|
||||
agg::trans_affine const& tr, double opacity, bool recenter)
|
||||
{
|
||||
using namespace mapnik::svg;
|
||||
agg::trans_affine mtx = tr;
|
||||
if (recenter)
|
||||
{
|
||||
coord<double,2> c = bbox.center();
|
||||
mtx = agg::trans_affine_translation(-c.x,-c.y);
|
||||
mtx *= tr;
|
||||
mtx.translate(pos.x, pos.y);
|
||||
}
|
||||
|
||||
agg::trans_affine transform;
|
||||
|
||||
for(unsigned i = 0; i < attributes.size(); ++i)
|
||||
{
|
||||
mapnik::svg::path_attributes const& attr = attributes[i];
|
||||
if (!attr.visibility_flag)
|
||||
continue;
|
||||
cairo_save_restore guard(context);
|
||||
transform = attr.transform;
|
||||
transform *= mtx;
|
||||
|
||||
// TODO - this 'is_valid' check is not used in the AGG renderer and also
|
||||
// appears to lead to bogus results with
|
||||
// tests/data/good_maps/markers_symbolizer_lines_file.xml
|
||||
//if (transform.is_valid() && !transform.is_identity())
|
||||
if (!transform.is_identity())
|
||||
{
|
||||
double m[6];
|
||||
transform.store_to(m);
|
||||
cairo_matrix_t matrix;
|
||||
cairo_matrix_init(&matrix,m[0],m[1],m[2],m[3],m[4],m[5]);
|
||||
context.transform(matrix);
|
||||
}
|
||||
|
||||
if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
context.add_agg_path(svg_path,attr.index);
|
||||
if (attr.even_odd_flag)
|
||||
{
|
||||
context.set_fill_rule(CAIRO_FILL_RULE_EVEN_ODD);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.set_fill_rule(CAIRO_FILL_RULE_WINDING);
|
||||
}
|
||||
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
cairo_gradient g(attr.fill_gradient,attr.fill_opacity * attr.opacity * opacity);
|
||||
|
||||
context.set_gradient(g,bbox);
|
||||
context.fill();
|
||||
}
|
||||
else if(attr.fill_flag)
|
||||
{
|
||||
double fill_opacity = attr.fill_opacity * attr.opacity * opacity * attr.fill_color.opacity();
|
||||
context.set_color(attr.fill_color.r/255.0,attr.fill_color.g/255.0,
|
||||
attr.fill_color.b/255.0, fill_opacity);
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
|
||||
if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT || attr.stroke_flag)
|
||||
{
|
||||
context.add_agg_path(svg_path,attr.index);
|
||||
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
context.set_line_width(attr.stroke_width);
|
||||
context.set_line_cap(line_cap_enum(attr.line_cap));
|
||||
context.set_line_join(line_join_enum(attr.line_join));
|
||||
context.set_miter_limit(attr.miter_limit);
|
||||
cairo_gradient g(attr.stroke_gradient,attr.fill_opacity * attr.opacity * opacity);
|
||||
context.set_gradient(g,bbox);
|
||||
context.stroke();
|
||||
}
|
||||
else if (attr.stroke_flag)
|
||||
{
|
||||
double stroke_opacity = attr.stroke_opacity * attr.opacity * opacity * attr.stroke_color.opacity();
|
||||
context.set_color(attr.stroke_color.r/255.0,attr.stroke_color.g/255.0,
|
||||
attr.stroke_color.b/255.0, stroke_opacity);
|
||||
context.set_line_width(attr.stroke_width);
|
||||
context.set_line_cap(line_cap_enum(attr.line_cap));
|
||||
context.set_line_join(line_join_enum(attr.line_join));
|
||||
context.set_miter_limit(attr.miter_limit);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_CAIRO
|
File diff suppressed because it is too large
Load diff
84
src/cairo/process_building_symbolizer.cpp
Normal file
84
src/cairo/process_building_symbolizer.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
// mapnik symbolizer generics
|
||||
#include <mapnik/renderer_common/process_building_symbolizer.hpp>
|
||||
|
||||
// stl
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
void cairo_renderer<T>::process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
using path_type = coord_transform<CoordTransform,geometry_type>;
|
||||
cairo_save_restore guard(context_);
|
||||
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
|
||||
mapnik::color fill = get<mapnik::color>(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128));
|
||||
double opacity = get<double>(sym, keys::fill_opacity, feature, common_.vars_, 1.0);
|
||||
double height = get<double>(sym, keys::height, feature, common_.vars_, 0.0);
|
||||
|
||||
context_.set_operator(comp_op);
|
||||
|
||||
render_building_symbolizer(
|
||||
feature, height,
|
||||
[&](geometry_type &faces) {
|
||||
path_type faces_path(common_.t_, faces, prj_trans);
|
||||
context_.set_color(fill.red() * 0.8 / 255.0, fill.green() * 0.8 / 255.0,
|
||||
fill.blue() * 0.8 / 255.0, fill.alpha() * opacity / 255.0);
|
||||
context_.add_path(faces_path);
|
||||
context_.fill();
|
||||
},
|
||||
[&](geometry_type &frame) {
|
||||
path_type path(common_.t_, frame, prj_trans);
|
||||
context_.set_color(fill.red() * 0.8 / 255.0, fill.green() * 0.8/255.0,
|
||||
fill.blue() * 0.8 / 255.0, fill.alpha() * opacity / 255.0);
|
||||
context_.set_line_width(common_.scale_factor_);
|
||||
context_.add_path(path);
|
||||
context_.stroke();
|
||||
},
|
||||
[&](geometry_type &roof) {
|
||||
path_type roof_path(common_.t_, roof, prj_trans);
|
||||
context_.set_color(fill, opacity);
|
||||
context_.add_path(roof_path);
|
||||
context_.fill();
|
||||
});
|
||||
}
|
||||
|
||||
template void cairo_renderer<cairo_ptr>::process(building_symbolizer const&,
|
||||
mapnik::feature_impl &,
|
||||
proj_transform const&);
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_CAIRO
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue