sync with master
|
@ -8,6 +8,10 @@ For a complete change history, see the git log.
|
|||
|
||||
## Future
|
||||
|
||||
- Added to python bindings: `has_tiff`, `has_png`, `has_webp`, `has_proj4`, `has_svg_renderer`, and `has_grid_renderer`
|
||||
|
||||
- Made it possible to disable compilation of `grid_renderer` with `./configure GRID_RENDERER=False` (#1962)
|
||||
|
||||
- Added `webp` image encoding and decoding support (#1955)
|
||||
|
||||
- Added `premultiplied` property on mapnik::image_32 / mapnik.Image to enable knowledge of premultiplied status of image buffer.
|
||||
|
|
|
@ -336,6 +336,7 @@ opts.AddVariables(
|
|||
|
||||
# Variables affecting rendering back-ends
|
||||
|
||||
BoolVariable('GRID_RENDERER', 'build support for native grid renderer', 'True'),
|
||||
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
|
||||
BoolVariable('CPP_TESTS', 'Compile the C++ tests', 'True'),
|
||||
BoolVariable('BENCHMARK', 'Compile the C++ benchmark scripts', 'False'),
|
||||
|
@ -454,6 +455,7 @@ pickle_store = [# Scons internal variables
|
|||
'CAIRO_LIBPATHS',
|
||||
'CAIRO_ALL_LIBS',
|
||||
'CAIRO_CPPPATHS',
|
||||
'GRID_RENDERER',
|
||||
'SVG_RENDERER',
|
||||
'SQLITE_LINKFLAGS',
|
||||
'BOOST_LIB_VERSION_FROM_HEADER',
|
||||
|
|
|
@ -266,7 +266,7 @@ struct test5
|
|||
s.resize(s.capacity());
|
||||
while (true)
|
||||
{
|
||||
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val_));
|
||||
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val));
|
||||
if (n2 <= s.size())
|
||||
{
|
||||
s.resize(n2);
|
||||
|
|
|
@ -46,6 +46,8 @@ target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.pa
|
|||
py_env = env.Clone()
|
||||
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
|
||||
|
||||
py_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||
|
||||
py_env['LIBS'] = ['mapnik',env['BOOST_PYTHON_LIB']]
|
||||
|
||||
link_all_libs = env['LINKING'] == 'static' or env['RUNTIME_LINK'] == 'static' or (env['PLATFORM'] == 'Darwin' and not env['PYTHON_DYNAMIC_LOOKUP'])
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/module.hpp>
|
||||
|
@ -80,3 +82,5 @@ void export_grid()
|
|||
;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/module.hpp>
|
||||
|
@ -49,3 +51,5 @@ void export_grid_view()
|
|||
)
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -91,17 +91,6 @@ mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x
|
|||
return m.query_map_point(idx, x, y);
|
||||
}
|
||||
|
||||
// deepcopy
|
||||
/*
|
||||
mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo)
|
||||
{
|
||||
// FIXME: ignore memo for now
|
||||
mapnik::Map result;
|
||||
mapnik::util::deepcopy(m, result);
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
|
||||
{
|
||||
if (box)
|
||||
|
|
|
@ -41,8 +41,10 @@ void export_image();
|
|||
void export_image_view();
|
||||
void export_gamma_method();
|
||||
void export_scaling_method();
|
||||
#if defined(GRID_RENDERER)
|
||||
void export_grid();
|
||||
void export_grid_view();
|
||||
#endif
|
||||
void export_map();
|
||||
void export_python();
|
||||
void export_expression();
|
||||
|
@ -92,7 +94,9 @@ void export_logger();
|
|||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/save_map.hpp>
|
||||
#include <mapnik/scale_denominator.hpp>
|
||||
#if defined(GRID_RENDERER)
|
||||
#include "python_grid_utils.hpp"
|
||||
#endif
|
||||
#include "mapnik_value_converter.hpp"
|
||||
#include "mapnik_threads.hpp"
|
||||
#include "python_optional.hpp"
|
||||
|
@ -366,7 +370,33 @@ std::string mapnik_version_string()
|
|||
return MAPNIK_VERSION_STRING;
|
||||
}
|
||||
|
||||
// indicator for jpeg read/write support within libmapnik
|
||||
bool has_proj4()
|
||||
{
|
||||
#if defined(MAPNIK_USE_PROJ4)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_svg_renderer()
|
||||
{
|
||||
#if defined(SVG_RENDERER)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_grid_renderer()
|
||||
{
|
||||
#if defined(GRID_RENDERER)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_jpeg()
|
||||
{
|
||||
#if defined(HAVE_JPEG)
|
||||
|
@ -376,6 +406,33 @@ bool has_jpeg()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool has_png()
|
||||
{
|
||||
#if defined(HAVE_PNG)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_tiff()
|
||||
{
|
||||
#if defined(HAVE_TIFF)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_webp()
|
||||
{
|
||||
#if defined(HAVE_WEBP)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// indicator for cairo rendering support inside libmapnik
|
||||
bool has_cairo()
|
||||
{
|
||||
|
@ -427,7 +484,6 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
using mapnik::load_map_string;
|
||||
using mapnik::save_map;
|
||||
using mapnik::save_map_to_string;
|
||||
using mapnik::render_grid;
|
||||
|
||||
register_exception_translator<std::exception>(&standard_error_translator);
|
||||
register_exception_translator<std::out_of_range>(&out_of_range_error_translator);
|
||||
|
@ -448,8 +504,10 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
export_image_view();
|
||||
export_gamma_method();
|
||||
export_scaling_method();
|
||||
#if defined(GRID_RENDERER)
|
||||
export_grid();
|
||||
export_grid_view();
|
||||
#endif
|
||||
export_expression();
|
||||
export_rule();
|
||||
export_style();
|
||||
|
@ -487,7 +545,8 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
">>> clear_cache()\n"
|
||||
);
|
||||
|
||||
def("render_grid",&render_grid,
|
||||
#if defined(GRID_RENDERER)
|
||||
def("render_grid",&mapnik::render_grid,
|
||||
( arg("map"),
|
||||
arg("layer"),
|
||||
args("key")="__id__",
|
||||
|
@ -495,6 +554,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
arg("fields")=boost::python::list()
|
||||
)
|
||||
);
|
||||
#endif
|
||||
|
||||
def("render_to_file",&render_to_file1,
|
||||
"\n"
|
||||
|
@ -579,9 +639,11 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
(arg("map"),arg("image"),args("layer"))
|
||||
);
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
def("render_layer", &mapnik::render_layer_for_grid,
|
||||
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
|
||||
);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
def("render",&render3,
|
||||
|
@ -739,7 +801,12 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
|
||||
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
|
||||
def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string");
|
||||
def("has_proj4", &has_proj4, "Get proj4 status");
|
||||
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
|
||||
def("has_png", &has_png, "Get png read/write support status");
|
||||
def("has_tiff", &has_jpeg, "Get tiff read/write support status");
|
||||
def("has_webp", &has_jpeg, "Get webp read/write support status");
|
||||
def("has_grid_renderer", &has_grid_renderer, "Get grid_renderer status");
|
||||
def("has_cairo", &has_cairo, "Get cairo library status");
|
||||
def("has_pycairo", &has_pycairo, "Get pycairo module status");
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
@ -472,3 +474,5 @@ boost::python::dict render_grid(mapnik::Map const& map,
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -228,7 +228,7 @@ public:
|
|||
: boost::python::class_<T, X1, X2, X3>(name, doc, i) { }
|
||||
|
||||
template <class D>
|
||||
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
|
||||
self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0)
|
||||
{
|
||||
this->add_property(name,
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
|
|
|
@ -34,6 +34,7 @@ demo_env = env.Clone()
|
|||
|
||||
|
||||
demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
|
||||
demo_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||
|
||||
if env['HAS_CAIRO']:
|
||||
demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS'])
|
||||
|
|
2
deps/agg/include/agg_pixfmt_rgba.h
vendored
|
@ -134,7 +134,7 @@ namespace agg
|
|||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned cr, unsigned cg, unsigned cb,
|
||||
unsigned alpha,
|
||||
unsigned cover=0)
|
||||
unsigned /*cover*/=0)
|
||||
{
|
||||
calc_type r = p[Order::R];
|
||||
calc_type g = p[Order::G];
|
||||
|
|
|
@ -9,6 +9,9 @@ subdirs = ['','svg','wkt','grid','json','util','text_placements','formatting','s
|
|||
if env['SVG_RENDERER']:
|
||||
subdirs.append('svg/output')
|
||||
|
||||
if env['GRID_RENDERER']:
|
||||
subdirs.append('grid')
|
||||
|
||||
if 'install' in COMMAND_LINE_TARGETS:
|
||||
for subdir in subdirs:
|
||||
pathdir = os.path.join(base,subdir,'*.hpp')
|
||||
|
|
|
@ -25,17 +25,12 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/gamma_method.hpp>
|
||||
#include <mapnik/stroke.hpp>
|
||||
#include <mapnik/stroke.hpp> // for line_cap_e, line_join_e, etc
|
||||
|
||||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_gamma_functions.h"
|
||||
#include "agg_math_stroke.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_scanline_p.h"
|
||||
#include "agg_renderer_outline_aa.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_gamma_functions.h" // for gamma_power, gamma_linear, etc
|
||||
#include "agg_math_stroke.h" // for line_join_e::miter_join, etc
|
||||
#include "agg_rasterizer_outline_aa.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include <mapnik/text_placements/base.hpp> // for text_placements
|
||||
|
||||
// boost
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
|
||||
|
@ -62,12 +61,11 @@ struct expression_attributes : boost::static_visitor<void>
|
|||
explicit expression_attributes(Container& names)
|
||||
: names_(names) {}
|
||||
|
||||
void operator() (value_type const& x) const
|
||||
void operator() (value_type const& /*x*/) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(x);
|
||||
}
|
||||
|
||||
void operator() (geometry_type_attribute const& type) const
|
||||
void operator() (geometry_type_attribute const& /*type*/) const
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef cairo_status_t ErrorStatus;
|
|||
/// Throws the appropriate exception, if exceptions are enabled.
|
||||
inline void throw_exception(ErrorStatus status)
|
||||
{
|
||||
throw std::runtime_error("cairo: fixme");
|
||||
throw std::runtime_error(std::string("cairo: ") + cairo_status_to_string(status));
|
||||
}
|
||||
|
||||
//We inline this because it is called so often.
|
||||
|
@ -70,7 +70,7 @@ inline void check_status_and_throw_exception(ErrorStatus status)
|
|||
}
|
||||
|
||||
template<class T>
|
||||
void check_object_status_and_throw_exception(const T& object)
|
||||
void check_object_status_and_throw_exception(T const& object)
|
||||
{
|
||||
check_status_and_throw_exception(object.get_status());
|
||||
}
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
// boost
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
// FIXME
|
||||
// forward declare so that
|
||||
// apps using mapnik do not
|
||||
// need agg headers
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace mapnik {
|
|||
public:
|
||||
typedef std::basic_ostringstream<Ch, Tr, A> stream_buffer;
|
||||
|
||||
void operator()(const logger::severity_type& severity, const stream_buffer &s)
|
||||
void operator()(const logger::severity_type& /*severity*/, const stream_buffer &s)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
static boost::mutex mutex;
|
||||
|
@ -193,15 +193,19 @@ namespace mapnik {
|
|||
|
||||
base_log() {}
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
base_log(const char* object_name)
|
||||
{
|
||||
#ifdef MAPNIK_LOG
|
||||
if (object_name != NULL)
|
||||
{
|
||||
object_name_ = object_name;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
base_log(const char* /*object_name*/)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
~base_log()
|
||||
{
|
||||
|
@ -214,13 +218,20 @@ namespace mapnik {
|
|||
}
|
||||
|
||||
template<class T>
|
||||
#ifdef MAPNIK_LOG
|
||||
base_log &operator<<(const T &x)
|
||||
{
|
||||
#ifdef MAPNIK_LOG
|
||||
|
||||
streambuf_ << x;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
base_log &operator<<(const T& /*x*/)
|
||||
{
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef MAPNIK_LOG
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
@ -74,11 +73,8 @@ template <> // No-op specialization
|
|||
struct process_impl<false>
|
||||
{
|
||||
template <typename T0, typename T1, typename T2, typename T3>
|
||||
static void process(T0 & ren, T1 const& sym, T2 & f, T3 const& tr)
|
||||
static void process(T0 & /*ren*/, T1 const& /*sym*/, T2 & /*f*/, T3 const& /*tr*/)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(ren);
|
||||
boost::ignore_unused_variable_warning(f);
|
||||
boost::ignore_unused_variable_warning(tr);
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "NO-OP ...\n";
|
||||
#endif
|
||||
|
|
|
@ -137,59 +137,6 @@ public:
|
|||
data_(x,y)=rgba;
|
||||
}
|
||||
}
|
||||
inline void blendPixel(int x,int y,unsigned int rgba1,int t)
|
||||
{
|
||||
blendPixel2(x,y,rgba1,t,1.0); // do not change opacity
|
||||
}
|
||||
|
||||
inline void blendPixel2(int x,int y,unsigned int rgba1,int t,double opacity)
|
||||
{
|
||||
if (checkBounds(x,y))
|
||||
{
|
||||
unsigned rgba0 = data_(x,y);
|
||||
#ifdef MAPNIK_BIG_ENDIAN
|
||||
unsigned a1 = (unsigned)((rgba1 & 0xff) * opacity) & 0xff; // adjust for desired opacity
|
||||
a1 = (t*a1) / 255;
|
||||
if (a1 == 0) return;
|
||||
unsigned r1 = (rgba1 >> 24) & 0xff;
|
||||
unsigned g1 = (rgba1 >> 16 ) & 0xff;
|
||||
unsigned b1 = (rgba1 >> 8) & 0xff;
|
||||
|
||||
unsigned a0 = (rgba0 & 0xff);
|
||||
unsigned r0 = ((rgba0 >> 24 ) & 0xff) * a0;
|
||||
unsigned g0 = ((rgba0 >> 16 ) & 0xff) * a0;
|
||||
unsigned b0 = ((rgba0 >> 8) & 0xff) * a0;
|
||||
|
||||
a0 = ((a1 + a0) << 8) - a0*a1;
|
||||
|
||||
r0 = ((((r1 << 8) - r0) * a1 + (r0 << 8)) / a0);
|
||||
g0 = ((((g1 << 8) - g0) * a1 + (g0 << 8)) / a0);
|
||||
b0 = ((((b1 << 8) - b0) * a1 + (b0 << 8)) / a0);
|
||||
a0 = a0 >> 8;
|
||||
data_(x,y)= (a0)| (b0 << 8) | (g0 << 16) | (r0 << 24) ;
|
||||
#else
|
||||
unsigned a1 = (unsigned)(((rgba1 >> 24) & 0xff) * opacity) & 0xff; // adjust for desired opacity
|
||||
a1 = (t*a1) / 255;
|
||||
if (a1 == 0) return;
|
||||
unsigned r1 = rgba1 & 0xff;
|
||||
unsigned g1 = (rgba1 >> 8 ) & 0xff;
|
||||
unsigned b1 = (rgba1 >> 16) & 0xff;
|
||||
|
||||
unsigned a0 = (rgba0 >> 24) & 0xff;
|
||||
unsigned r0 = (rgba0 & 0xff) * a0;
|
||||
unsigned g0 = ((rgba0 >> 8 ) & 0xff) * a0;
|
||||
unsigned b0 = ((rgba0 >> 16) & 0xff) * a0;
|
||||
|
||||
a0 = ((a1 + a0) << 8) - a0*a1;
|
||||
|
||||
r0 = ((((r1 << 8) - r0) * a1 + (r0 << 8)) / a0);
|
||||
g0 = ((((g1 << 8) - g0) * a1 + (g0 << 8)) / a0);
|
||||
b0 = ((((b1 << 8) - b0) * a1 + (b0 << 8)) / a0);
|
||||
a0 = a0 >> 8;
|
||||
data_(x,y)= (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void composite_pixel(unsigned op, int x,int y,unsigned c, unsigned cover, double opacity);
|
||||
|
||||
|
|
|
@ -198,30 +198,6 @@ public:
|
|||
return height_;
|
||||
}
|
||||
|
||||
inline void blendPixel(value_type feature_id,int x,int y,unsigned int rgba1,int t)
|
||||
{
|
||||
blendPixel2(feature_id ,x,y,rgba1,t,1.0); // do not change opacity
|
||||
}
|
||||
|
||||
inline void blendPixel2(value_type feature_id,int x,int y,unsigned int rgba1,int t,double opacity)
|
||||
{
|
||||
if (checkBounds(x,y))
|
||||
{
|
||||
|
||||
#ifdef MAPNIK_BIG_ENDIAN
|
||||
unsigned a = (int)((rgba1 & 0xff) * opacity) & 0xff; // adjust for desired opacity
|
||||
#else
|
||||
unsigned a = (int)(((rgba1 >> 24) & 0xff) * opacity) & 0xff; // adjust for desired opacity
|
||||
#endif
|
||||
// if the pixel is more than a tenth
|
||||
// opaque then burn in the feature id
|
||||
if (a >= 25)
|
||||
{
|
||||
data_(x,y) = feature_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void set_rectangle(value_type id,image_data_32 const& data,int x0,int y0)
|
||||
{
|
||||
box2d<int> ext0(0,0,width_,height_);
|
||||
|
|
|
@ -40,7 +40,7 @@ template<class ColorT> struct blender_gray
|
|||
enum base_scale_e { base_shift = color_type::base_shift };
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
|
||||
unsigned alpha, unsigned cover=0)
|
||||
unsigned alpha, unsigned /*cover*/=0)
|
||||
{
|
||||
*p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
agg::int8u cover)
|
||||
agg::int8u /*cover*/)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
@ -588,7 +588,7 @@ public:
|
|||
void blend_from_color(const SrcPixelFormatRenderer& from,
|
||||
const color_type& color,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
int /*xsrc*/, int ysrc,
|
||||
unsigned len,
|
||||
agg::int8u cover)
|
||||
{
|
||||
|
@ -615,7 +615,7 @@ public:
|
|||
void blend_from_lut(const SrcPixelFormatRenderer& from,
|
||||
const color_type* color_lut,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
int /*xsrc*/, int ysrc,
|
||||
unsigned len,
|
||||
agg::int8u cover)
|
||||
{
|
||||
|
|
|
@ -73,8 +73,8 @@ public:
|
|||
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) {}
|
||||
void end_style_processing(feature_type_style const& st) {}
|
||||
void start_style_processing(feature_type_style const& /*st*/) {}
|
||||
void end_style_processing(feature_type_style const& /*st*/) {}
|
||||
void render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity, composite_mode_e comp_op);
|
||||
|
||||
void process(point_symbolizer const& sym,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_blur.h"
|
||||
|
@ -404,7 +405,7 @@ template <typename Src>
|
|||
void apply_filter(Src & src, agg_stack_blur const& op)
|
||||
{
|
||||
agg::rendering_buffer buf(src.raw_data(),src.width(),src.height(), src.width() * 4);
|
||||
agg::pixfmt_rgba32 pixf(buf);
|
||||
agg::pixfmt_rgba32_pre pixf(buf);
|
||||
agg::stack_blur_rgba32(pixf,op.rx,op.ry);
|
||||
}
|
||||
|
||||
|
@ -585,7 +586,7 @@ void apply_filter(Src & src, scale_hsla const& transform)
|
|||
}
|
||||
|
||||
template <typename Src>
|
||||
void apply_filter(Src & src, gray const& op)
|
||||
void apply_filter(Src & src, gray const& /*op*/)
|
||||
{
|
||||
using namespace boost::gil;
|
||||
|
||||
|
@ -635,14 +636,14 @@ void x_gradient_impl(Src const& src_view, Dst const& dst_view)
|
|||
}
|
||||
|
||||
template <typename Src>
|
||||
void apply_filter(Src & src, x_gradient const& op)
|
||||
void apply_filter(Src & src, x_gradient const& /*op*/)
|
||||
{
|
||||
double_buffer<Src> tb(src);
|
||||
x_gradient_impl(tb.src_view, tb.dst_view);
|
||||
}
|
||||
|
||||
template <typename Src>
|
||||
void apply_filter(Src & src, y_gradient const& op)
|
||||
void apply_filter(Src & src, y_gradient const& /*op*/)
|
||||
{
|
||||
double_buffer<Src> tb(src);
|
||||
x_gradient_impl(rotated90ccw_view(tb.src_view),
|
||||
|
@ -650,7 +651,7 @@ void apply_filter(Src & src, y_gradient const& op)
|
|||
}
|
||||
|
||||
template <typename Src>
|
||||
void apply_filter(Src & src, invert const& op)
|
||||
void apply_filter(Src & src, invert const& /*op*/)
|
||||
{
|
||||
using namespace boost::gil;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
// agg
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_renderer_base.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace mapnik { namespace detail {
|
|||
template <typename T>
|
||||
struct extract_value
|
||||
{
|
||||
static inline boost::optional<T> do_extract_from_string(std::string const& source)
|
||||
static inline boost::optional<T> do_extract_from_string(std::string const& /*source*/)
|
||||
{
|
||||
std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str();
|
||||
throw std::runtime_error(err_msg);
|
||||
|
|
|
@ -57,8 +57,7 @@ template <typename DetectorT>
|
|||
class placement_finder : mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
placement_finder(feature_impl const& feature,
|
||||
text_placement_info const& placement_info,
|
||||
placement_finder(text_placement_info const& placement_info,
|
||||
string_info const& info,
|
||||
DetectorT & detector,
|
||||
box2d<double> const& extent);
|
||||
|
|
|
@ -79,8 +79,8 @@ public:
|
|||
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) {}
|
||||
void end_style_processing(feature_type_style const& st) {}
|
||||
void start_style_processing(feature_type_style const& /*st*/) {}
|
||||
void end_style_processing(feature_type_style const& /*st*/) {}
|
||||
|
||||
/*!
|
||||
* @brief Overloads that process each kind of symbolizer individually.
|
||||
|
@ -115,9 +115,9 @@ public:
|
|||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans) {}
|
||||
void process(debug_symbolizer const& /*sym*/,
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/) {}
|
||||
|
||||
/*!
|
||||
* @brief Overload that process the whole set of symbolizers of a rule.
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
|
||||
void painted(bool painted)
|
||||
void painted(bool /*painted*/)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// agg
|
||||
#include "agg_math_stroke.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
// mapnik
|
||||
|
|
|
@ -27,7 +27,11 @@
|
|||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/gradient.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#endif
|
||||
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
||||
// boost
|
||||
|
@ -52,7 +56,6 @@
|
|||
#include "agg_gradient_lut.h"
|
||||
#include "agg_gamma_lut.h"
|
||||
#include "agg_span_interpolator_linear.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
|
||||
namespace mapnik {
|
||||
namespace svg {
|
||||
|
@ -335,14 +338,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
template <typename Rasterizer, typename Scanline, typename Renderer>
|
||||
void render_id(Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
Renderer& ren,
|
||||
int feature_id,
|
||||
agg::trans_affine const& mtx,
|
||||
double opacity,
|
||||
box2d<double> const& symbol_bbox)
|
||||
double /*opacity*/,
|
||||
box2d<double> const& /*symbol_bbox*/)
|
||||
|
||||
{
|
||||
using namespace agg;
|
||||
|
@ -417,6 +421,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -34,10 +34,9 @@ namespace mapnik {
|
|||
struct symbolizer_hash
|
||||
{
|
||||
template <typename T>
|
||||
static std::size_t value(T const& sym)
|
||||
static std::size_t value(T const& /*sym*/)
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
return seed;
|
||||
return 0;
|
||||
}
|
||||
// specialisation for polygon_symbolizer
|
||||
static std::size_t value(polygon_symbolizer const& sym)
|
||||
|
|
|
@ -146,16 +146,16 @@ static toff_t tiff_size_proc(thandle_t fd)
|
|||
return (toff_t)len;
|
||||
}
|
||||
|
||||
static tsize_t tiff_dummy_read_proc(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
static tsize_t tiff_dummy_read_proc(thandle_t /*fd*/, tdata_t /*buf*/, tsize_t /*size*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tiff_dummy_unmap_proc(thandle_t fd, tdata_t base, toff_t size)
|
||||
static void tiff_dummy_unmap_proc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/)
|
||||
{
|
||||
}
|
||||
|
||||
static int tiff_dummy_map_proc(thandle_t fd, tdata_t* pbase, toff_t* psize)
|
||||
static int tiff_dummy_map_proc(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ template <>
|
|||
struct end_container<mapnik::geometry_type const>
|
||||
{
|
||||
static mapnik::util::path_iterator<mapnik::geometry_type>
|
||||
call (mapnik::geometry_type const& g)
|
||||
call (mapnik::geometry_type const& /*g*/)
|
||||
{
|
||||
return mapnik::util::path_iterator<mapnik::geometry_type>();
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ template <>
|
|||
struct end_container<path_type const>
|
||||
{
|
||||
static mapnik::util::path_iterator<path_type>
|
||||
call (path_type const& g)
|
||||
call (path_type const& /*g*/)
|
||||
{
|
||||
return mapnik::util::path_iterator<path_type>();
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ struct equals
|
|||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator() (T const& lhs, U const& rhs) const
|
||||
bool operator() (T const& /*lhs*/, U const& /*rhs*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ 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 /*lhs*/, value_unicode_string const& rhs) const
|
||||
{
|
||||
if (rhs.isEmpty()) return false;
|
||||
return true;
|
||||
|
|
|
@ -47,12 +47,12 @@ typedef bool value_bool;
|
|||
|
||||
struct value_null
|
||||
{
|
||||
bool operator==(value_null const& other) const
|
||||
bool operator==(value_null const& /*other*/) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(value_null const& other) const
|
||||
bool operator!=(value_null const& /*other*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ struct value_null
|
|||
}
|
||||
};
|
||||
|
||||
inline std::size_t hash_value(const value_null& val) {
|
||||
inline std::size_t hash_value(const value_null& /*val*/) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream & out,value_null const& v)
|
||||
inline std::ostream& operator<< (std::ostream & out,value_null const& /*v*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
#include "agg_conv_clipper.h"
|
||||
#include "agg_path_storage.h"
|
||||
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
struct transform_tag {};
|
||||
|
@ -86,9 +89,9 @@ struct converter_traits
|
|||
typedef T0 geometry_type;
|
||||
typedef geometry_type conv_type;
|
||||
template <typename Args>
|
||||
static void setup(geometry_type & geom, Args const& args)
|
||||
static void setup(geometry_type & /*geom*/, Args const& /*args*/)
|
||||
{
|
||||
throw "BOOM!";
|
||||
throw std::runtime_error("invalid call to setup");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -216,7 +219,7 @@ struct converter_traits<T,mapnik::close_poly_tag>
|
|||
typedef T geometry_type;
|
||||
typedef typename agg::conv_close_polygon<geometry_type> conv_type;
|
||||
template <typename Args>
|
||||
static void setup(geometry_type & geom, Args const& args)
|
||||
static void setup(geometry_type & /*geom*/, Args const& /*args*/)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
@ -291,7 +294,7 @@ template <>
|
|||
struct converter_fwd<true>
|
||||
{
|
||||
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
|
||||
static void forward(Base& base, T0 & geom,T1 const& args)
|
||||
static void forward(Base& base, T0 & geom,T1 const& /*args*/)
|
||||
{
|
||||
base.template dispatch<Iter,End>(geom, typename boost::is_same<Iter,End>::type());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace mapnik { namespace detail {
|
|||
template <typename T>
|
||||
struct do_xml_attribute_cast
|
||||
{
|
||||
static inline boost::optional<T> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<T> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/)
|
||||
{
|
||||
std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str();
|
||||
throw std::runtime_error(err_msg);
|
||||
|
@ -55,7 +55,7 @@ struct do_xml_attribute_cast
|
|||
template <>
|
||||
struct do_xml_attribute_cast<mapnik::boolean>
|
||||
{
|
||||
static inline boost::optional<mapnik::boolean> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<mapnik::boolean> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
bool result;
|
||||
if (mapnik::util::string2bool(source, result))
|
||||
|
@ -68,7 +68,7 @@ struct do_xml_attribute_cast<mapnik::boolean>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<int>
|
||||
{
|
||||
static inline boost::optional<int> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<int> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::util::string2int(source, result))
|
||||
|
@ -82,7 +82,7 @@ struct do_xml_attribute_cast<int>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<long long>
|
||||
{
|
||||
static inline boost::optional<long long> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<long long> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::util::string2int(source, result))
|
||||
|
@ -98,7 +98,7 @@ struct do_xml_attribute_cast<long long>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<unsigned>
|
||||
{
|
||||
static inline boost::optional<unsigned> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<unsigned> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::util::string2int(source, result))
|
||||
|
@ -111,7 +111,7 @@ struct do_xml_attribute_cast<unsigned>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<float>
|
||||
{
|
||||
static inline boost::optional<float> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<float> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
float result;
|
||||
if (mapnik::util::string2float(source, result))
|
||||
|
@ -124,7 +124,7 @@ struct do_xml_attribute_cast<float>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<double>
|
||||
{
|
||||
static inline boost::optional<double> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<double> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
double result;
|
||||
if (mapnik::util::string2double(source, result))
|
||||
|
@ -137,7 +137,7 @@ struct do_xml_attribute_cast<double>
|
|||
template <typename T, int MAX>
|
||||
struct do_xml_attribute_cast<mapnik::enumeration<T,MAX> >
|
||||
{
|
||||
static inline boost::optional<mapnik::enumeration<T,MAX> > xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<mapnik::enumeration<T,MAX> > xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
typedef typename boost::optional<mapnik::enumeration<T,MAX> > result_type;
|
||||
try
|
||||
|
@ -168,7 +168,7 @@ struct do_xml_attribute_cast<mapnik::color>
|
|||
template <>
|
||||
struct do_xml_attribute_cast<std::string>
|
||||
{
|
||||
static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
|
||||
static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
|
||||
{
|
||||
return boost::optional<std::string>(source);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
return feature_ptr();
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// FIXME: https://github.com/mapnik/mapnik/issues/1020
|
||||
feature->set_id(shape_.id_);
|
||||
if (attr_ids_.size())
|
||||
{
|
||||
|
|
|
@ -45,10 +45,9 @@
|
|||
#include <mapnik/image_compositing.hpp>
|
||||
#include <mapnik/image_filter.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
// agg
|
||||
#define AGG_RENDERING_BUFFER row_ptr_cache<int8u>
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_image_filters.h"
|
||||
#include "agg_trans_bilinear.h"
|
||||
|
@ -193,7 +192,7 @@ void agg_renderer<T>::end_map_processing(Map const& )
|
|||
{
|
||||
|
||||
agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4);
|
||||
agg::pixfmt_rgba32 pixf(buf);
|
||||
agg::pixfmt_rgba32_pre pixf(buf);
|
||||
pixf.demultiply();
|
||||
MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: End map processing";
|
||||
}
|
||||
|
@ -298,7 +297,6 @@ void agg_renderer<T>::render_marker(pixel_position const& pos,
|
|||
{
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
|
@ -427,7 +425,7 @@ template <typename T> template <typename R>
|
|||
void agg_renderer<T>::debug_draw_box(R& buf, box2d<double> const& box,
|
||||
double x, double y, double angle)
|
||||
{
|
||||
typedef agg::pixfmt_rgba32 pixfmt;
|
||||
typedef agg::pixfmt_rgba32_pre pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
|
@ -54,11 +55,11 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_pre> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
agg::pixfmt_rgba32 pixf(buf);
|
||||
agg::pixfmt_rgba32_pre pixf(buf);
|
||||
ren_base renb(pixf);
|
||||
|
||||
color const& fill_ = sym.get_fill();
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_rasterizer_outline.h"
|
||||
#include "agg_rasterizer_outline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
|
@ -90,7 +91,6 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
{
|
||||
typedef agg::rgba8 color;
|
||||
typedef agg::order_rgba order;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color, order> blender_type;
|
||||
typedef agg::pattern_filter_bilinear_rgba8 pattern_filter_type;
|
||||
typedef agg::line_image_pattern<pattern_filter_type> pattern_type;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
|
@ -77,7 +78,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_path_storage.h"
|
||||
|
@ -64,7 +65,6 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
{
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::rendering_buffer buf_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, buf_type> pixfmt_comp_type;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
// for polygon_pattern_symbolizer
|
||||
|
@ -93,13 +94,12 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
typedef agg::rgba8 color;
|
||||
typedef agg::order_rgba order;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color, order> blender_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
|
||||
|
||||
typedef agg::wrap_mode_repeat wrap_x_type;
|
||||
typedef agg::wrap_mode_repeat wrap_y_type;
|
||||
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
|
||||
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32_pre,
|
||||
wrap_x_type,
|
||||
wrap_y_type> img_source_type;
|
||||
|
||||
|
@ -117,7 +117,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
unsigned w=(*pat)->width();
|
||||
unsigned h=(*pat)->height();
|
||||
agg::rendering_buffer pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4);
|
||||
agg::pixfmt_rgba32 pixf_pattern(pattern_rbuf);
|
||||
agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf);
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
||||
pattern_alignment_e align = sym.get_alignment();
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
|
||||
|
@ -86,7 +88,6 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
|
|
33
src/build.py
|
@ -304,21 +304,24 @@ if env['RUNTIME_LINK'] == "static":
|
|||
source += glob.glob('../deps/agg/src/' + '*.cpp')
|
||||
|
||||
# grid backend
|
||||
source += Split(
|
||||
"""
|
||||
grid/grid.cpp
|
||||
grid/grid_renderer.cpp
|
||||
grid/process_building_symbolizer.cpp
|
||||
grid/process_line_pattern_symbolizer.cpp
|
||||
grid/process_line_symbolizer.cpp
|
||||
grid/process_markers_symbolizer.cpp
|
||||
grid/process_point_symbolizer.cpp
|
||||
grid/process_polygon_pattern_symbolizer.cpp
|
||||
grid/process_polygon_symbolizer.cpp
|
||||
grid/process_raster_symbolizer.cpp
|
||||
grid/process_shield_symbolizer.cpp
|
||||
grid/process_text_symbolizer.cpp
|
||||
""")
|
||||
if env['GRID_RENDERER']:
|
||||
source += Split(
|
||||
"""
|
||||
grid/grid.cpp
|
||||
grid/grid_renderer.cpp
|
||||
grid/process_building_symbolizer.cpp
|
||||
grid/process_line_pattern_symbolizer.cpp
|
||||
grid/process_line_symbolizer.cpp
|
||||
grid/process_markers_symbolizer.cpp
|
||||
grid/process_point_symbolizer.cpp
|
||||
grid/process_polygon_pattern_symbolizer.cpp
|
||||
grid/process_polygon_symbolizer.cpp
|
||||
grid/process_raster_symbolizer.cpp
|
||||
grid/process_shield_symbolizer.cpp
|
||||
grid/process_text_symbolizer.cpp
|
||||
""")
|
||||
lib_env.Append(CPPDEFINES = '-DGRID_RENDERER')
|
||||
libmapnik_defines.append('-DGRID_RENDERER')
|
||||
|
||||
# https://github.com/mapnik/mapnik/issues/1438
|
||||
if env['SVG_RENDERER']: # svg backend
|
||||
|
|
|
@ -791,8 +791,8 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
|
||||
//typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
//typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
cairo_save_restore guard(context_);
|
||||
context_.set_operator(sym.comp_op());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/xml_tree.hpp>
|
||||
#include <mapnik/xml_node.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
namespace mapnik
|
||||
|
|
|
@ -133,23 +133,24 @@ static datasource_map ds_map = boost::assign::map_list_of
|
|||
;
|
||||
#endif
|
||||
|
||||
#ifdef MAPNIK_STATIC_PLUGINS
|
||||
datasource_ptr create_static_datasource(parameters const& params)
|
||||
{
|
||||
datasource_ptr ds;
|
||||
|
||||
#ifdef MAPNIK_STATIC_PLUGINS
|
||||
boost::optional<std::string> type = params.get<std::string>("type");
|
||||
|
||||
datasource_map::iterator it = ds_map.find(*type);
|
||||
|
||||
if (it != ds_map.end())
|
||||
{
|
||||
ds = it->second(params);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ds;
|
||||
}
|
||||
#else
|
||||
datasource_ptr create_static_datasource(parameters const& /*params*/)
|
||||
{
|
||||
return datasource_ptr();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::string> get_static_datasource_names()
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ struct expression_string : boost::static_visitor<void>
|
|||
str_ += "]";
|
||||
}
|
||||
|
||||
void operator() (geometry_type_attribute const& attr) const
|
||||
void operator() (geometry_type_attribute const& /*attr*/) const
|
||||
{
|
||||
str_ += "[mapnik::geometry_type]";
|
||||
}
|
||||
|
|
|
@ -24,8 +24,11 @@
|
|||
#include <mapnik/feature_style_processor_impl.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/graphics.hpp>
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <cairo.h>
|
||||
|
@ -56,7 +59,10 @@ template class feature_style_processor<skia_renderer>;
|
|||
template class feature_style_processor<svg_renderer<std::ostream_iterator<char> > >;
|
||||
#endif
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
template class feature_style_processor<grid_renderer<grid> >;
|
||||
#endif
|
||||
|
||||
template class feature_style_processor<agg_renderer<image_32> >;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include <mapnik/text_properties.hpp>
|
||||
#include <mapnik/graphics.hpp>
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#endif
|
||||
|
||||
#include <mapnik/text_path.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/font_util.hpp>
|
||||
|
@ -692,6 +696,7 @@ void text_renderer<T>::render(pixel_position const& pos)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(GRID_RENDERER)
|
||||
template <typename T>
|
||||
void text_renderer<T>::render_id(mapnik::value_integer feature_id,
|
||||
pixel_position const& pos)
|
||||
|
@ -721,6 +726,7 @@ void text_renderer<T>::render_id(mapnik::value_integer feature_id,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
boost::mutex freetype_engine::mutex_;
|
||||
|
@ -735,6 +741,7 @@ template text_renderer<image_32>::text_renderer(image_32&,
|
|||
double);
|
||||
template box2d<double>text_renderer<image_32>::prepare_glyphs(text_path const&);
|
||||
template void text_renderer<image_32>::render(pixel_position const&);
|
||||
#if defined(GRID_RENDERER)
|
||||
template void text_renderer<grid>::render_id(mapnik::value_integer,
|
||||
pixel_position const&);
|
||||
template text_renderer<grid>::text_renderer(grid&,
|
||||
|
@ -742,4 +749,5 @@ template text_renderer<grid>::text_renderer(grid&,
|
|||
halo_rasterizer_e,
|
||||
composite_mode_e, double);
|
||||
template box2d<double>text_renderer<grid>::prepare_glyphs(text_path const& );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -30,13 +30,15 @@
|
|||
// boost
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik {
|
||||
namespace formatting {
|
||||
|
||||
void node::to_xml(boost::property_tree::ptree &xml) const
|
||||
void node::to_xml(boost::property_tree::ptree & /*xml*/) const
|
||||
{
|
||||
//TODO: Should this throw a config_error?
|
||||
MAPNIK_LOG_ERROR(base) << "Trying to write unsupported node type to XML.";
|
||||
throw std::runtime_error("Trying to write unsupported node type to XML");
|
||||
}
|
||||
|
||||
node_ptr node::from_xml(xml_node const& xml)
|
||||
|
@ -62,7 +64,7 @@ node_ptr node::from_xml(xml_node const& xml)
|
|||
}
|
||||
}
|
||||
|
||||
void node::add_expressions(expression_set &output) const
|
||||
void node::add_expressions(expression_set & /*output*/) const
|
||||
{
|
||||
//Do nothing by default
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
// agg
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
// boost
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
@ -202,7 +203,7 @@ void image_32::premultiply()
|
|||
void image_32::demultiply()
|
||||
{
|
||||
agg::rendering_buffer buffer(data_.getBytes(),width_,height_,width_ * 4);
|
||||
agg::pixfmt_rgba32 pixf(buffer);
|
||||
agg::pixfmt_rgba32_pre pixf(buffer);
|
||||
pixf.demultiply();
|
||||
premultiplied_ = false;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void grid_renderer<T>::start_map_processing(Map const& m)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void grid_renderer<T>::end_map_processing(Map const& m)
|
||||
void grid_renderer<T>::end_map_processing(Map const& /*m*/)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(grid_renderer) << "grid_renderer: End map processing";
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void grid_renderer<T>::end_layer_processing(layer const&)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity, composite_mode_e comp_op)
|
||||
void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity, composite_mode_e /*comp_op*/)
|
||||
{
|
||||
if (marker.is_vector())
|
||||
{
|
||||
|
|
|
@ -65,7 +65,6 @@ porting notes -->
|
|||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
|
||||
// boost
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "agg_scanline_u.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
// agg
|
||||
#include "agg_image_accessors.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_color_rgba.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
|
|
@ -178,7 +178,7 @@ void jpeg_reader<T>::skip(j_decompress_ptr cinfo, long count)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void jpeg_reader<T>::term (j_decompress_ptr cinfo)
|
||||
void jpeg_reader<T>::term (j_decompress_ptr /*cinfo*/)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
@ -203,15 +203,16 @@ void jpeg_reader<T>::attach_stream (j_decompress_ptr cinfo, input_stream* in)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void jpeg_reader<T>::on_error(j_common_ptr cinfo)
|
||||
void jpeg_reader<T>::on_error(j_common_ptr /*cinfo*/)
|
||||
{
|
||||
throw image_reader_exception("JPEG Reader: libjpeg could not read image");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void jpeg_reader<T>::on_error_message(j_common_ptr cinfo)
|
||||
{
|
||||
// used to supress jpeg from printing to stderr
|
||||
char buffer[JMSG_LENGTH_MAX];
|
||||
(*cinfo->err->format_message)(cinfo, buffer);
|
||||
throw image_reader_exception(std::string("JPEG Reader: libjpeg could not read image: ") + buffer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -269,8 +269,6 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas
|
|||
{
|
||||
throw config_error(std::string("Invalid version string encountered: '")
|
||||
+ *beg + "' in '" + *min_version_string + "'");
|
||||
|
||||
break;
|
||||
}
|
||||
if (i==2)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
// miniz
|
||||
#define MINIZ_NO_ARCHIVE_APIS
|
||||
#define MINIZ_NO_STDIO
|
||||
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
|
||||
#include "miniz.c"
|
||||
|
||||
|
|
|
@ -97,8 +97,7 @@ double get_total_distance(T & shape_path)
|
|||
}
|
||||
|
||||
template <typename DetectorT>
|
||||
placement_finder<DetectorT>::placement_finder(feature_impl const& feature,
|
||||
text_placement_info const& placement_info,
|
||||
placement_finder<DetectorT>::placement_finder(text_placement_info const& placement_info,
|
||||
string_info const& info,
|
||||
DetectorT & detector,
|
||||
box2d<double> const& extent)
|
||||
|
|
|
@ -96,12 +96,12 @@ const bool registered2 = register_image_reader("png", create_png_reader2);
|
|||
}
|
||||
|
||||
|
||||
void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
|
||||
void user_error_fn(png_structp /*png_ptr*/, png_const_charp error_msg)
|
||||
{
|
||||
throw image_reader_exception(std::string("failed to read invalid png: '") + error_msg + "'");
|
||||
}
|
||||
|
||||
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
|
||||
void user_warning_fn(png_structp /*png_ptr*/, png_const_charp warning_msg)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(png_reader) << "libpng warning: '" << warning_msg << "'";
|
||||
}
|
||||
|
|
|
@ -190,8 +190,7 @@ public:
|
|||
|
||||
if (sym.get_colorizer())
|
||||
{
|
||||
serialize_raster_colorizer(sym_node, sym.get_colorizer(),
|
||||
explicit_defaults_);
|
||||
serialize_raster_colorizer(sym_node, sym.get_colorizer());
|
||||
}
|
||||
|
||||
boost::optional<bool> premultiplied = sym.premultiplied();
|
||||
|
@ -352,13 +351,16 @@ public:
|
|||
}
|
||||
|
||||
template <typename Symbolizer>
|
||||
#ifdef MAPNIK_DEBUG
|
||||
void operator () ( Symbolizer const& sym)
|
||||
{
|
||||
// not-supported
|
||||
#ifdef MAPNIK_DEBUG
|
||||
MAPNIK_LOG_WARN(save_map) << typeid(sym).name() << " is not supported";
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void operator () ( Symbolizer const& /*sym*/)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
serialize_symbolizer();
|
||||
|
@ -394,16 +396,23 @@ private:
|
|||
}
|
||||
|
||||
void serialize_raster_colorizer(ptree & sym_node,
|
||||
raster_colorizer_ptr const& colorizer,
|
||||
bool explicit_defaults)
|
||||
raster_colorizer_ptr const& colorizer)
|
||||
{
|
||||
ptree & col_node = sym_node.push_back(
|
||||
ptree::value_type("RasterColorizer", ptree() ))->second;
|
||||
|
||||
set_attr(col_node, "default-mode", colorizer->get_default_mode());
|
||||
set_attr(col_node, "default-color", colorizer->get_default_color());
|
||||
set_attr(col_node, "epsilon", colorizer->get_epsilon());
|
||||
|
||||
raster_colorizer dfl;
|
||||
if (colorizer->get_default_mode() != dfl.get_default_mode() || explicit_defaults_)
|
||||
{
|
||||
set_attr(col_node, "default-mode", colorizer->get_default_mode());
|
||||
}
|
||||
if (colorizer->get_default_color() != dfl.get_default_color() || explicit_defaults_)
|
||||
{
|
||||
set_attr(col_node, "default-color", colorizer->get_default_color());
|
||||
}
|
||||
if (colorizer->get_epsilon() != dfl.get_epsilon() || explicit_defaults_)
|
||||
{
|
||||
set_attr(col_node, "epsilon", colorizer->get_epsilon());
|
||||
}
|
||||
unsigned i;
|
||||
colorizer_stops const &stops = colorizer->get_stops();
|
||||
for (i=0; i<stops.size(); i++) {
|
||||
|
@ -414,7 +423,6 @@ private:
|
|||
if (stops[i].get_label()!=std::string(""))
|
||||
set_attr(stop_node, "label", stops[i].get_label());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void add_image_attributes(ptree & node, symbolizer_with_image const& sym)
|
||||
|
@ -673,22 +681,22 @@ public:
|
|||
serialize_type( boost::property_tree::ptree & node):
|
||||
node_(node) {}
|
||||
|
||||
void operator () ( mapnik::value_integer val ) const
|
||||
void operator () ( mapnik::value_integer /*val*/ ) const
|
||||
{
|
||||
node_.put("<xmlattr>.type", "int" );
|
||||
}
|
||||
|
||||
void operator () ( mapnik::value_double val ) const
|
||||
void operator () ( mapnik::value_double /*val*/ ) const
|
||||
{
|
||||
node_.put("<xmlattr>.type", "float" );
|
||||
}
|
||||
|
||||
void operator () ( std::string const& val ) const
|
||||
void operator () ( std::string const& /*val*/ ) const
|
||||
{
|
||||
node_.put("<xmlattr>.type", "string" );
|
||||
}
|
||||
|
||||
void operator () ( mapnik::value_null val ) const
|
||||
void operator () ( mapnik::value_null /*val*/ ) const
|
||||
{
|
||||
node_.put("<xmlattr>.type", "string" );
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace mapnik
|
|||
*/
|
||||
template <typename T>
|
||||
void svg_renderer<T>::process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
{
|
||||
path_attributes_.set_stroke_color(sym.get_stroke().get_color());
|
||||
path_attributes_.set_stroke_opacity(sym.get_stroke().get_opacity());
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "agg_ellipse.h"
|
||||
#include "agg_rounded_rect.h"
|
||||
#include "agg_span_gradient.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
|
@ -64,7 +65,6 @@ void parse_linear_gradient(svg_parser & parser,xmlTextReaderPtr reader);
|
|||
void parse_radial_gradient(svg_parser & parser,xmlTextReaderPtr reader);
|
||||
bool parse_common_gradient(svg_parser & parser,xmlTextReaderPtr reader);
|
||||
void parse_gradient_stop(svg_parser & parser,xmlTextReaderPtr reader);
|
||||
void parse_pattern(svg_parser & parser,xmlTextReaderPtr reader);
|
||||
void parse_attr(svg_parser & parser,xmlTextReaderPtr reader);
|
||||
void parse_attr(svg_parser & parser,const xmlChar * name, const xmlChar * value );
|
||||
|
||||
|
@ -1046,11 +1046,6 @@ void parse_linear_gradient(svg_parser & parser, xmlTextReaderPtr reader)
|
|||
//MAPNIK_LOG_DEBUG(svg_parser) << "Found Linear Gradient: " << "(" << x1 << " " << y1 << "),(" << x2 << " " << y2 << ")";
|
||||
}
|
||||
|
||||
void parse_pattern(svg_parser & parser, xmlTextReaderPtr reader)
|
||||
{
|
||||
//const xmlChar *value;
|
||||
}
|
||||
|
||||
svg_parser::svg_parser(svg_converter<svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes> > & path)
|
||||
: path_(path),
|
||||
|
|
|
@ -330,7 +330,7 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_placement()
|
|||
angle_ = 0.0;
|
||||
}
|
||||
|
||||
finder_.reset(new placement_finder<DetectorT>(feature_, *placement_,
|
||||
finder_.reset(new placement_finder<DetectorT>(*placement_,
|
||||
text_.get_string_info(font_manager_),
|
||||
detector_, dims_));
|
||||
placement_valid_ = true;
|
||||
|
|
|
@ -61,7 +61,7 @@ static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence)
|
|||
return static_cast<toff_t>(in->tellg());
|
||||
}
|
||||
|
||||
static int tiff_close_proc(thandle_t fd)
|
||||
static int tiff_close_proc(thandle_t /*fd*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,16 +86,16 @@ static tsize_t tiff_read_proc(thandle_t fd, tdata_t buf, tsize_t size)
|
|||
return static_cast<tsize_t>(in->gcount());
|
||||
}
|
||||
|
||||
static tsize_t tiff_write_proc(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
static tsize_t tiff_write_proc(thandle_t /*fd*/, tdata_t /*buf*/, tsize_t /*size*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tiff_unmap_proc(thandle_t fd, tdata_t base, toff_t size)
|
||||
static void tiff_unmap_proc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/)
|
||||
{
|
||||
}
|
||||
|
||||
static int tiff_map_proc(thandle_t fd, tdata_t* pbase, toff_t* psize)
|
||||
static int tiff_map_proc(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
12
src/warp.cpp
|
@ -78,11 +78,9 @@ void reproject_and_scale_raster(raster & target, raster const& source,
|
|||
prj_trans.backward(xs.getData(), ys.getData(), NULL, mesh_nx*mesh_ny);
|
||||
|
||||
// Initialize AGG objects
|
||||
typedef agg::pixfmt_rgba32 pixfmt;
|
||||
typedef agg::pixfmt_rgba32_pre pixfmt;
|
||||
typedef pixfmt::color_type color_type;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
typedef agg::pixfmt_rgba32_pre pixfmt_pre;
|
||||
typedef agg::renderer_base<pixfmt_pre> renderer_base_pre;
|
||||
|
||||
agg::rasterizer_scanline_aa<> rasterizer;
|
||||
agg::scanline_u8 scanline;
|
||||
|
@ -90,8 +88,8 @@ void reproject_and_scale_raster(raster & target, raster const& source,
|
|||
target.data_.width(),
|
||||
target.data_.height(),
|
||||
target.data_.width()*4);
|
||||
pixfmt_pre pixf_pre(buf);
|
||||
renderer_base_pre rb_pre(pixf_pre);
|
||||
pixfmt pixf(buf);
|
||||
renderer_base rb(pixf);
|
||||
rasterizer.clip_box(0, 0, target.data_.width(), target.data_.height());
|
||||
agg::rendering_buffer buf_tile(
|
||||
(unsigned char*)source.data_.getData(),
|
||||
|
@ -184,13 +182,13 @@ void reproject_and_scale_raster(raster & target, raster const& source,
|
|||
<img_accessor_type, interpolator_type>
|
||||
span_gen_type;
|
||||
span_gen_type sg(ia, interpolator);
|
||||
agg::render_scanlines_aa(rasterizer, scanline, rb_pre,
|
||||
agg::render_scanlines_aa(rasterizer, scanline, rb,
|
||||
sa, sg);
|
||||
} else {
|
||||
typedef agg::span_image_resample_rgba_affine
|
||||
<img_accessor_type> span_gen_type;
|
||||
span_gen_type sg(ia, interpolator, filter);
|
||||
agg::render_scanlines_aa(rasterizer, scanline, rb_pre,
|
||||
agg::render_scanlines_aa(rasterizer, scanline, rb,
|
||||
sa, sg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ else:
|
|||
test_env.AppendUnique(LIBS='dl')
|
||||
test_env.AppendUnique(CXXFLAGS='-g')
|
||||
test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS'])
|
||||
test_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||
if test_env['HAS_CAIRO']:
|
||||
test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS'])
|
||||
test_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
||||
|
|
|
@ -45,18 +45,18 @@ def make_map():
|
|||
m.zoom_all()
|
||||
return m
|
||||
|
||||
def test_clearing_grid_data():
|
||||
g = mapnik.Grid(256,256)
|
||||
utf = g.encode()
|
||||
# make sure it equals itself
|
||||
eq_(g.encode(),utf)
|
||||
m = make_map()
|
||||
mapnik.render_layer(m,g,layer=0,fields=['__id__','Name'])
|
||||
eq_(g.encode()!=utf,True)
|
||||
# clear grid, should now match original
|
||||
g.clear()
|
||||
eq_(g.encode(),utf)
|
||||
|
||||
if mapnik.has_grid_renderer():
|
||||
def test_clearing_grid_data():
|
||||
g = mapnik.Grid(256,256)
|
||||
utf = g.encode()
|
||||
# make sure it equals itself
|
||||
eq_(g.encode(),utf)
|
||||
m = make_map()
|
||||
mapnik.render_layer(m,g,layer=0,fields=['__id__','Name'])
|
||||
eq_(g.encode()!=utf,True)
|
||||
# clear grid, should now match original
|
||||
g.clear()
|
||||
eq_(g.encode(),utf)
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
|
|
|
@ -20,9 +20,11 @@ def test_image_premultiply():
|
|||
im.demultiply()
|
||||
eq_(im.premultiplied(),False)
|
||||
|
||||
@raises(RuntimeError)
|
||||
def test_negative_image_dimensions():
|
||||
im = mapnik.Image(-40,40)
|
||||
# Disabled for now since this breaks hard if run against
|
||||
# a mapnik version that does not have the fix
|
||||
#@raises(RuntimeError)
|
||||
#def test_negative_image_dimensions():
|
||||
#im = mapnik.Image(-40,40)
|
||||
|
||||
def test_tiff_round_trip():
|
||||
filepath = '/tmp/mapnik-tiff-io.tiff'
|
||||
|
|
|
@ -15,370 +15,371 @@ def setup():
|
|||
# from another directory we need to chdir()
|
||||
os.chdir(execution_path('.'))
|
||||
|
||||
def show_grids(name,g1,g2):
|
||||
g1_file = '/tmp/mapnik-%s-actual.json' % name
|
||||
open(g1_file,'w').write(json.dumps(g1,sort_keys=True))
|
||||
g2_file = '/tmp/mapnik-%s-expected.json' % name
|
||||
open(g2_file,'w').write(json.dumps(g2,sort_keys=True))
|
||||
val = 'JSON does not match ->\n'
|
||||
if g1['grid'] != g2['grid']:
|
||||
val += ' X grid does not match\n'
|
||||
else:
|
||||
val += ' ✓ grid matches\n'
|
||||
if g1['data'].keys() != g2['data'].keys():
|
||||
val += ' X data does not match\n'
|
||||
else:
|
||||
val += ' ✓ data matches\n'
|
||||
if g1['keys'] != g2['keys']:
|
||||
val += ' X keys do not\n'
|
||||
else:
|
||||
val += ' ✓ keys match\n'
|
||||
val += '\n\t%s\n\t%s' % (g1_file,g2_file)
|
||||
return val
|
||||
|
||||
def show_grids2(name,g1,g2):
|
||||
g2_expected = '../data/grids/mapnik-%s-actual.json' % name
|
||||
if not os.path.exists(g2_expected):
|
||||
# create test fixture based on actual results
|
||||
open(g2_expected,'a+').write(json.dumps(g1,sort_keys=True))
|
||||
return
|
||||
g1_file = '/tmp/mapnik-%s-actual.json' % name
|
||||
open(g1_file,'w').write(json.dumps(g1,sort_keys=True))
|
||||
val = 'JSON does not match ->\n'
|
||||
if g1['grid'] != g2['grid']:
|
||||
val += ' X grid does not match\n'
|
||||
else:
|
||||
val += ' ✓ grid matches\n'
|
||||
if g1['data'].keys() != g2['data'].keys():
|
||||
val += ' X data does not match\n'
|
||||
else:
|
||||
val += ' ✓ data matches\n'
|
||||
if g1['keys'] != g2['keys']:
|
||||
val += ' X keys do not\n'
|
||||
else:
|
||||
val += ' ✓ keys match\n'
|
||||
val += '\n\t%s\n\t%s' % (g1_file,g2_expected)
|
||||
return val
|
||||
|
||||
# first pass impl where resolution is passed as render
|
||||
# time rather than encoding time, likely will be deprecated soon
|
||||
grid_correct_old = {"keys": ["", "North West", "North East", "South West", "South East"], "data": {"South East": {"Name": "South East"}, "North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!!!! ##### ", " !!!!! ##### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$$ %%%%% ", " $$$$$ %%%%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]}
|
||||
|
||||
# now using svg rendering
|
||||
grid_correct_old2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
grid_correct_old3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
# previous rendering using agg ellipse directly
|
||||
grid_correct_new = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
# newer rendering using svg
|
||||
grid_correct_new2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
grid_correct_new3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
def resolve(grid,row,col):
|
||||
""" Resolve the attributes for a given pixel in a grid.
|
||||
"""
|
||||
row = grid['grid'][row]
|
||||
utf_val = row[col]
|
||||
#http://docs.python.org/library/functions.html#ord
|
||||
codepoint = ord(utf_val)
|
||||
if (codepoint >= 93):
|
||||
codepoint-=1
|
||||
if (codepoint >= 35):
|
||||
codepoint-=1
|
||||
codepoint -= 32
|
||||
key = grid['keys'][codepoint]
|
||||
return grid['data'].get(key)
|
||||
|
||||
|
||||
def create_grid_map(width,height,sym):
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
f = mapnik.Feature(context,1)
|
||||
f['Name'] = 'South East'
|
||||
f.add_geometries_from_wkt('POINT (143.10 -38.60)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,2)
|
||||
f['Name'] = 'South West'
|
||||
f.add_geometries_from_wkt('POINT (142.48 -38.60)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,3)
|
||||
f['Name'] = 'North West'
|
||||
f.add_geometries_from_wkt('POINT (142.48 -38.38)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,4)
|
||||
f['Name'] = 'North East'
|
||||
f.add_geometries_from_wkt('POINT (143.10 -38.38)')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
sym.allow_overlap = True
|
||||
r.symbols.append(sym)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
return m
|
||||
|
||||
def test_render_grid_old():
|
||||
""" test old method """
|
||||
width,height = 256,256
|
||||
symb = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png'))
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
#print mapnik.save_map_to_string(m)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
||||
eq_(grid,grid_correct_old3,show_grids('old-markers',grid,grid_correct_old3))
|
||||
eq_(resolve(grid,0,0),None)
|
||||
|
||||
# check every pixel of the nw symbol
|
||||
expected = {"Name": "North West"}
|
||||
|
||||
# top row
|
||||
eq_(resolve(grid,23,9),expected)
|
||||
eq_(resolve(grid,23,10),expected)
|
||||
eq_(resolve(grid,23,11),expected)
|
||||
|
||||
def test_render_grid_new():
|
||||
""" test old against new"""
|
||||
width,height = 256,256
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
|
||||
# new method
|
||||
grid = mapnik.Grid(m.width,m.height,key='Name')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1,grid_correct_new3,show_grids('new-markers',utf1,grid_correct_new3))
|
||||
|
||||
# check a full view is the same as a full image
|
||||
grid_view = grid.view(0,0,width,height)
|
||||
# for kicks check at full res too
|
||||
utf3 = grid.encode('utf',resolution=1)
|
||||
utf4 = grid_view.encode('utf',resolution=1)
|
||||
eq_(utf3['grid'],utf4['grid'])
|
||||
eq_(utf3['keys'],utf4['keys'])
|
||||
eq_(utf3['data'],utf4['data'])
|
||||
|
||||
eq_(resolve(utf4,0,0),None)
|
||||
|
||||
# resolve some center points in the
|
||||
# resampled view
|
||||
utf5 = grid_view.encode('utf',resolution=4)
|
||||
eq_(resolve(utf5,25,10),{"Name": "North West"})
|
||||
eq_(resolve(utf5,25,46),{"Name": "North East"})
|
||||
eq_(resolve(utf5,38,10),{"Name": "South West"})
|
||||
eq_(resolve(utf5,38,46),{"Name": "South East"})
|
||||
|
||||
|
||||
grid_feat_id = {'keys': ['', '3', '4', '2', '1'], 'data': {'1': {'Name': 'South East'}, '3': {'Name': u'North West'}, '2': {'Name': 'South West'}, '4': {'Name': 'North East'}}, 'grid': [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' !! ## ', ' !!! ### ', ' !! ## ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $$$ %% ', ' $$$ %%% ', ' $$ %% ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']}
|
||||
|
||||
grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
grid_feat_id3 = {"data": {"1": {"Name": "South East", "__id__": 1}, "2": {"Name": "South West", "__id__": 2}, "3": {"Name": "North West", "__id__": 3}, "4": {"Name": "North East", "__id__": 4}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
def test_render_grid3():
|
||||
""" test using feature id"""
|
||||
width,height = 256,256
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name'])
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1,grid_feat_id3,show_grids('id-markers',utf1,grid_feat_id3))
|
||||
# check a full view is the same as a full image
|
||||
grid_view = grid.view(0,0,width,height)
|
||||
# for kicks check at full res too
|
||||
utf3 = grid.encode('utf',resolution=1)
|
||||
utf4 = grid_view.encode('utf',resolution=1)
|
||||
eq_(utf3['grid'],utf4['grid'])
|
||||
eq_(utf3['keys'],utf4['keys'])
|
||||
eq_(utf3['data'],utf4['data'])
|
||||
|
||||
eq_(resolve(utf4,0,0),None)
|
||||
|
||||
# resolve some center points in the
|
||||
# resampled view
|
||||
utf5 = grid_view.encode('utf',resolution=4)
|
||||
eq_(resolve(utf5,25,10),{"Name": "North West","__id__": 3})
|
||||
eq_(resolve(utf5,25,46),{"Name": "North East","__id__": 4})
|
||||
eq_(resolve(utf5,38,10),{"Name": "South West","__id__": 2})
|
||||
eq_(resolve(utf5,38,46),{"Name": "South East","__id__": 1})
|
||||
|
||||
|
||||
def gen_grid_for_id(pixel_key):
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
f = mapnik.Feature(context,pixel_key)
|
||||
f['Name'] = str(pixel_key)
|
||||
f.add_geometries_from_wkt('POLYGON ((0 0, 0 256, 256 256, 256 0, 0 0))')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
symb = mapnik.PolygonSymbolizer()
|
||||
r.symbols.append(symb)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
width,height = 256,256
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
m.zoom_all()
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name'])
|
||||
return grid
|
||||
|
||||
def test_negative_id():
|
||||
grid = gen_grid_for_id(-1)
|
||||
eq_(grid.get_pixel(128,128),-1)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],['-1'])
|
||||
|
||||
def test_32bit_int_id():
|
||||
int32 = 2147483647
|
||||
grid = gen_grid_for_id(int32)
|
||||
eq_(grid.get_pixel(128,128),int32)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(int32)])
|
||||
max_neg = -(int32)
|
||||
grid = gen_grid_for_id(max_neg)
|
||||
eq_(grid.get_pixel(128,128),max_neg)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(max_neg)])
|
||||
|
||||
def test_64bit_int_id():
|
||||
int64 = 0x7FFFFFFFFFFFFFFF
|
||||
grid = gen_grid_for_id(int64)
|
||||
eq_(grid.get_pixel(128,128),int64)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(int64)])
|
||||
max_neg = -(int64)
|
||||
grid = gen_grid_for_id(max_neg)
|
||||
eq_(grid.get_pixel(128,128),max_neg)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(max_neg)])
|
||||
|
||||
def test_id_zero():
|
||||
grid = gen_grid_for_id(0)
|
||||
eq_(grid.get_pixel(128,128),0)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],['0'])
|
||||
|
||||
line_expected = {"keys": ["", "1"], "data": {"1": {"Name": "1"}}, "grid": [" !", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", "!! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! "]}
|
||||
|
||||
def test_line_rendering():
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
pixel_key = 1
|
||||
f = mapnik.Feature(context,pixel_key)
|
||||
f['Name'] = str(pixel_key)
|
||||
f.add_geometries_from_wkt('LINESTRING (30 10, 10 30, 40 40)')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
symb = mapnik.LineSymbolizer()
|
||||
r.symbols.append(symb)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
width,height = 256,256
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
m.zoom_all()
|
||||
#mapnik.render_to_file(m,'test.png')
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode()
|
||||
eq_(utf1,line_expected,show_grids('line',utf1,line_expected))
|
||||
|
||||
point_expected = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
def test_point_symbolizer_grid():
|
||||
width,height = 256,256
|
||||
sym = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png'))
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.Grid(m.width,m.height)
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode()
|
||||
eq_(utf1,point_expected,show_grids('point-sym',utf1,point_expected))
|
||||
|
||||
|
||||
# should throw because this is a mis-usage
|
||||
# https://github.com/mapnik/mapnik/issues/1325
|
||||
@raises(RuntimeError)
|
||||
def test_render_to_grid_multiple_times():
|
||||
# create map with two layers
|
||||
m = mapnik.Map(256,256)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.allow_overlap = True
|
||||
r.symbols.append(sym)
|
||||
s.rules.append(r)
|
||||
m.append_style('points',s)
|
||||
|
||||
# NOTE: we use a csv datasource here
|
||||
# because the memorydatasource fails silently for
|
||||
# queries requesting fields that do not exist in the datasource
|
||||
ds1 = mapnik.Datasource(**{"type":"csv","inline":'''
|
||||
wkt,Name
|
||||
"POINT (143.10 -38.60)",South East'''})
|
||||
lyr1 = mapnik.Layer('One')
|
||||
lyr1.datasource = ds1
|
||||
lyr1.styles.append('points')
|
||||
m.layers.append(lyr1)
|
||||
|
||||
ds2 = mapnik.Datasource(**{"type":"csv","inline":'''
|
||||
wkt,Value
|
||||
"POINT (142.48 -38.60)",South West'''})
|
||||
lyr2 = mapnik.Layer('Two')
|
||||
lyr2.datasource = ds2
|
||||
lyr2.styles.append('points')
|
||||
m.layers.append(lyr2)
|
||||
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.Grid(m.width,m.height)
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
# should throw right here since Name will be a property now on the `grid` object
|
||||
# and it is not found on the second layer
|
||||
mapnik.render_layer(m,grid,layer=1,fields=['Value'])
|
||||
utf1 = grid.encode()
|
||||
if mapnik.has_grid_renderer():
|
||||
def show_grids(name,g1,g2):
|
||||
g1_file = '/tmp/mapnik-%s-actual.json' % name
|
||||
open(g1_file,'w').write(json.dumps(g1,sort_keys=True))
|
||||
g2_file = '/tmp/mapnik-%s-expected.json' % name
|
||||
open(g2_file,'w').write(json.dumps(g2,sort_keys=True))
|
||||
val = 'JSON does not match ->\n'
|
||||
if g1['grid'] != g2['grid']:
|
||||
val += ' X grid does not match\n'
|
||||
else:
|
||||
val += ' ✓ grid matches\n'
|
||||
if g1['data'].keys() != g2['data'].keys():
|
||||
val += ' X data does not match\n'
|
||||
else:
|
||||
val += ' ✓ data matches\n'
|
||||
if g1['keys'] != g2['keys']:
|
||||
val += ' X keys do not\n'
|
||||
else:
|
||||
val += ' ✓ keys match\n'
|
||||
val += '\n\t%s\n\t%s' % (g1_file,g2_file)
|
||||
return val
|
||||
|
||||
def show_grids2(name,g1,g2):
|
||||
g2_expected = '../data/grids/mapnik-%s-actual.json' % name
|
||||
if not os.path.exists(g2_expected):
|
||||
# create test fixture based on actual results
|
||||
open(g2_expected,'a+').write(json.dumps(g1,sort_keys=True))
|
||||
return
|
||||
g1_file = '/tmp/mapnik-%s-actual.json' % name
|
||||
open(g1_file,'w').write(json.dumps(g1,sort_keys=True))
|
||||
val = 'JSON does not match ->\n'
|
||||
if g1['grid'] != g2['grid']:
|
||||
val += ' X grid does not match\n'
|
||||
else:
|
||||
val += ' ✓ grid matches\n'
|
||||
if g1['data'].keys() != g2['data'].keys():
|
||||
val += ' X data does not match\n'
|
||||
else:
|
||||
val += ' ✓ data matches\n'
|
||||
if g1['keys'] != g2['keys']:
|
||||
val += ' X keys do not\n'
|
||||
else:
|
||||
val += ' ✓ keys match\n'
|
||||
val += '\n\t%s\n\t%s' % (g1_file,g2_expected)
|
||||
return val
|
||||
|
||||
# first pass impl where resolution is passed as render
|
||||
# time rather than encoding time, likely will be deprecated soon
|
||||
grid_correct_old = {"keys": ["", "North West", "North East", "South West", "South East"], "data": {"South East": {"Name": "South East"}, "North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!!!! ##### ", " !!!!! ##### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$$ %%%%% ", " $$$$$ %%%%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]}
|
||||
|
||||
# now using svg rendering
|
||||
grid_correct_old2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
grid_correct_old3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
# previous rendering using agg ellipse directly
|
||||
grid_correct_new = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
# newer rendering using svg
|
||||
grid_correct_new2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
grid_correct_new3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]}
|
||||
|
||||
def resolve(grid,row,col):
|
||||
""" Resolve the attributes for a given pixel in a grid.
|
||||
"""
|
||||
row = grid['grid'][row]
|
||||
utf_val = row[col]
|
||||
#http://docs.python.org/library/functions.html#ord
|
||||
codepoint = ord(utf_val)
|
||||
if (codepoint >= 93):
|
||||
codepoint-=1
|
||||
if (codepoint >= 35):
|
||||
codepoint-=1
|
||||
codepoint -= 32
|
||||
key = grid['keys'][codepoint]
|
||||
return grid['data'].get(key)
|
||||
|
||||
|
||||
def create_grid_map(width,height,sym):
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
f = mapnik.Feature(context,1)
|
||||
f['Name'] = 'South East'
|
||||
f.add_geometries_from_wkt('POINT (143.10 -38.60)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,2)
|
||||
f['Name'] = 'South West'
|
||||
f.add_geometries_from_wkt('POINT (142.48 -38.60)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,3)
|
||||
f['Name'] = 'North West'
|
||||
f.add_geometries_from_wkt('POINT (142.48 -38.38)')
|
||||
ds.add_feature(f)
|
||||
|
||||
f = mapnik.Feature(context,4)
|
||||
f['Name'] = 'North East'
|
||||
f.add_geometries_from_wkt('POINT (143.10 -38.38)')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
sym.allow_overlap = True
|
||||
r.symbols.append(sym)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
return m
|
||||
|
||||
def test_render_grid_old():
|
||||
""" test old method """
|
||||
width,height = 256,256
|
||||
symb = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png'))
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
#print mapnik.save_map_to_string(m)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
||||
eq_(grid,grid_correct_old3,show_grids('old-markers',grid,grid_correct_old3))
|
||||
eq_(resolve(grid,0,0),None)
|
||||
|
||||
# check every pixel of the nw symbol
|
||||
expected = {"Name": "North West"}
|
||||
|
||||
# top row
|
||||
eq_(resolve(grid,23,9),expected)
|
||||
eq_(resolve(grid,23,10),expected)
|
||||
eq_(resolve(grid,23,11),expected)
|
||||
|
||||
def test_render_grid_new():
|
||||
""" test old against new"""
|
||||
width,height = 256,256
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
|
||||
# new method
|
||||
grid = mapnik.Grid(m.width,m.height,key='Name')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1,grid_correct_new3,show_grids('new-markers',utf1,grid_correct_new3))
|
||||
|
||||
# check a full view is the same as a full image
|
||||
grid_view = grid.view(0,0,width,height)
|
||||
# for kicks check at full res too
|
||||
utf3 = grid.encode('utf',resolution=1)
|
||||
utf4 = grid_view.encode('utf',resolution=1)
|
||||
eq_(utf3['grid'],utf4['grid'])
|
||||
eq_(utf3['keys'],utf4['keys'])
|
||||
eq_(utf3['data'],utf4['data'])
|
||||
|
||||
eq_(resolve(utf4,0,0),None)
|
||||
|
||||
# resolve some center points in the
|
||||
# resampled view
|
||||
utf5 = grid_view.encode('utf',resolution=4)
|
||||
eq_(resolve(utf5,25,10),{"Name": "North West"})
|
||||
eq_(resolve(utf5,25,46),{"Name": "North East"})
|
||||
eq_(resolve(utf5,38,10),{"Name": "South West"})
|
||||
eq_(resolve(utf5,38,46),{"Name": "South East"})
|
||||
|
||||
|
||||
grid_feat_id = {'keys': ['', '3', '4', '2', '1'], 'data': {'1': {'Name': 'South East'}, '3': {'Name': u'North West'}, '2': {'Name': 'South West'}, '4': {'Name': 'North East'}}, 'grid': [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' !! ## ', ' !!! ### ', ' !! ## ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $$$ %% ', ' $$$ %%% ', ' $$ %% ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']}
|
||||
|
||||
grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
grid_feat_id3 = {"data": {"1": {"Name": "South East", "__id__": 1}, "2": {"Name": "South West", "__id__": 2}, "3": {"Name": "North West", "__id__": 3}, "4": {"Name": "North East", "__id__": 4}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
def test_render_grid3():
|
||||
""" test using feature id"""
|
||||
width,height = 256,256
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.width = mapnik.Expression('10')
|
||||
sym.height = mapnik.Expression('10')
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name'])
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1,grid_feat_id3,show_grids('id-markers',utf1,grid_feat_id3))
|
||||
# check a full view is the same as a full image
|
||||
grid_view = grid.view(0,0,width,height)
|
||||
# for kicks check at full res too
|
||||
utf3 = grid.encode('utf',resolution=1)
|
||||
utf4 = grid_view.encode('utf',resolution=1)
|
||||
eq_(utf3['grid'],utf4['grid'])
|
||||
eq_(utf3['keys'],utf4['keys'])
|
||||
eq_(utf3['data'],utf4['data'])
|
||||
|
||||
eq_(resolve(utf4,0,0),None)
|
||||
|
||||
# resolve some center points in the
|
||||
# resampled view
|
||||
utf5 = grid_view.encode('utf',resolution=4)
|
||||
eq_(resolve(utf5,25,10),{"Name": "North West","__id__": 3})
|
||||
eq_(resolve(utf5,25,46),{"Name": "North East","__id__": 4})
|
||||
eq_(resolve(utf5,38,10),{"Name": "South West","__id__": 2})
|
||||
eq_(resolve(utf5,38,46),{"Name": "South East","__id__": 1})
|
||||
|
||||
|
||||
def gen_grid_for_id(pixel_key):
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
f = mapnik.Feature(context,pixel_key)
|
||||
f['Name'] = str(pixel_key)
|
||||
f.add_geometries_from_wkt('POLYGON ((0 0, 0 256, 256 256, 256 0, 0 0))')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
symb = mapnik.PolygonSymbolizer()
|
||||
r.symbols.append(symb)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
width,height = 256,256
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
m.zoom_all()
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name'])
|
||||
return grid
|
||||
|
||||
def test_negative_id():
|
||||
grid = gen_grid_for_id(-1)
|
||||
eq_(grid.get_pixel(128,128),-1)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],['-1'])
|
||||
|
||||
def test_32bit_int_id():
|
||||
int32 = 2147483647
|
||||
grid = gen_grid_for_id(int32)
|
||||
eq_(grid.get_pixel(128,128),int32)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(int32)])
|
||||
max_neg = -(int32)
|
||||
grid = gen_grid_for_id(max_neg)
|
||||
eq_(grid.get_pixel(128,128),max_neg)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(max_neg)])
|
||||
|
||||
def test_64bit_int_id():
|
||||
int64 = 0x7FFFFFFFFFFFFFFF
|
||||
grid = gen_grid_for_id(int64)
|
||||
eq_(grid.get_pixel(128,128),int64)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(int64)])
|
||||
max_neg = -(int64)
|
||||
grid = gen_grid_for_id(max_neg)
|
||||
eq_(grid.get_pixel(128,128),max_neg)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],[str(max_neg)])
|
||||
|
||||
def test_id_zero():
|
||||
grid = gen_grid_for_id(0)
|
||||
eq_(grid.get_pixel(128,128),0)
|
||||
utf1 = grid.encode('utf',resolution=4)
|
||||
eq_(utf1['keys'],['0'])
|
||||
|
||||
line_expected = {"keys": ["", "1"], "data": {"1": {"Name": "1"}}, "grid": [" !", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", "!! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! "]}
|
||||
|
||||
def test_line_rendering():
|
||||
ds = mapnik.MemoryDatasource()
|
||||
context = mapnik.Context()
|
||||
context.push('Name')
|
||||
pixel_key = 1
|
||||
f = mapnik.Feature(context,pixel_key)
|
||||
f['Name'] = str(pixel_key)
|
||||
f.add_geometries_from_wkt('LINESTRING (30 10, 10 30, 40 40)')
|
||||
ds.add_feature(f)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
symb = mapnik.LineSymbolizer()
|
||||
r.symbols.append(symb)
|
||||
s.rules.append(r)
|
||||
lyr = mapnik.Layer('Places')
|
||||
lyr.datasource = ds
|
||||
lyr.styles.append('places_labels')
|
||||
width,height = 256,256
|
||||
m = mapnik.Map(width,height)
|
||||
m.append_style('places_labels',s)
|
||||
m.layers.append(lyr)
|
||||
m.zoom_all()
|
||||
#mapnik.render_to_file(m,'test.png')
|
||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode()
|
||||
eq_(utf1,line_expected,show_grids('line',utf1,line_expected))
|
||||
|
||||
point_expected = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||
|
||||
def test_point_symbolizer_grid():
|
||||
width,height = 256,256
|
||||
sym = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png'))
|
||||
m = create_grid_map(width,height,sym)
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.Grid(m.width,m.height)
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
utf1 = grid.encode()
|
||||
eq_(utf1,point_expected,show_grids('point-sym',utf1,point_expected))
|
||||
|
||||
|
||||
# should throw because this is a mis-usage
|
||||
# https://github.com/mapnik/mapnik/issues/1325
|
||||
@raises(RuntimeError)
|
||||
def test_render_to_grid_multiple_times():
|
||||
# create map with two layers
|
||||
m = mapnik.Map(256,256)
|
||||
s = mapnik.Style()
|
||||
r = mapnik.Rule()
|
||||
sym = mapnik.MarkersSymbolizer()
|
||||
sym.allow_overlap = True
|
||||
r.symbols.append(sym)
|
||||
s.rules.append(r)
|
||||
m.append_style('points',s)
|
||||
|
||||
# NOTE: we use a csv datasource here
|
||||
# because the memorydatasource fails silently for
|
||||
# queries requesting fields that do not exist in the datasource
|
||||
ds1 = mapnik.Datasource(**{"type":"csv","inline":'''
|
||||
wkt,Name
|
||||
"POINT (143.10 -38.60)",South East'''})
|
||||
lyr1 = mapnik.Layer('One')
|
||||
lyr1.datasource = ds1
|
||||
lyr1.styles.append('points')
|
||||
m.layers.append(lyr1)
|
||||
|
||||
ds2 = mapnik.Datasource(**{"type":"csv","inline":'''
|
||||
wkt,Value
|
||||
"POINT (142.48 -38.60)",South West'''})
|
||||
lyr2 = mapnik.Layer('Two')
|
||||
lyr2.datasource = ds2
|
||||
lyr2.styles.append('points')
|
||||
m.layers.append(lyr2)
|
||||
|
||||
ul_lonlat = mapnik.Coord(142.30,-38.20)
|
||||
lr_lonlat = mapnik.Coord(143.40,-38.80)
|
||||
m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
|
||||
grid = mapnik.Grid(m.width,m.height)
|
||||
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||
# should throw right here since Name will be a property now on the `grid` object
|
||||
# and it is not found on the second layer
|
||||
mapnik.render_layer(m,grid,layer=1,fields=['Value'])
|
||||
utf1 = grid.encode()
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" !! ",
|
||||
" !! ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 195 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 6.3 KiB |
42
tests/visual_tests/styles/marker-path-expression.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
|
||||
<Style name="ellipse">
|
||||
<Rule>
|
||||
<MarkersSymbolizer file="../../data/svg/[FILENAME].[FILETYPE]" />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>ellipse</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="inline">
|
||||
x,y,FILENAME,FILETYPE
|
||||
2.5,2.5,rect2,svg
|
||||
</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<!-- points to frame data view -->
|
||||
|
||||
<Style name="frame">
|
||||
<Rule>
|
||||
<PointSymbolizer />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Layer name="frame" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>frame</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="inline">
|
||||
x,y
|
||||
0,0
|
||||
5,0
|
||||
0,5
|
||||
5,5
|
||||
</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
|
@ -21,7 +21,7 @@ defaults = {
|
|||
'scales':[1.0,2.0],
|
||||
'agg': True,
|
||||
'cairo': mapnik.has_cairo(),
|
||||
'grid': True
|
||||
'grid': mapnik.has_grid_renderer()
|
||||
}
|
||||
|
||||
cairo_threshold = 10
|
||||
|
@ -167,7 +167,8 @@ files = {
|
|||
'style-level-compositing-tiled-0,0':{'sizes':[(512,512)],'bbox':merc_z1_bboxes['0,0']},
|
||||
'style-level-compositing-tiled-1,0':{'sizes':[(512,512)],'bbox':merc_z1_bboxes['1,0']},
|
||||
'style-level-compositing-tiled-0,1':{'sizes':[(512,512)],'bbox':merc_z1_bboxes['0,1']},
|
||||
'style-level-compositing-tiled-1,1':{'sizes':[(512,512)],'bbox':merc_z1_bboxes['1,1']}
|
||||
'style-level-compositing-tiled-1,1':{'sizes':[(512,512)],'bbox':merc_z1_bboxes['1,1']},
|
||||
'marker-path-expression':{}
|
||||
}
|
||||
|
||||
class Reporting:
|
||||
|
|
|
@ -36,6 +36,7 @@ source = Split(
|
|||
)
|
||||
|
||||
program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
|
||||
program_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||
|
||||
if env['HAS_CAIRO']:
|
||||
program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS'])
|
||||
|
|
|
@ -34,6 +34,7 @@ source = Split(
|
|||
)
|
||||
|
||||
program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
|
||||
program_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||
|
||||
if env['HAS_CAIRO']:
|
||||
program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS'])
|
||||
|
|