Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2012-06-02 11:21:52 -07:00
commit d7d346d799
57 changed files with 1153 additions and 845 deletions

View file

@ -37,10 +37,7 @@ Build dependencies are:
Mapnik Core depends on: Mapnik Core depends on:
* Boost * Boost
- >= 1.46 is recommended - >= 1.47 is required.
- >= 1.45 is required if compiling with clang++
- >= 1.42 works on most systems and most compilers
- >= 1.47 is required to support wkt/wkb geometry output (optional)
- These libraries are required: - These libraries are required:
- filesystem - filesystem
- system - system

View file

@ -44,7 +44,7 @@ SCONS_CONFIGURE_CACHE = 'config.cache'
SCONF_TEMP_DIR = '.sconf_temp' SCONF_TEMP_DIR = '.sconf_temp'
# auto-search directories for boost libs/headers # auto-search directories for boost libs/headers
BOOST_SEARCH_PREFIXES = ['/usr/local','/opt/local','/sw','/usr',] BOOST_SEARCH_PREFIXES = ['/usr/local','/opt/local','/sw','/usr',]
BOOST_MIN_VERSION = '1.41' BOOST_MIN_VERSION = '1.47'
CAIROMM_MIN_VERSION = '1.8.0' CAIROMM_MIN_VERSION = '1.8.0'
DEFAULT_LINK_PRIORITY = ['internal','other','frameworks','user','system'] DEFAULT_LINK_PRIORITY = ['internal','other','frameworks','user','system']
@ -81,7 +81,7 @@ pretty_dep_names = {
'sqlite_rtree':'The SQLite plugin requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)', 'sqlite_rtree':'The SQLite plugin requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)',
'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)' 'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)'
} }
# Core plugin build configuration # Core plugin build configuration
# opts.AddVariables still hardcoded however... # opts.AddVariables still hardcoded however...
PLUGINS = { # plugins with external dependencies PLUGINS = { # plugins with external dependencies
@ -94,7 +94,7 @@ PLUGINS = { # plugins with external dependencies
'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','lang':'C++'}, 'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','lang':'C++'},
'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'}, 'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'},
'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'}, 'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'},
# todo: osm plugin does also depend on libxml2 (but there is a separate check for that) # todo: osm plugin does also depend on libxml2 (but there is a separate check for that)
'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'}, 'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'},
@ -156,7 +156,7 @@ def create_uninstall_target(env, path, is_glob=False):
Delete("$SOURCE"), Delete("$SOURCE"),
]) ])
env.Alias("uninstall", "uninstall-"+path) env.Alias("uninstall", "uninstall-"+path)
def shortest_name(libs): def shortest_name(libs):
name = '-'*200 name = '-'*200
for lib in libs: for lib in libs:
@ -168,20 +168,20 @@ def shortest_name(libs):
def sort_paths(items,priority): def sort_paths(items,priority):
"""Sort paths such that compiling and linking will globally prefer custom or local libs """Sort paths such that compiling and linking will globally prefer custom or local libs
over system libraries by fixing up the order libs are passed to gcc and the linker. over system libraries by fixing up the order libs are passed to gcc and the linker.
Ideally preference could be by-target instead of global, but our SCons implementation Ideally preference could be by-target instead of global, but our SCons implementation
is not currently utilizing different SCons build env()'s as we should. is not currently utilizing different SCons build env()'s as we should.
Overally the current approach within these scripts is to prepend paths of preference Overally the current approach within these scripts is to prepend paths of preference
and append all others, but this does not give enough control (particularly due to the and append all others, but this does not give enough control (particularly due to the
approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config). approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config).
In effect /usr/lib is likely to come before /usr/local/lib which makes linking against In effect /usr/lib is likely to come before /usr/local/lib which makes linking against
custom built icu or boost impossible when those libraries are available in both places. custom built icu or boost impossible when those libraries are available in both places.
Sorting using a priority list allows this to be controlled, and fine tuned. Sorting using a priority list allows this to be controlled, and fine tuned.
""" """
new = [] new = []
path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]} path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]}
# parse types of paths into logical/meaningful groups # parse types of paths into logical/meaningful groups
@ -235,7 +235,7 @@ def sort_paths(items,priority):
if platform.dist()[0] in ('Ubuntu','debian'): if platform.dist()[0] in ('Ubuntu','debian'):
LIBDIR_SCHEMA='lib' LIBDIR_SCHEMA='lib'
elif platform.uname()[4] == 'x86_64' and platform.system() == 'Linux': elif platform.uname()[4] == 'x86_64' and platform.system() == 'Linux':
LIBDIR_SCHEMA='lib64' LIBDIR_SCHEMA='lib64'
elif platform.uname()[4] == 'ppc64': elif platform.uname()[4] == 'ppc64':
LIBDIR_SCHEMA='lib64' LIBDIR_SCHEMA='lib64'
else: else:
@ -274,7 +274,7 @@ opts.AddVariables(
BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'), BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'),
ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()), ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()),
('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''), ('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''),
# SCons build behavior options # SCons build behavior options
('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG),
BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'),
@ -282,8 +282,8 @@ opts.AddVariables(
# http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script
BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'),
BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'), BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'),
('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)), ('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)),
# Install Variables # Install Variables
('PREFIX', 'The install path "prefix"', '/usr/local'), ('PREFIX', 'The install path "prefix"', '/usr/local'),
('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''), ('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''),
@ -291,7 +291,7 @@ opts.AddVariables(
('PATH', 'A custom path (or multiple paths divided by ":") to append to the $PATH env to prioritize usage of command line programs (if multiple are present on the system)', ''), ('PATH', 'A custom path (or multiple paths divided by ":") to append to the $PATH env to prioritize usage of command line programs (if multiple are present on the system)', ''),
('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths', ''), ('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths', ''),
('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''), ('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''),
# Boost variables # Boost variables
# default is '/usr/include', see FindBoost method below # default is '/usr/include', see FindBoost method below
('BOOST_INCLUDES', 'Search path for boost include files', '',False), ('BOOST_INCLUDES', 'Search path for boost include files', '',False),
@ -301,7 +301,7 @@ opts.AddVariables(
('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False), ('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False),
('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False), ('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False),
('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''), ('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''),
# Variables for required dependencies # Variables for required dependencies
('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'), ('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'),
('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'), ('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'),
@ -310,7 +310,7 @@ opts.AddVariables(
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'), ('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'),
PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept), PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept),
PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'), BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'),
PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept), PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept),
PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept), PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept),
@ -318,15 +318,13 @@ opts.AddVariables(
PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept), PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept),
PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''), ('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''),
# Variables affecting rendering back-ends # Variables affecting rendering back-ends
BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'), BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'),
BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'),
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'), BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
# Variables for optional dependencies # Variables for optional dependencies
('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'), ('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'),
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config # Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
@ -447,7 +445,7 @@ HELP_REQUESTED = False
if ('-h' in command_line_args) or ('--help' in command_line_args): if ('-h' in command_line_args) or ('--help' in command_line_args):
HELP_REQUESTED = True HELP_REQUESTED = True
if 'configure' in command_line_args and not HELP_REQUESTED: if 'configure' in command_line_args and not HELP_REQUESTED:
force_configure = True force_configure = True
@ -482,10 +480,10 @@ for opt in pickle_store:
# if custom arguments are supplied make sure to accept them # if custom arguments are supplied make sure to accept them
if opts.args: if opts.args:
# since we have custom arguments update environment with all opts to # since we have custom arguments update environment with all opts to
# make sure to absorb the custom ones # make sure to absorb the custom ones
opts.Update(env) opts.Update(env)
# now since we've got custom arguments we'll disregard any # now since we've got custom arguments we'll disregard any
# pickled environment and force another configuration # pickled environment and force another configuration
preconfigured = False preconfigured = False
@ -504,7 +502,7 @@ color_print(4,'\nWelcome to Mapnik...\n')
#### Custom Configure Checks ### #### Custom Configure Checks ###
def prioritize_paths(context,silent=True): def prioritize_paths(context,silent=True):
env = context.env env = context.env
prefs = env['LINK_PRIORITY'].split(',') prefs = env['LINK_PRIORITY'].split(',')
if not silent: if not silent:
@ -572,7 +570,7 @@ def parse_config(context, config, checks='--libs --cflags'):
env['SKIPPED_DEPS'].append(tool) env['SKIPPED_DEPS'].append(tool)
conf.rollback_option(config) conf.rollback_option(config)
else: # freetype and libxml2, not optional else: # freetype and libxml2, not optional
env['MISSING_DEPS'].append(tool) env['MISSING_DEPS'].append(tool)
context.Result( ret ) context.Result( ret )
return ret return ret
@ -637,18 +635,18 @@ def rollback_option(context,variable):
def FindBoost(context, prefixes, thread_flag): def FindBoost(context, prefixes, thread_flag):
"""Routine to auto-find boost header dir, lib dir, and library naming structure. """Routine to auto-find boost header dir, lib dir, and library naming structure.
""" """
context.Message( 'Searching for boost libs and headers... ' ) context.Message( 'Searching for boost libs and headers... ' )
env = context.env env = context.env
BOOST_LIB_DIR = None BOOST_LIB_DIR = None
BOOST_INCLUDE_DIR = None BOOST_INCLUDE_DIR = None
BOOST_APPEND = None BOOST_APPEND = None
env['BOOST_APPEND'] = str() env['BOOST_APPEND'] = str()
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
search_lib = 'libboost_thread' search_lib = 'libboost_thread'
else: else:
search_lib = 'libboost_filesystem' search_lib = 'libboost_filesystem'
@ -669,23 +667,23 @@ def FindBoost(context, prefixes, thread_flag):
if hasattr(match,'groups'): if hasattr(match,'groups'):
BOOST_APPEND = match.groups()[0] BOOST_APPEND = match.groups()[0]
break break
msg = str() msg = str()
if BOOST_LIB_DIR: if BOOST_LIB_DIR:
msg += '\n *libs found: %s' % BOOST_LIB_DIR msg += '\n *libs found: %s' % BOOST_LIB_DIR
env['BOOST_LIBS'] = BOOST_LIB_DIR env['BOOST_LIBS'] = BOOST_LIB_DIR
else: else:
env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA
msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS'] msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS']
if BOOST_INCLUDE_DIR: if BOOST_INCLUDE_DIR:
msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR
env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR
else: else:
env['BOOST_INCLUDES'] = '/usr/include' env['BOOST_INCLUDES'] = '/usr/include'
msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES'] msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES']
if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']: if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']:
if BOOST_APPEND: if BOOST_APPEND:
msg += '\n *lib naming extension found: %s' % BOOST_APPEND msg += '\n *lib naming extension found: %s' % BOOST_APPEND
@ -704,12 +702,12 @@ def FindBoost(context, prefixes, thread_flag):
# Constructing the BOOST_APPEND setting that will be used to find the # Constructing the BOOST_APPEND setting that will be used to find the
# Boost libraries. # Boost libraries.
if len(append_params) > 1: if len(append_params) > 1:
env['BOOST_APPEND'] = '-'.join(append_params) env['BOOST_APPEND'] = '-'.join(append_params)
msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND'] msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND']
env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES'])) env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES']))
env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS'])) env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS']))
if env['COLOR_PRINT']: if env['COLOR_PRINT']:
msg = "\033[94m%s\033[0m" % (msg) msg = "\033[94m%s\033[0m" % (msg)
ret = context.Result(msg) ret = context.Result(msg)
@ -725,14 +723,14 @@ def CheckBoost(context, version, silent=False):
version_n += int(v_arr[1])*100 version_n += int(v_arr[1])*100
if len(v_arr) > 2: if len(v_arr) > 2:
version_n += int(v_arr[2]) version_n += int(v_arr[2])
if not silent: if not silent:
context.Message('Checking for Boost version >= %s... ' % (version)) context.Message('Checking for Boost version >= %s... ' % (version))
ret = context.TryRun(""" ret = context.TryRun("""
#include <boost/version.hpp> #include <boost/version.hpp>
int main() int main()
{ {
return BOOST_VERSION >= %d ? 0 : 1; return BOOST_VERSION >= %d ? 0 : 1;
} }
@ -749,7 +747,7 @@ def GetBoostLibVersion(context):
#include <boost/version.hpp> #include <boost/version.hpp>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << BOOST_LIB_VERSION << std::endl; std::cout << BOOST_LIB_VERSION << std::endl;
@ -768,7 +766,7 @@ def GetMapnikLibVersion(context):
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << MAPNIK_VERSION_STRING << std::endl; std::cout << MAPNIK_VERSION_STRING << std::endl;
return 0; return 0;
@ -788,7 +786,7 @@ def icu_at_least_four_two(context):
#include <unicode/uversion.h> #include <unicode/uversion.h>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl; std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl;
return 0; return 0;
@ -802,12 +800,12 @@ int main()
if not result: if not result:
context.Result('error, could not get major and minor version from unicode/uversion.h') context.Result('error, could not get major and minor version from unicode/uversion.h')
return False return False
major, minor = map(int,result.split('.')) major, minor = map(int,result.split('.'))
if major >= 4 and minor >= 0: if major >= 4 and minor >= 0:
color_print(4,'found: icu %s' % result) color_print(4,'found: icu %s' % result)
return True return True
color_print(1,'\nFound insufficient icu version... %s' % result) color_print(1,'\nFound insufficient icu version... %s' % result)
return False return False
@ -820,10 +818,10 @@ def boost_regex_has_icu(context):
#include <boost/regex/icu.hpp> #include <boost/regex/icu.hpp>
#include <unicode/unistr.h> #include <unicode/unistr.h>
int main() int main()
{ {
UnicodeString ustr; UnicodeString ustr;
try { try {
boost::u32regex pattern = boost::make_u32regex(ustr); boost::u32regex pattern = boost::make_u32regex(ustr);
} }
// an exception is fine, still indicates support is // an exception is fine, still indicates support is
@ -843,17 +841,17 @@ int main()
def sqlite_has_rtree(context): def sqlite_has_rtree(context):
""" check an sqlite3 install has rtree support. """ check an sqlite3 install has rtree support.
PRAGMA compile_options; PRAGMA compile_options;
http://www.sqlite.org/c3ref/compileoption_get.html http://www.sqlite.org/c3ref/compileoption_get.html
""" """
ret = context.TryRun(""" ret = context.TryRun("""
#include <sqlite3.h> #include <sqlite3.h>
#include <stdio.h> #include <stdio.h>
int main() int main()
{ {
sqlite3* db; sqlite3* db;
int rc; int rc;
@ -873,7 +871,7 @@ int main()
printf("yes, has rtree!\\n"); printf("yes, has rtree!\\n");
return 0; return 0;
} }
return -1; return -1;
} }
@ -883,7 +881,7 @@ int main()
if ret[0]: if ret[0]:
return True return True
return False return False
conf_tests = { 'prioritize_paths' : prioritize_paths, conf_tests = { 'prioritize_paths' : prioritize_paths,
'CheckPKGConfig' : CheckPKGConfig, 'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG, 'CheckPKG' : CheckPKG,
@ -909,7 +907,7 @@ if not preconfigured:
if not env['FAST']: if not env['FAST']:
SetCacheMode('force') SetCacheMode('force')
if env['USE_CONFIG']: if env['USE_CONFIG']:
if not env['CONFIG'].endswith('.py'): if not env['CONFIG'].endswith('.py'):
color_print(1,'SCons CONFIG file specified is not a python file, will not be read...') color_print(1,'SCons CONFIG file specified is not a python file, will not be read...')
@ -924,7 +922,7 @@ if not preconfigured:
optfile = file(conf) optfile = file(conf)
#print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=") #print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=")
optfile.close() optfile.close()
elif not conf == SCONS_LOCAL_CONFIG: elif not conf == SCONS_LOCAL_CONFIG:
# if default missing, no worries # if default missing, no worries
# but if the default is overridden and the file is not found, give warning # but if the default is overridden and the file is not found, give warning
@ -933,18 +931,18 @@ if not preconfigured:
env = Environment(ENV=os.environ,options=opts) env = Environment(ENV=os.environ,options=opts)
env['USE_CONFIG'] = True env['USE_CONFIG'] = True
else: else:
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...') color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
conf = Configure(env, custom_tests = conf_tests) conf = Configure(env, custom_tests = conf_tests)
if env['DEBUG']: if env['DEBUG']:
mode = 'debug mode' mode = 'debug mode'
else: else:
mode = 'release mode' mode = 'release mode'
env['PLATFORM'] = platform.uname()[0] env['PLATFORM'] = platform.uname()[0]
color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode)) color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode))
env['MISSING_DEPS'] = [] env['MISSING_DEPS'] = []
env['SKIPPED_DEPS'] = [] env['SKIPPED_DEPS'] = []
env['HAS_CAIRO'] = False env['HAS_CAIRO'] = False
@ -964,7 +962,7 @@ if not preconfigured:
# now strip it to ensure expected behavior # now strip it to ensure expected behavior
if env['LIB_DIR_NAME'].startswith(os.path.sep): if env['LIB_DIR_NAME'].startswith(os.path.sep):
env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep) env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep)
# base install location # base install location
env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA']) env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA'])
# directory for plugins and fonts # directory for plugins and fonts
@ -976,8 +974,8 @@ if not preconfigured:
env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS']) env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS'])
else: else:
env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts') env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts')
# install prefix is a pre-pended base location to # install prefix is a pre-pended base location to
# re-route the install and only intended for package building # re-route the install and only intended for package building
# we normalize to ensure no trailing slash and proper pre-pending to the absolute prefix # we normalize to ensure no trailing slash and proper pre-pending to the absolute prefix
install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX']) install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX'])
@ -991,12 +989,12 @@ if not preconfigured:
env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS']) env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS'])
else: else:
env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts') env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts')
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}' env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}'
else: else:
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}' env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}'
if env['PKG_CONFIG_PATH']: if env['PKG_CONFIG_PATH']:
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"] # otherwise this variable == os.environ["PKG_CONFIG_PATH"]
@ -1008,11 +1006,11 @@ if not preconfigured:
if not os.path.isdir(env['SYSTEM_FONTS']): if not os.path.isdir(env['SYSTEM_FONTS']):
color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!') color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!')
#### Libraries and headers dependency checks #### #### Libraries and headers dependency checks ####
# Set up for libraries and headers dependency checks # Set up for libraries and headers dependency checks
env['CPPPATH'] = ['#include', '#'] env['CPPPATH'] = ['#include', '#']
env['LIBPATH'] = ['#src'] env['LIBPATH'] = ['#src']
# set any custom cxxflags to come first # set any custom cxxflags to come first
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
@ -1027,7 +1025,7 @@ if not preconfigured:
# set if the `CXX` option begins with `CC`) # set if the `CXX` option begins with `CC`)
SOLARIS = env['PLATFORM'] == 'SunOS' SOLARIS = env['PLATFORM'] == 'SunOS'
env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC') env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC')
# If the Sun Studio C++ compiler (`CC`) is used instead of GCC. # If the Sun Studio C++ compiler (`CC`) is used instead of GCC.
if env['SUNCC']: if env['SUNCC']:
env['CC'] = 'cc' env['CC'] = 'cc'
@ -1050,7 +1048,7 @@ if not preconfigured:
if os.path.exists(env['ICU_LIB_NAME']): if os.path.exists(env['ICU_LIB_NAME']):
#-sICU_LINK=" -L/usr/lib -licucore #-sICU_LINK=" -L/usr/lib -licucore
env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','') env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','')
# Adding the required prerequisite library directories to the include path for # Adding the required prerequisite library directories to the include path for
# compiling and the library path for linking, respectively. # compiling and the library path for linking, respectively.
for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU', 'SQLITE'): for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU', 'SQLITE'):
@ -1094,8 +1092,8 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=False) conf.prioritize_paths(silent=False)
for libname, headers, required, lang in LIBSHEADERS: for libname, headers, required, lang in LIBSHEADERS:
if not conf.CheckLibWithHeader(libname, headers, lang): if not conf.CheckLibWithHeader(libname, headers, lang):
if required: if required:
@ -1109,16 +1107,16 @@ if not preconfigured:
if not conf.icu_at_least_four_two(): if not conf.icu_at_least_four_two():
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2 # expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
thread_flag = thread_suffix thread_flag = thread_suffix
else: else:
thread_flag = '' thread_flag = ''
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag) conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion() env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion()
# The other required boost headers. # The other required boost headers.
BOOST_LIBSHEADERS = [ BOOST_LIBSHEADERS = [
['system', 'boost/system/system_error.hpp', True], ['system', 'boost/system/system_error.hpp', True],
@ -1126,11 +1124,11 @@ if not preconfigured:
['regex', 'boost/regex.hpp', True], ['regex', 'boost/regex.hpp', True],
['program_options', 'boost/program_options.hpp', False] ['program_options', 'boost/program_options.hpp', False]
] ]
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True]) BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True])
# on solaris the configure checks for boost_thread # on solaris the configure checks for boost_thread
# require the -pthreads flag to be able to check for # require the -pthreads flag to be able to check for
# threading support, so we add as a global library instead # threading support, so we add as a global library instead
# of attaching to cxxflags after configure # of attaching to cxxflags after configure
if env['PLATFORM'] == 'SunOS': if env['PLATFORM'] == 'SunOS':
@ -1138,17 +1136,17 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths() conf.prioritize_paths()
# if the user is not setting custom boost configuration # if the user is not setting custom boost configuration
# enforce boost version greater than or equal to BOOST_MIN_VERSION # enforce boost version greater than or equal to BOOST_MIN_VERSION
if not conf.CheckBoost(BOOST_MIN_VERSION): if not conf.CheckBoost(BOOST_MIN_VERSION):
color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION) color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION)
if not env['BOOST_VERSION']: if not env['BOOST_VERSION']:
env['MISSING_DEPS'].append('boost version >=%s' % BOOST_MIN_VERSION) env['MISSING_DEPS'].append('boost version >=%s' % BOOST_MIN_VERSION)
else: else:
color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') ) color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') )
for count, libinfo in enumerate(BOOST_LIBSHEADERS): for count, libinfo in enumerate(BOOST_LIBSHEADERS):
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'): if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'):
if libinfo[2]: if libinfo[2]:
@ -1167,7 +1165,7 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('boost_regex_icu') env['SKIPPED_DEPS'].append('boost_regex_icu')
env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
if len(env['REQUESTED_PLUGINS']): if len(env['REQUESTED_PLUGINS']):
color_print(4,'Checking for requested plugins dependencies...') color_print(4,'Checking for requested plugins dependencies...')
for plugin in env['REQUESTED_PLUGINS']: for plugin in env['REQUESTED_PLUGINS']:
@ -1232,7 +1230,7 @@ if not preconfigured:
elif details['lib'] and details['inc']: elif details['lib'] and details['inc']:
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']): if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
env['SKIPPED_DEPS'].append(details['lib']) env['SKIPPED_DEPS'].append(details['lib'])
# re-append the local paths for mapnik sources to the beginning of the list # re-append the local paths for mapnik sources to the beginning of the list
# to make sure they come before any plugins that were 'prepended' # to make sure they come before any plugins that were 'prepended'
env.PrependUnique(CPPPATH = '#include', delete_existing=True) env.PrependUnique(CPPPATH = '#include', delete_existing=True)
@ -1244,15 +1242,10 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree') env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree')
env['PGSQL2SQLITE'] = False env['PGSQL2SQLITE'] = False
# Decide which libagg to use # we rely on an internal, patched copy of agg with critical fixes
# if we are using internal agg, then prepend to make sure # prepend to make sure we link locally
# we link locally env.Prepend(CPPPATH = '#deps/agg/include')
env.Prepend(LIBPATH = '#deps/agg')
if env['INTERNAL_LIBAGG']:
env.Prepend(CPPPATH = '#deps/agg/include')
env.Prepend(LIBPATH = '#deps/agg')
else:
env.ParseConfig('pkg-config --libs --cflags libagg')
if env['CAIRO']: if env['CAIRO']:
if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']: if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']:
@ -1260,7 +1253,7 @@ if not preconfigured:
if env['CAIRO_LIBS']: if env['CAIRO_LIBS']:
env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS'])) env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS']))
if not env['CAIRO_INCLUDES']: if not env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_LIBS'].replace('lib','',1) c_inc = env['CAIRO_LIBS'].replace('lib','',1)
if c_inc: if c_inc:
c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES'])) c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES']))
if c_inc.endswith('include'): if c_inc.endswith('include'):
@ -1323,17 +1316,17 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('cairo') env['SKIPPED_DEPS'].append('cairo')
env['SKIPPED_DEPS'].append('cairomm') env['SKIPPED_DEPS'].append('cairomm')
color_print(1,'pkg-config reported: %s' % e) color_print(1,'pkg-config reported: %s' % e)
else: else:
color_print(4,'Not building with cairo support, pass CAIRO=True to enable') color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS']:
# checklibwithheader does not work for boost_python since we can't feed it # checklibwithheader does not work for boost_python since we can't feed it
# multiple header files, so we fall back on a simple check for boost_python headers # multiple header files, so we fall back on a simple check for boost_python headers
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python') color_print(1,'Could not find required header files for boost python')
env['MISSING_DEPS'].append('boost python') env['MISSING_DEPS'].append('boost python')
if env['CAIRO']: if env['CAIRO']:
if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
env['HAS_PYCAIRO'] = True env['HAS_PYCAIRO'] = True
@ -1341,10 +1334,10 @@ if not preconfigured:
env['SKIPPED_DEPS'].extend(['pycairo']) env['SKIPPED_DEPS'].extend(['pycairo'])
else: else:
color_print(4,'Not building with pycairo support, pass CAIRO=True to enable') color_print(4,'Not building with pycairo support, pass CAIRO=True to enable')
#### End Config Stage for Required Dependencies #### #### End Config Stage for Required Dependencies ####
if env['MISSING_DEPS']: if env['MISSING_DEPS']:
# if required dependencies are missing, print warnings and then let SCons finish without building or saving local config # if required dependencies are missing, print warnings and then let SCons finish without building or saving local config
color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']])) color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']]))
@ -1367,7 +1360,7 @@ if not preconfigured:
if env['USE_CONFIG']: if env['USE_CONFIG']:
if os.path.exists(SCONS_LOCAL_CONFIG): if os.path.exists(SCONS_LOCAL_CONFIG):
action = 'Overwriting and re-saving' action = 'Overwriting and re-saving'
os.unlink(SCONS_LOCAL_CONFIG) os.unlink(SCONS_LOCAL_CONFIG)
else: else:
action = 'Saving new' action = 'Saving new'
color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG)) color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG))
@ -1409,25 +1402,25 @@ if not preconfigured:
# common_cxx_flags += '-DOSX_LEOPARD ' # common_cxx_flags += '-DOSX_LEOPARD '
else: else:
pthread = '-pthread' pthread = '-pthread'
# Common debugging flags. # Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'
ndebug_flags = '-DNDEBUG' ndebug_flags = '-DNDEBUG'
# Enable logging in debug mode (always) and release mode (when specified) # Enable logging in debug mode (always) and release mode (when specified)
severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY']:
severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY'] not in severities: if env['DEFAULT_LOG_SEVERITY'] not in severities:
color_print(1,"Cannot set default logger severity to '%s', available options are 'info', 'debug', 'warn', 'error', 'fatal', 'none'." % env['DEFAULT_LOG_SEVERITY']) severities_list = ', '.join(["'%s'" % s for s in severities])
color_print(1,"Cannot set default logger severity to '%s', available options are %s." % (env['DEFAULT_LOG_SEVERITY'], severities_list))
Exit(1) Exit(1)
else: else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY']) log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else: else:
if env['DEBUG']: severities_list = ', '.join(["'%s'" % s for s in severities])
log_severity = 1 # debug color_print(1,"No logger severity specified, available options are %s." % severities_list)
else: Exit(1)
log_severity = 3 # error
log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity
@ -1447,7 +1440,7 @@ if not preconfigured:
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++': if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
env.MergeFlags('-rdynamic') env.MergeFlags('-rdynamic')
# Customizing the C++ compiler flags depending on: # Customizing the C++ compiler flags depending on:
# (1) the C++ compiler used; and # (1) the C++ compiler used; and
# (2) whether debug binaries are requested. # (2) whether debug binaries are requested.
if env['SUNCC']: if env['SUNCC']:
@ -1457,10 +1450,10 @@ if not preconfigured:
env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags) env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags)
else: else:
# Common flags for GCC. # Common flags for GCC.
gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags) gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags)
if env['DEBUG']: if env['DEBUG']:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags) env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags)
else: else:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags)) env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags))
if env['DEBUG_UNDEFINED']: if env['DEBUG_UNDEFINED']:
@ -1470,44 +1463,44 @@ if not preconfigured:
if not os.access(env['PYTHON'], os.X_OK): if not os.access(env['PYTHON'], os.X_OK):
color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'])
Exit(1) Exit(1)
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip() py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
if py3: if py3:
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON'] sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
else: else:
sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON']
env['PYTHON_SYS_PREFIX'] = call(sys_prefix) env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
if HAS_DISTUTILS: if HAS_DISTUTILS:
if py3: if py3:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON'] sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON']
else: else:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON']
env['PYTHON_VERSION'] = call(sys_version) env['PYTHON_VERSION'] = call(sys_version)
if py3: if py3:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON'] py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON']
else: else:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON'] py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON']
env['PYTHON_INCLUDES'] = call(py_includes) env['PYTHON_INCLUDES'] = call(py_includes)
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
if py3: if py3:
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON'] site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON']
else: else:
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON']
env['PYTHON_SITE_PACKAGES'] = call(site_packages) env['PYTHON_SITE_PACKAGES'] = call(site_packages)
else: else:
env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip() env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip()
env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3] env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3]
env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION'] env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']
env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
# if user-requested custom prefix fall back to manual concatenation for building subdirectories # if user-requested custom prefix fall back to manual concatenation for building subdirectories
if env['PYTHON_PREFIX']: if env['PYTHON_PREFIX']:
py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install
else: else:
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES'] env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES']
@ -1515,27 +1508,27 @@ if not preconfigured:
is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON'] is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON']
else: else:
is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON'] is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON']
if is_64_bit: if is_64_bit:
env['PYTHON_IS_64BIT'] = True env['PYTHON_IS_64BIT'] = True
else: else:
env['PYTHON_IS_64BIT'] = False env['PYTHON_IS_64BIT'] = False
majver, minver = env['PYTHON_VERSION'].split('.') majver, minver = env['PYTHON_VERSION'].split('.')
# we don't want the includes it in the main environment... # we don't want the includes it in the main environment...
# as they are later set in the python build.py # as they are later set in the python build.py
# ugly hack needed until we have env specific conf # ugly hack needed until we have env specific conf
backup = env.Clone().Dictionary() backup = env.Clone().Dictionary()
env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES'])) env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES']))
if not conf.CheckHeader(header='Python.h',language='C'): if not conf.CheckHeader(header='Python.h',language='C'):
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION']) color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])
env.Replace(**backup) env.Replace(**backup)
Exit(1) Exit(1)
else: else:
env.Replace(**backup) env.Replace(**backup)
if (int(majver), int(minver)) < (2, 2): if (int(majver), int(minver)) < (2, 2):
color_print(1,"Python version 2.2 or greater required") color_print(1,"Python version 2.2 or greater required")
Exit(1) Exit(1)
@ -1557,7 +1550,7 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH one last time before saving... # if requested, sort LIBPATH and CPPPATH one last time before saving...
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths() conf.prioritize_paths()
# finish config stage and pickle results # finish config stage and pickle results
env = conf.Finish() env = conf.Finish()
env_cache = open(SCONS_CONFIGURE_CACHE, 'w') env_cache = open(SCONS_CONFIGURE_CACHE, 'w')
@ -1606,7 +1599,7 @@ if not HELP_REQUESTED:
if env['PKG_CONFIG_PATH']: if env['PKG_CONFIG_PATH']:
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"] # otherwise this variable == os.environ["PKG_CONFIG_PATH"]
if env['PATH']: if env['PATH']:
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH'] env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
@ -1640,10 +1633,10 @@ if not HELP_REQUESTED:
replace_path('CXXFLAGS',search,replace) replace_path('CXXFLAGS',search,replace)
replace_path('CAIROMM_LIBPATHS',search,replace) replace_path('CAIROMM_LIBPATHS',search,replace)
replace_path('CAIROMM_CPPPATHS',search,replace) replace_path('CAIROMM_CPPPATHS',search,replace)
# export env so it is available in build.py files # export env so it is available in build.py files
Export('env') Export('env')
plugin_base = env.Clone() plugin_base = env.Clone()
# for this to work you need: # for this to work you need:
# if __GNUC__ >= 4 # if __GNUC__ >= 4
@ -1659,7 +1652,7 @@ if not HELP_REQUESTED:
env['_CPPDEFFLAGS'] = None env['_CPPDEFFLAGS'] = None
plugin_base['_CPPDEFFLAGS'] = None plugin_base['_CPPDEFFLAGS'] = None
if env['FAST']: if env['FAST']:
# caching is 'auto' by default in SCons # caching is 'auto' by default in SCons
# But let's also cache implicit deps... # But let's also cache implicit deps...
@ -1667,22 +1660,22 @@ if not HELP_REQUESTED:
SetOption('implicit_cache', 1) SetOption('implicit_cache', 1)
env.Decider('MD5-timestamp') env.Decider('MD5-timestamp')
SetOption('max_drift', 1) SetOption('max_drift', 1)
else: else:
# Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite' # Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite'
# This allows for a SCONS_LOCAL_CONFIG, if present, to be used as the primary means of storing paths to successful build dependencies # This allows for a SCONS_LOCAL_CONFIG, if present, to be used as the primary means of storing paths to successful build dependencies
SetCacheMode('force') SetCacheMode('force')
if env['JOBS'] > 1: if env['JOBS'] > 1:
SetOption("num_jobs", env['JOBS']) SetOption("num_jobs", env['JOBS'])
# Build agg first, doesn't need anything special # Build agg first, doesn't need anything special
if env['RUNTIME_LINK'] == 'shared' and env['INTERNAL_LIBAGG']: if env['RUNTIME_LINK'] == 'shared':
SConscript('deps/agg/build.py') SConscript('deps/agg/build.py')
# Build the core library # Build the core library
SConscript('src/build.py') SConscript('src/build.py')
# Build the requested and able-to-be-compiled input plug-ins # Build the requested and able-to-be-compiled input plug-ins
GDAL_BUILT = False GDAL_BUILT = False
OGR_BUILT = False OGR_BUILT = False
@ -1702,7 +1695,7 @@ if not HELP_REQUESTED:
SConscript('plugins/input/%s/build.py' % plugin) SConscript('plugins/input/%s/build.py' % plugin)
else: else:
color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin) color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin)
create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False) create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False)
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
@ -1716,43 +1709,43 @@ if not HELP_REQUESTED:
if os.path.exists(plugin_path): if os.path.exists(plugin_path):
color_print(1,"Notice: removing out of date plugin: '%s'" % plugin_path) color_print(1,"Notice: removing out of date plugin: '%s'" % plugin_path)
os.unlink(plugin_path) os.unlink(plugin_path)
# Build the c++ rundemo app if requested # Build the c++ rundemo app if requested
if env['DEMO']: if env['DEMO']:
SConscript('demo/c++/build.py') SConscript('demo/c++/build.py')
# Build the pgsql2psqlite app if requested # Build the pgsql2psqlite app if requested
if env['PGSQL2SQLITE']: if env['PGSQL2SQLITE']:
SConscript('utils/pgsql2sqlite/build.py') SConscript('utils/pgsql2sqlite/build.py')
# Build shapeindex and remove its dependency from the LIBS # Build shapeindex and remove its dependency from the LIBS
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']: if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
SConscript('utils/shapeindex/build.py') SConscript('utils/shapeindex/build.py')
# devtools not ready for public # devtools not ready for public
#SConscript('utils/ogrindex/build.py') #SConscript('utils/ogrindex/build.py')
SConscript('utils/svg2png/build.py') SConscript('utils/svg2png/build.py')
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND']) env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
else : else :
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available") color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available")
# Build the Python bindings # Build the Python bindings
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS']:
SConscript('bindings/python/build.py') SConscript('bindings/python/build.py')
# Install the python speed testing scripts if python bindings will be available # Install the python speed testing scripts if python bindings will be available
SConscript('utils/performance/build.py') SConscript('utils/performance/build.py')
# Install the mapnik upgrade script # Install the mapnik upgrade script
SConscript('utils/upgrade_map_xml/build.py') SConscript('utils/upgrade_map_xml/build.py')
# Configure fonts and if requested install the bundled DejaVu fonts # Configure fonts and if requested install the bundled DejaVu fonts
SConscript('fonts/build.py') SConscript('fonts/build.py')
# build C++ tests # build C++ tests
# not ready for release # not ready for release
SConscript('tests/cpp_tests/build.py') SConscript('tests/cpp_tests/build.py')
# not ready for release # not ready for release
#if env['SVG_RENDERER']: #if env['SVG_RENDERER']:
# SConscript('tests/cpp_tests/svg_renderer_tests/build.py') # SConscript('tests/cpp_tests/svg_renderer_tests/build.py')
@ -1762,7 +1755,7 @@ if not HELP_REQUESTED:
# write the viewer.ini file # write the viewer.ini file
SConscript('demo/viewer/build.py') SConscript('demo/viewer/build.py')
# if requested, build the sample input plugins # if requested, build the sample input plugins
if env['SAMPLE_INPUT_PLUGINS']: if env['SAMPLE_INPUT_PLUGINS']:
SConscript('plugins/input/templates/helloworld/build.py') SConscript('plugins/input/templates/helloworld/build.py')

View file

@ -46,6 +46,11 @@ expression_ptr parse_expression_(std::string const& wkt)
return parse_expression(wkt,"utf8"); return parse_expression(wkt,"utf8");
} }
std::string expression_to_string_(mapnik::expr_node const& expr)
{
return mapnik::to_expression_string(expr);
}
mapnik::value expression_evaluate_(mapnik::expr_node const& expr, mapnik::Feature const& f) mapnik::value expression_evaluate_(mapnik::expr_node const& expr, mapnik::Feature const& f)
{ {
// will be auto-converted to proper python type by `mapnik_value_to_python` // will be auto-converted to proper python type by `mapnik_value_to_python`
@ -75,7 +80,7 @@ void export_expression()
"TODO" "TODO"
"",no_init) "",no_init)
.def("evaluate", &expression_evaluate_) .def("evaluate", &expression_evaluate_)
.def("__str__",&to_expression_string); .def("__str__",&expression_to_string_);
; ;
def("Expression",&parse_expression_,(arg("expr")),"Expression string"); def("Expression",&parse_expression_,(arg("expr")),"Expression string");

View file

@ -149,7 +149,7 @@ void blend (image_32 & im, unsigned x, unsigned y, image_32 const& im2, float op
void composite(image_32 & im, image_32 & im2, mapnik::composite_mode_e mode, float opacity) void composite(image_32 & im, image_32 & im2, mapnik::composite_mode_e mode, float opacity)
{ {
mapnik::composite(im.data(),im2.data(),mode,opacity,0,0,true,true); mapnik::composite(im.data(),im2.data(),mode,opacity,0,0,false,true);
} }
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)

View file

@ -194,7 +194,7 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
boost::get<1>(*itr).to_string().c_str())); boost::get<1>(*itr).to_string().c_str()));
} }
typedef mapnik::coord_transform2<mapnik::CoordTransform,mapnik::geometry_type> path_type; typedef mapnik::coord_transform<mapnik::CoordTransform,mapnik::geometry_type> path_type;
for (unsigned i=0; i<feat->num_geometries();++i) for (unsigned i=0; i<feat->num_geometries();++i)
{ {
@ -289,6 +289,32 @@ void MapWidget::mouseReleaseEvent(QMouseEvent* e)
} }
} }
void MapWidget::wheelEvent(QWheelEvent* e)
{
if (!map_)
{
return;
}
QPoint corner(map_->width(), map_->height());
QPoint zoomCoords;
double zoom;
if (e->delta() > 0)
{
zoom = 0.5;
QPoint center = corner / 2;
QPoint delta = e->pos() - center;
zoomCoords = zoom * delta + center;
}
else
{
zoom = 2.0;
zoomCoords = corner - e->pos();
}
map_->pan_and_zoom(zoomCoords.x(), zoomCoords.y(), zoom);
updateMap();
}
void MapWidget::keyPressEvent(QKeyEvent *e) void MapWidget::keyPressEvent(QKeyEvent *e)
{ {
@ -486,6 +512,10 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
{ {
std::cerr << ex.what() << std::endl; std::cerr << ex.what() << std::endl;
} }
catch (const std::exception & ex)
{
std::cerr << "exception: " << ex.what() << std::endl;
}
catch (...) catch (...)
{ {
std::cerr << "Unknown exception caught!\n"; std::cerr << "Unknown exception caught!\n";
@ -522,6 +552,10 @@ void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
{ {
std::cerr << ex.what() << std::endl; std::cerr << ex.what() << std::endl;
} }
catch (const std::exception & ex)
{
std::cerr << "exception: " << ex.what() << std::endl;
}
catch (...) catch (...)
{ {
std::cerr << "Unknown exception caught!\n"; std::cerr << "Unknown exception caught!\n";

View file

@ -99,6 +99,7 @@ protected:
void mousePressEvent(QMouseEvent* e); void mousePressEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e); void mouseMoveEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e); void mouseReleaseEvent(QMouseEvent* e);
void wheelEvent(QWheelEvent* e);
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e);
void export_to_file(unsigned width, void export_to_file(unsigned width,
unsigned height, unsigned height,

View file

@ -29,11 +29,8 @@ namespace agg
template<class VertexSource, class Transformer=trans_affine> class conv_transform template<class VertexSource, class Transformer=trans_affine> class conv_transform
{ {
public: public:
explicit conv_transform(VertexSource& source) : conv_transform(VertexSource& source, Transformer& tr) :
m_source(&source), m_trans() {} m_source(&source), m_trans(&tr) {}
conv_transform(VertexSource& source, const Transformer& tr) :
m_source(&source), m_trans(tr) {}
void attach(VertexSource& source) { m_source = &source; } void attach(VertexSource& source) { m_source = &source; }
@ -47,14 +44,14 @@ namespace agg
unsigned cmd = m_source->vertex(x, y); unsigned cmd = m_source->vertex(x, y);
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
m_trans.transform(x, y); m_trans->transform(x, y);
} }
return cmd; return cmd;
} }
void transformer(const Transformer& tr) void transformer(Transformer& tr)
{ {
m_trans = tr; m_trans = &tr;
} }
private: private:
@ -63,7 +60,7 @@ namespace agg
operator = (const conv_transform<VertexSource>&); operator = (const conv_transform<VertexSource>&);
VertexSource* m_source; VertexSource* m_source;
Transformer m_trans; const Transformer* m_trans;
}; };

File diff suppressed because it is too large Load diff

View file

@ -725,7 +725,6 @@ namespace agg
base_type::m_ry_inv) >> base_type::m_ry_inv) >>
image_subpixel_shift; image_subpixel_shift;
int total_weight = 0; int total_weight = 0;
int total_weight_alpha = 0;
int x_lr = x >> image_subpixel_shift; int x_lr = x >> image_subpixel_shift;
int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) *
base_type::m_rx_inv) >> base_type::m_rx_inv) >>
@ -740,21 +739,15 @@ namespace agg
x_hr = x_hr2; x_hr = x_hr2;
for(;;) for(;;)
{ {
int weight = (weight_y * weight_array[x_hr] + int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >> image_filter_scale / 2) >>
downscale_shift; downscale_shift;
int weight_alpha = (weight_y * weight_array[x_hr] / base_mask * fg_ptr[3] +
image_filter_scale / 2) >>
downscale_shift;
fg[0] += *fg_ptr++ * weight_alpha; fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight_alpha; fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight_alpha; fg[2] += *fg_ptr++ * weight;
fg[3] += *fg_ptr++ * weight; fg[3] += *fg_ptr++ * weight;
total_weight += weight; total_weight += weight;
total_weight_alpha += weight_alpha;
x_hr += base_type::m_rx_inv; x_hr += base_type::m_rx_inv;
if(x_hr >= filter_scale) break; if(x_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_x(); fg_ptr = (const value_type*)base_type::source().next_x();
@ -763,26 +756,16 @@ namespace agg
if(y_hr >= filter_scale) break; if(y_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_y(); fg_ptr = (const value_type*)base_type::source().next_y();
} }
if (total_weight && total_weight_alpha) fg[0] /= total_weight;
{ fg[1] /= total_weight;
fg[3] /= total_weight; fg[2] /= total_weight;
fg[0] = fg[0] / total_weight_alpha * fg[3] / base_mask; fg[3] /= total_weight;
fg[1] = fg[1] / total_weight_alpha * fg[3] / base_mask;
fg[2] = fg[2] / total_weight_alpha * fg[3] / base_mask; if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0;
if(fg[0] < 0) fg[0] = 0; if(fg[2] < 0) fg[2] = 0;
if(fg[1] < 0) fg[1] = 0; if(fg[3] < 0) fg[3] = 0;
if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0;
}
else
{
fg[0] = 0;
fg[1] = 0;
fg[2] = 0;
fg[3] = 0;
}
if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask;
if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A];

View file

@ -38,45 +38,20 @@ namespace mapnik
typedef coord_array<coord2d> CoordinateArray; typedef coord_array<coord2d> CoordinateArray;
template <typename Transform, typename Geometry> template <typename Transform, typename Geometry>
struct MAPNIK_DECL coord_transform struct MAPNIK_DECL coord_transform
{
coord_transform(Transform const& t, Geometry& geom)
: t_(t), geom_(geom) {}
unsigned vertex(double *x, double *y) const
{
unsigned command = geom_.vertex(x, y);
t_.forward(x, y);
return command;
}
void rewind(unsigned pos)
{
geom_.rewind(pos);
}
private:
Transform const& t_;
Geometry& geom_;
};
template <typename Transform, typename Geometry>
struct MAPNIK_DECL coord_transform2
{ {
typedef std::size_t size_type; typedef std::size_t size_type;
//typedef typename Geometry::value_type value_type; //typedef typename Geometry::value_type value_type;
coord_transform2(Transform const& t, coord_transform(Transform const& t,
Geometry & geom, Geometry & geom,
proj_transform const& prj_trans) proj_transform const& prj_trans)
: t_(&t), : t_(&t),
geom_(geom), geom_(geom),
prj_trans_(&prj_trans) {} prj_trans_(&prj_trans) {}
explicit coord_transform2(Geometry & geom) explicit coord_transform(Geometry & geom)
: t_(0), : t_(0),
geom_(geom), geom_(geom),
prj_trans_(0) {} prj_trans_(0) {}
@ -91,7 +66,7 @@ struct MAPNIK_DECL coord_transform2
t_ = &t; t_ = &t;
} }
unsigned vertex(double *x, double *y) unsigned vertex(double *x, double *y) const
{ {
unsigned command = SEG_MOVETO; unsigned command = SEG_MOVETO;
bool ok = false; bool ok = false;
@ -113,7 +88,7 @@ struct MAPNIK_DECL coord_transform2
return command; return command;
} }
void rewind(unsigned pos) void rewind(unsigned pos) const
{ {
geom_.rewind(pos); geom_.rewind(pos);
} }
@ -129,44 +104,6 @@ private:
proj_transform const* prj_trans_; proj_transform const* prj_trans_;
}; };
template <typename Transform, typename Geometry>
struct MAPNIK_DECL coord_transform3
{
coord_transform3(Transform const& t,
Geometry const& geom,
proj_transform const& prj_trans,
int dx, int dy)
: t_(t),
geom_(geom),
prj_trans_(prj_trans),
dx_(dx), dy_(dy) {}
unsigned vertex(double *x, double *y) const
{
unsigned command = geom_.vertex(x, y);
double z = 0;
prj_trans_.backward(*x, *y, z);
t_.forward(x, y);
*x += dx_;
*y += dy_;
return command;
}
void rewind(unsigned pos)
{
geom_.rewind(pos);
}
private:
Transform const& t_;
Geometry const& geom_;
proj_transform const& prj_trans_;
int dx_;
int dy_;
};
class CoordTransform class CoordTransform
{ {
private: private:

View file

@ -73,6 +73,12 @@ struct evaluate : boost::static_visitor<T1>
template <typename Tag> template <typename Tag>
value_type operator() (unary_node<Tag> const& x) const value_type operator() (unary_node<Tag> const& x) const
{
typename make_op<Tag>::type func;
return func(boost::apply_visitor(*this, x.expr));
}
value_type operator() (unary_node<tags::logical_not> const& x) const
{ {
return ! (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr).to_bool()); return ! (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr).to_bool());
} }

View file

@ -198,21 +198,26 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
| ( (lit('>') | lit("gt") ) >> additive_expr [ _val > _1 ]) | ( (lit('>') | lit("gt") ) >> additive_expr [ _val > _1 ])
) )
; ;
additive_expr = multiplicative_expr [_val = _1] additive_expr = multiplicative_expr [_val = _1]
>> * ( '+' >> multiplicative_expr[_val += _1] >> * ( '+' >> multiplicative_expr[_val += _1]
| '-' >> multiplicative_expr[_val -= _1] | '-' >> multiplicative_expr[_val -= _1]
) )
; ;
multiplicative_expr = primary_expr [_val = _1] multiplicative_expr = unary_expr [_val = _1]
>> *( '*' >> primary_expr [_val *= _1] >> *( '*' >> unary_expr [_val *= _1]
| '/' >> primary_expr [_val /= _1] | '/' >> unary_expr [_val /= _1]
| '%' >> primary_expr [_val %= _1] | '%' >> unary_expr [_val %= _1]
| regex_match_expr[_val = regex_match_(_val, _1)] | regex_match_expr[_val = regex_match_(_val, _1)]
| regex_replace_expr(_val) [_val = _1] | regex_replace_expr(_val) [_val = _1]
) )
; ;
unary_expr = primary_expr [_val = _1]
| '+' >> primary_expr [_val = _1]
| '-' >> primary_expr [_val = -_1]
;
primary_expr = strict_double [_val = _1] primary_expr = strict_double [_val = _1]
| int_ [_val = _1] | int_ [_val = _1]
@ -256,6 +261,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
rule_type logical_expr; rule_type logical_expr;
rule_type additive_expr; rule_type additive_expr;
rule_type multiplicative_expr; rule_type multiplicative_expr;
rule_type unary_expr;
rule_type not_expr; rule_type not_expr;
rule_type primary_expr; rule_type primary_expr;
qi::rule<Iterator, std::string() > regex_match_expr; qi::rule<Iterator, std::string() > regex_match_expr;

View file

@ -40,6 +40,14 @@ namespace mapnik
{ {
namespace tags { namespace tags {
struct negate
{
static const char* str()
{
return "-";
}
};
struct plus struct plus
{ {
static const char* str() static const char* str()
@ -166,6 +174,7 @@ typedef mapnik::value value_type;
typedef boost::variant < typedef boost::variant <
value_type, value_type,
attribute, attribute,
boost::recursive_wrapper<unary_node<tags::negate> >,
boost::recursive_wrapper<binary_node<tags::plus> >, boost::recursive_wrapper<binary_node<tags::plus> >,
boost::recursive_wrapper<binary_node<tags::minus> >, boost::recursive_wrapper<binary_node<tags::minus> >,
boost::recursive_wrapper<binary_node<tags::mult> >, boost::recursive_wrapper<binary_node<tags::mult> >,
@ -185,6 +194,7 @@ boost::recursive_wrapper<regex_replace_node>
> expr_node; > expr_node;
template <typename Tag> struct make_op; template <typename Tag> struct make_op;
template <> struct make_op<tags::negate> { typedef std::negate<value_type> type;};
template <> struct make_op<tags::plus> { typedef std::plus<value_type> type;}; template <> struct make_op<tags::plus> { typedef std::plus<value_type> type;};
template <> struct make_op<tags::minus> { typedef std::minus<value_type> type;}; template <> struct make_op<tags::minus> { typedef std::minus<value_type> type;};
template <> struct make_op<tags::mult> { typedef std::multiplies<value_type> type;}; template <> struct make_op<tags::mult> { typedef std::multiplies<value_type> type;};
@ -289,6 +299,11 @@ struct function_call
// ops // ops
inline expr_node& operator- (expr_node& expr)
{
return expr = unary_node<tags::negate>(expr);
}
inline expr_node & operator += ( expr_node &left ,const expr_node &right) inline expr_node & operator += ( expr_node &left ,const expr_node &right)
{ {
return left = binary_node<tags::plus>(left,right); return left = binary_node<tags::plus>(left,right);

View file

@ -33,6 +33,31 @@
namespace mapnik namespace mapnik
{ {
MAPNIK_DECL std::string to_expression_string(expr_node const& node); MAPNIK_DECL std::string to_expression_string(expr_node const& node);
/*
The following two templates are intentionally invalid and will prompt
a compile error if ever instanciated. This should prevent accidentally
passing a pointer (either raw or shared) as the argument. Without them,
the compiler could construct a temporary expr_node(bool) using
implicit pointer-to-bool conversion, thus any non-null pointer
would yield "true".
*/
template <typename T>
std::string to_expression_string(T const* x)
{
x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
}
template <typename T>
std::string to_expression_string(boost::shared_ptr<T> const& x)
{
x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
}
} }
#endif // MAPNIK_EXPRESSION_STRING_HPP #endif // MAPNIK_EXPRESSION_STRING_HPP

View file

@ -68,7 +68,9 @@ enum composite_mode_e
exclusion, exclusion,
contrast, contrast,
invert, invert,
invert_rgb invert_rgb,
grain_merge,
grain_extract
}; };
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name); MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);

View file

@ -29,14 +29,14 @@
// boost // boost
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
// agg // agg
#include "agg_basics.h" #include "agg_basics.h"
#include "agg_rendering_buffer.h" #include "agg_rendering_buffer.h"
#include "agg_pixfmt_rgba.h" #include "agg_pixfmt_rgba.h"
#include "agg_scanline_u.h" #include "agg_scanline_u.h"
#include "agg_blur.h" #include "agg_blur.h"
// 8-bit YUV // 8-bit YUV
//Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16 //Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16
//U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128 //U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128
@ -51,48 +51,48 @@
// c3 c4 c5 // c3 c4 c5
// c6 c7 c8 // c6 c7 c8
//sharpen //sharpen
// 0 -1 0 // 0 -1 0
// -1 5 -1 // -1 5 -1
// 0 -1 0 // 0 -1 0
//bits_type out_value = -c1 - c3 + 5.0*c4 - c5 - c7; //bits_type out_value = -c1 - c3 + 5.0*c4 - c5 - c7;
// edge detect // edge detect
// 0 1 0 // 0 1 0
// 1 -4 1 // 1 -4 1
// 0 1 0 // 0 1 0
//bits_type out_value = c1 + c3 - 4.0*c4 + c5 + c7; //bits_type out_value = c1 + c3 - 4.0*c4 + c5 + c7;
// //
//if (out_value < 0) out_value = 0; //if (out_value < 0) out_value = 0;
//if (out_value > 255) out_value = 255; //if (out_value > 255) out_value = 255;
// emboss // emboss
// -2 -1 0 // -2 -1 0
// -1 1 1 // -1 1 1
// 0 1 2 // 0 1 2
// bits_type out_value = -2*c0 - c1 - c3 + c4 + c5 + c7 + 2*c8; // bits_type out_value = -2*c0 - c1 - c3 + c4 + c5 + c7 + 2*c8;
// blur // blur
//float out_value = (0.1f*c0 + 0.1f*c1 + 0.1f*c2 + //float out_value = (0.1f*c0 + 0.1f*c1 + 0.1f*c2 +
// 0.1f*c3 + 0.1f*c4 + 0.1f*c5 + // 0.1f*c3 + 0.1f*c4 + 0.1f*c5 +
// 0.1f*c6 + 0.1f*c7 + 0.1f*c8); // 0.1f*c6 + 0.1f*c7 + 0.1f*c8);
//float out_value = std::sqrt(std::pow(x_gradient,2) + std::pow(y_gradient,2)); //float out_value = std::sqrt(std::pow(x_gradient,2) + std::pow(y_gradient,2));
//float theta = std::atan2(x_gradient,y_gradient); //float theta = std::atan2(x_gradient,y_gradient);
//if (out_value < 0.0) out_value = 0.0; //if (out_value < 0.0) out_value = 0.0;
//if (out_value < 1.0) out_value = 1.0; //if (out_value < 1.0) out_value = 1.0;
//float conv_matrix[]={1/3.0,1/3.0,1/3.0}; //float conv_matrix[]={1/3.0,1/3.0,1/3.0};
//float gaussian_1[]={0.00022923296f,0.0059770769f,0.060597949f,0.24173197f,0.38292751f, //float gaussian_1[]={0.00022923296f,0.0059770769f,0.060597949f,0.24173197f,0.38292751f,
// 0.24173197f,0.060597949f,0.0059770769f,0.00022923296f}; // 0.24173197f,0.060597949f,0.0059770769f,0.00022923296f};
//float gaussian_2[]={ //float gaussian_2[]={
// 0.00048869418f,0.0024031631f,0.0092463447f, // 0.00048869418f,0.0024031631f,0.0092463447f,
// 0.027839607f,0.065602221f,0.12099898f,0.17469721f, // 0.027839607f,0.065602221f,0.12099898f,0.17469721f,
@ -102,16 +102,16 @@
//}; //};
// kernel_1d_fixed<float,9> kernel(conv,4); // kernel_1d_fixed<float,9> kernel(conv,4);
// color_converted_view<rgb8_pixel_t>(src_view); // color_converted_view<rgb8_pixel_t>(src_view);
//typedef kth_channel_view_type< 0, const rgba8_view_t>::type view_t; //typedef kth_channel_view_type< 0, const rgba8_view_t>::type view_t;
//view_t red = kth_channel_view<0>(const_view(src_view)); //view_t red = kth_channel_view<0>(const_view(src_view));
//kernel_1d_fixed<float,3> kernel(sharpen,0); //kernel_1d_fixed<float,3> kernel(sharpen,0);
//convolve_rows_fixed<rgba32f_pixel_t>(src_view,kernel,src_view); //convolve_rows_fixed<rgba32f_pixel_t>(src_view,kernel,src_view);
// convolve_cols_fixed<rgba32f_pixel_t>(src_view,kernel,dst_view); // convolve_cols_fixed<rgba32f_pixel_t>(src_view,kernel,dst_view);
using namespace boost::gil; using namespace boost::gil;
namespace mapnik { namespace filter { namespace detail { namespace mapnik { namespace filter { namespace detail {
@ -127,20 +127,20 @@ static const float edge_detect_matrix[] = {0,1,0,1,-4,1,0,1,0 };
template <typename Src, typename Dst, typename Conv> template <typename Src, typename Dst, typename Conv>
void process_channel_impl (Src const& src, Dst & dst, Conv const& k) void process_channel_impl (Src const& src, Dst & dst, Conv const& k)
{ {
using namespace boost::gil; using namespace boost::gil;
typedef boost::gil::bits32f bits_type; typedef boost::gil::bits32f bits_type;
bits32f out_value = bits32f out_value =
k[0]*src[0] + k[1]*src[1] + k[2]*src[2] + k[0]*src[0] + k[1]*src[1] + k[2]*src[2] +
k[3]*src[3] + k[4]*src[4] + k[5]*src[5] + k[3]*src[3] + k[4]*src[4] + k[5]*src[5] +
k[6]*src[6] + k[7]*src[7] + k[8]*src[8] k[6]*src[6] + k[7]*src[7] + k[8]*src[8]
; ;
if (out_value < 0) out_value = 0; if (out_value < 0) out_value = 0;
if (out_value > 255) out_value = 255; if (out_value > 255) out_value = 255;
dst = out_value; dst = out_value;
} }
template <typename Src, typename Dst, typename Conv> template <typename Src, typename Dst, typename Conv>
void process_channel (Src const& src, Dst & dst, Conv const& k) void process_channel (Src const& src, Dst & dst, Conv const& k)
{ {
boost::ignore_unused_variable_warning(src); boost::ignore_unused_variable_warning(src);
boost::ignore_unused_variable_warning(dst); boost::ignore_unused_variable_warning(dst);
@ -175,19 +175,19 @@ void process_channel (Src const& src, Dst & dst, mapnik::filter::edge_detect)
template <typename Src, typename Dst> template <typename Src, typename Dst>
void process_channel (Src const& src, Dst & dst, mapnik::filter::sobel) void process_channel (Src const& src, Dst & dst, mapnik::filter::sobel)
{ {
using namespace boost::gil; using namespace boost::gil;
typedef boost::gil::bits32f bits_type; typedef boost::gil::bits32f bits_type;
bits32f x_gradient = (src[2] + 2*src[5] + src[8]) bits32f x_gradient = (src[2] + 2*src[5] + src[8])
- (src[0] + 2*src[3] + src[6]); - (src[0] + 2*src[3] + src[6]);
bits32f y_gradient = (src[0] + 2*src[1] + src[2]) bits32f y_gradient = (src[0] + 2*src[1] + src[2])
- (src[6] + 2*src[7] + src[8]); - (src[6] + 2*src[7] + src[8]);
bits32f out_value = std::sqrt(std::pow(x_gradient,2) + std::pow(y_gradient,2)); bits32f out_value = std::sqrt(std::pow(x_gradient,2) + std::pow(y_gradient,2));
//bts32f theta = std::atan2(x_gradient,y_gradient); //bts32f theta = std::atan2(x_gradient,y_gradient);
if (out_value < 0) out_value = 0; if (out_value < 0) out_value = 0;
if (out_value > 255) out_value = 255; if (out_value > 255) out_value = 255;
dst = out_value; dst = out_value;
} }
@ -196,47 +196,164 @@ void process_channel (Src const& src, Dst & dst, mapnik::filter::sobel)
template <typename Src, typename Dst, typename FilterTag> template <typename Src, typename Dst, typename FilterTag>
void apply_convolution_3x3(Src const& src_view, Dst & dst_view, FilterTag filter_tag) void apply_convolution_3x3(Src const& src_view, Dst & dst_view, FilterTag filter_tag)
{ {
typename Src::xy_locator src_loc = src_view.xy_at(1,1); // p0 p1 p2
// p3 p4 p5
// p6 p7 p8
typename Src::xy_locator src_loc = src_view.xy_at(0,0);
typename Src::xy_locator::cached_location_t loc00 = src_loc.cache_location(-1,-1); typename Src::xy_locator::cached_location_t loc00 = src_loc.cache_location(-1,-1);
typename Src::xy_locator::cached_location_t loc10 = src_loc.cache_location( 0,-1); typename Src::xy_locator::cached_location_t loc10 = src_loc.cache_location( 0,-1);
typename Src::xy_locator::cached_location_t loc20 = src_loc.cache_location( 1,-1); typename Src::xy_locator::cached_location_t loc20 = src_loc.cache_location( 1,-1);
typename Src::xy_locator::cached_location_t loc01 = src_loc.cache_location(-1, 0); typename Src::xy_locator::cached_location_t loc01 = src_loc.cache_location(-1, 0);
typename Src::xy_locator::cached_location_t loc11 = src_loc.cache_location( 0, 0); typename Src::xy_locator::cached_location_t loc11 = src_loc.cache_location( 0, 0);
typename Src::xy_locator::cached_location_t loc21 = src_loc.cache_location( 1, 0); typename Src::xy_locator::cached_location_t loc21 = src_loc.cache_location( 1, 0);
typename Src::xy_locator::cached_location_t loc02 = src_loc.cache_location(-1, 1); typename Src::xy_locator::cached_location_t loc02 = src_loc.cache_location(-1, 1);
typename Src::xy_locator::cached_location_t loc12 = src_loc.cache_location( 0, 1); typename Src::xy_locator::cached_location_t loc12 = src_loc.cache_location( 0, 1);
typename Src::xy_locator::cached_location_t loc22 = src_loc.cache_location( 1, 1); typename Src::xy_locator::cached_location_t loc22 = src_loc.cache_location( 1, 1);
for (int y = 1; y<src_view.height()-1; ++y) typename Src::x_iterator dst_it = dst_view.row_begin(0);
// top row
for (int x = 0 ; x < src_view.width(); ++x)
{ {
typename Src::x_iterator dst_it = dst_view.row_begin(y); *dst_it = src_loc[loc11];
for (int x = 0; x<src_view.width(); ++x) for (int i = 0; i < 3; ++i)
{ {
bits32f p[9];
p[4] = src_loc[loc11][i];
p[7] = src_loc[loc12][i];
if (x == 0)
{
p[3] = p[4];
p[6] = p[7];
}
else
{
p[3] = src_loc[loc01][i];
p[6] = src_loc[loc02][i];
}
if ( x == src_view.width()-1)
{
p[5] = p[4];
p[8] = p[7];
}
else
{
p[5] = src_loc[loc21][i];
p[8] = src_loc[loc22][i];
}
p[0] = p[6];
p[1] = p[7];
p[2] = p[8];
process_channel(p, (*dst_it)[i], filter_tag);
}
++src_loc.x();
++dst_it;
}
// carrige-return
src_loc += point2<std::ptrdiff_t>(-src_view.width(),1);
// 1... height-1 rows
for (int y = 1; y<src_view.height()-1; ++y)
{
for (int x = 0; x < src_view.width(); ++x)
{
*dst_it = src_loc[loc11]; *dst_it = src_loc[loc11];
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
bits32f p[9]; bits32f p[9];
p[0] = src_loc[loc00][i];
p[1] = src_loc[loc10][i]; p[1] = src_loc[loc10][i];
p[2] = src_loc[loc20][i];
p[3] = src_loc[loc01][i];
p[4] = src_loc[loc11][i]; p[4] = src_loc[loc11][i];
p[5] = src_loc[loc21][i];
p[6] = src_loc[loc02][i];
p[7] = src_loc[loc12][i]; p[7] = src_loc[loc12][i];
p[8] = src_loc[loc22][i];
if (x == 0)
{
p[0] = p[1];
p[3] = p[4];
p[6] = p[7];
}
else
{
p[0] = src_loc[loc00][i];
p[3] = src_loc[loc01][i];
p[6] = src_loc[loc02][i];
}
if ( x == src_view.width() - 1)
{
p[2] = p[1];
p[5] = p[4];
p[8] = p[7];
}
else
{
p[2] = src_loc[loc20][i];
p[5] = src_loc[loc21][i];
p[8] = src_loc[loc22][i];
}
process_channel(p, (*dst_it)[i], filter_tag); process_channel(p, (*dst_it)[i], filter_tag);
} }
++dst_it; ++dst_it;
++src_loc.x(); ++src_loc.x();
} }
// carrige-return
src_loc += point2<std::ptrdiff_t>(-src_view.width(),1); src_loc += point2<std::ptrdiff_t>(-src_view.width(),1);
} }
// bottom row
//src_loc = src_view.xy_at(0,src_view.height()-1);
for (int x = 0 ; x < src_view.width(); ++x)
{
*dst_it = src_loc[loc11];
for (int i = 0; i < 3; ++i)
{
bits32f p[9];
p[1] = src_loc[loc10][i];
p[4] = src_loc[loc11][i];
if (x == 0)
{
p[0] = p[1];
p[3] = p[4];
}
else
{
p[0] = src_loc[loc00][i];
p[3] = src_loc[loc01][i];
}
if ( x == src_view.width()-1)
{
p[2] = p[1];
p[5] = p[4];
}
else
{
p[2] = src_loc[loc20][i];
p[5] = src_loc[loc21][i];
}
p[6] = p[0];
p[7] = p[1];
p[8] = p[2];
process_channel(p, (*dst_it)[i], filter_tag);
}
++src_loc.x();
++dst_it;
}
} }
template <typename Src, typename Dst,typename FilterTag>
template <typename Src, typename Dst,typename FilterTag>
void apply_filter(Src const& src, Dst & dst, FilterTag filter_tag) void apply_filter(Src const& src, Dst & dst, FilterTag filter_tag)
{ {
using namespace boost::gil; using namespace boost::gil;
@ -245,115 +362,114 @@ void apply_filter(Src const& src, Dst & dst, FilterTag filter_tag)
src.width()*4); src.width()*4);
rgba8_view_t dst_view = interleaved_view(dst.width(),dst.height(), rgba8_view_t dst_view = interleaved_view(dst.width(),dst.height(),
(rgba8_pixel_t*) dst.raw_data(), (rgba8_pixel_t*) dst.raw_data(),
dst.width()*4); dst.width()*4);
typedef boost::mpl::vector<red_t,green_t,blue_t> channels; typedef boost::mpl::vector<red_t,green_t,blue_t> channels;
apply_convolution_3x3(src_view,dst_view,filter_tag); apply_convolution_3x3(src_view,dst_view,filter_tag);
} }
template <typename Src, typename FilterTag> template <typename Src, typename FilterTag>
void apply_filter(Src & src, FilterTag filter_tag) void apply_filter(Src & src, FilterTag filter_tag)
{ {
using namespace boost::gil; using namespace boost::gil;
rgba8_view_t src_view = interleaved_view(src.width(),src.height(), rgba8_view_t src_view = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(), (rgba8_pixel_t*) src.raw_data(),
src.width()*4); src.width()*4);
rgba8_image_t temp_buffer(src_view.dimensions()); rgba8_image_t temp_buffer(src_view.dimensions());
apply_convolution_3x3(src_view,boost::gil::view(temp_buffer), filter_tag); apply_convolution_3x3(src_view,boost::gil::view(temp_buffer), filter_tag);
boost::gil::copy_pixels(view(temp_buffer), src_view); boost::gil::copy_pixels(view(temp_buffer), src_view);
} }
template <typename Src> template <typename Src>
void apply_filter(Src & src, agg_stack_blur const& op) 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::rendering_buffer buf(src.raw_data(),src.width(),src.height(), src.width() * 4);
agg::pixfmt_rgba32 pixf(buf); agg::pixfmt_rgba32 pixf(buf);
agg::stack_blur_rgba32(pixf,op.rx,op.ry); agg::stack_blur_rgba32(pixf,op.rx,op.ry);
} }
template <typename Src> template <typename Src>
void apply_filter(Src & src, gray) void apply_filter(Src & src, gray)
{ {
using namespace boost::gil; using namespace boost::gil;
typedef pixel<channel_type<rgba8_view_t>::type, gray_layout_t> gray_pixel_t; typedef pixel<channel_type<rgba8_view_t>::type, gray_layout_t> gray_pixel_t;
rgba8_view_t src_view = interleaved_view(src.width(),src.height(), rgba8_view_t src_view = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(), (rgba8_pixel_t*) src.raw_data(),
src.width()*4); src.width()*4);
boost::gil::copy_and_convert_pixels(color_converted_view<gray_pixel_t>(src_view), src_view); boost::gil::copy_and_convert_pixels(color_converted_view<gray_pixel_t>(src_view), src_view);
} }
template <typename Src, typename Dst>
void x_gradient_impl(Src const& src_view, Dst const& dst_view)
{
for (int y=0; y<src_view.height(); ++y)
{
typename Src::x_iterator src_it = src_view.row_begin(y);
typename Dst::x_iterator dst_it = dst_view.row_begin(y);
template <typename Src> dst_it[0][0] = 128 + (src_it[0][0] - src_it[1][0]) / 2;
dst_it[0][1] = 128 + (src_it[0][1] - src_it[1][1]) / 2;
dst_it[0][2] = 128 + (src_it[0][2] - src_it[1][2]) / 2;
dst_it[dst_view.width()-1][0] = 128 + (src_it[src_view.width()-2][0] - src_it[src_view.width()-1][0]) / 2;
dst_it[dst_view.width()-1][1] = 128 + (src_it[src_view.width()-2][1] - src_it[src_view.width()-1][1]) / 2;
dst_it[dst_view.width()-1][2] = 128 + (src_it[src_view.width()-2][2] - src_it[src_view.width()-1][2]) / 2;
dst_it[0][3] = dst_it[src_view.width()-1][3] = 255;
for (int x=1; x<src_view.width()-1; ++x)
{
dst_it[x][0] = 128 + (src_it[x-1][0] - src_it[x+1][0]) / 2;
dst_it[x][1] = 128 + (src_it[x-1][1] - src_it[x+1][1]) / 2;
dst_it[x][2] = 128 + (src_it[x-1][2] - src_it[x+1][2]) / 2;
dst_it[x][3] = 255;
}
}
}
template <typename Src>
void apply_filter(Src & src, x_gradient) void apply_filter(Src & src, x_gradient)
{ {
using namespace boost::gil; using namespace boost::gil;
rgba8_view_t src_view = interleaved_view(src.width(),src.height(), rgba8_view_t src_view = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(), (rgba8_pixel_t*) src.raw_data(),
src.width()*4); src.width()*4);
rgba8_image_t temp_buffer(src_view.dimensions()); rgba8_image_t temp_buffer(src_view.dimensions());
rgba8_view_t dst_view = view(temp_buffer); rgba8_view_t dst_view = view(temp_buffer);
for (int y=0; y<src_view.height(); ++y)
{ x_gradient_impl(src_view, dst_view);
rgba8_view_t::x_iterator src_it = src_view.row_begin(y); boost::gil::copy_pixels(view(temp_buffer), src_view);
rgba8_view_t::x_iterator dst_it = dst_view.row_begin(y);
for (int x=1; x<src_view.width()-1; ++x)
{
dst_it[x][0] = 127 + (src_it[x-1][0] - src_it[x+1][0]) / 2;
dst_it[x][1] = 127 + (src_it[x-1][1] - src_it[x+1][1]) / 2;
dst_it[x][2] = 127 + (src_it[x-1][2] - src_it[x+1][2]) / 2;
dst_it[x][3] = 255;
}
}
boost::gil::copy_pixels(view(temp_buffer), src_view);
} }
template <typename Src> template <typename Src>
void apply_filter(Src & src, y_gradient) void apply_filter(Src & src, y_gradient)
{ {
using namespace boost::gil; using namespace boost::gil;
rgba8_view_t in = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(),
src.width()*4);
rgba8_image_t temp_buffer(in.dimensions());
dynamic_xy_step_type<rgba8_view_t>::type src_view = rotated90ccw_view(in);
dynamic_xy_step_type<rgba8_view_t>::type dst_view = rotated90ccw_view(view(temp_buffer));
for (int y=0; y<src_view.height(); ++y)
{
dynamic_xy_step_type<rgba8_view_t>::type::x_iterator src_it = src_view.row_begin(y);
dynamic_xy_step_type<rgba8_view_t>::type::x_iterator dst_it = dst_view.row_begin(y);
for (int x=1; x<src_view.width()-1; ++x)
{
dst_it[x][0] = 127 + (src_it[x-1][0] - src_it[x+1][0]) / 2;
dst_it[x][1] = 127 + (src_it[x-1][1] - src_it[x+1][1]) / 2;
dst_it[x][2] = 127 + (src_it[x-1][2] - src_it[x+1][2]) / 2;
dst_it[x][3] = 255;
}
}
boost::gil::copy_pixels(view(temp_buffer), in);
}
template <typename Src>
void apply_filter(Src & src, invert)
{
using namespace boost::gil;
rgba8_view_t src_view = interleaved_view(src.width(),src.height(), rgba8_view_t src_view = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(), (rgba8_pixel_t*) src.raw_data(),
src.width()*4); src.width()*4);
for (int y=0; y<src_view.height(); ++y) rgba8_image_t temp_buffer(src_view.dimensions());
rgba8_view_t dst_view = view(temp_buffer);
x_gradient_impl(rotated90ccw_view(src_view), rotated90ccw_view(dst_view));
boost::gil::copy_pixels(view(temp_buffer), src_view);
}
template <typename Src>
void apply_filter(Src & src, invert)
{
using namespace boost::gil;
rgba8_view_t src_view = interleaved_view(src.width(),src.height(),
(rgba8_pixel_t*) src.raw_data(),
src.width()*4);
for (int y=0; y<src_view.height(); ++y)
{ {
rgba8_view_t::x_iterator src_itr = src_view.row_begin(y); rgba8_view_t::x_iterator src_itr = src_view.row_begin(y);
for (int x=0; x<src_view.width(); ++x) for (int x=0; x<src_view.width(); ++x)
{ {
get_color(src_itr[x],red_t()) = channel_invert(get_color(src_itr[x],red_t())); get_color(src_itr[x],red_t()) = channel_invert(get_color(src_itr[x],red_t()));
@ -368,14 +484,14 @@ template <typename Src>
struct filter_visitor : boost::static_visitor<void> struct filter_visitor : boost::static_visitor<void>
{ {
filter_visitor(Src & src) filter_visitor(Src & src)
: src_(src) {} : src_(src) {}
template <typename T> template <typename T>
void operator () (T filter_tag) void operator () (T filter_tag)
{ {
apply_filter(src_,filter_tag); apply_filter(src_,filter_tag);
} }
Src & src_; Src & src_;
}; };

View file

@ -34,7 +34,7 @@ namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix; namespace phoenix = boost::phoenix;
template <typename Iterator, typename ContType> template <typename Iterator, typename ContType>
struct image_filter_grammar : struct image_filter_grammar :
qi::grammar<Iterator, ContType(), qi::ascii::space_type> qi::grammar<Iterator, ContType(), qi::ascii::space_type>
{ {
image_filter_grammar() image_filter_grammar()
@ -59,7 +59,7 @@ struct image_filter_grammar :
; ;
#endif #endif
filter = filter =
lit("emboss")[push_back(_val,construct<mapnik::filter::emboss>())] lit("emboss")[push_back(_val,construct<mapnik::filter::emboss>())]
| |
lit("blur")[push_back(_val,construct<mapnik::filter::blur>())] lit("blur")[push_back(_val,construct<mapnik::filter::blur>())]
@ -76,16 +76,16 @@ struct image_filter_grammar :
| |
lit("y-gradient")[push_back(_val,construct<mapnik::filter::y_gradient>())] lit("y-gradient")[push_back(_val,construct<mapnik::filter::y_gradient>())]
| |
(lit("agg-stack-blur")[_a = 1, _b = 1] (lit("agg-stack-blur")[_a = 1, _b = 1]
>> -( lit(':') >> lit("rx") >> lit('=') >> radius_[_a = _1] >> -( lit(':') >> radius_[_a = _1]
>> lit(',') >> lit(',')
>> lit("ry") >> lit('=') >> radius_[_b = _1]) >> radius_[_b = _1])
[push_back(_val,construct<mapnik::filter::agg_stack_blur>(_a,_b))]) [push_back(_val,construct<mapnik::filter::agg_stack_blur>(_a,_b))])
| |
lit("invert")[push_back(_val,construct<mapnik::filter::invert>())] lit("invert")[push_back(_val,construct<mapnik::filter::invert>())]
; ;
} }
// //
qi::rule<Iterator, ContType(), qi::ascii::space_type> start; qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
qi::rule<Iterator, ContType(), qi::locals<int,int>, qi::ascii::space_type> filter; qi::rule<Iterator, ContType(), qi::locals<int,int>, qi::ascii::space_type> filter;
qi::uint_parser< unsigned, 10, 1, 3 > radius_; qi::uint_parser< unsigned, 10, 1, 3 > radius_;

View file

@ -41,9 +41,9 @@ struct agg_stack_blur
{ {
agg_stack_blur(unsigned rx_, unsigned ry_) agg_stack_blur(unsigned rx_, unsigned ry_)
: rx(rx_),ry(ry_) {} : rx(rx_),ry(ry_) {}
// an attemp to support older boost spirit (< 1.46) // an attempt to support older boost spirit (< 1.46)
agg_stack_blur() agg_stack_blur()
: rx(0),ry(0) {} : rx(1),ry(1) {}
unsigned rx; unsigned rx;
unsigned ry; unsigned ry;
}; };

View file

@ -27,6 +27,10 @@
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/palette.hpp> #include <mapnik/palette.hpp>
#ifdef _MSC_VER
#include <mapnik/graphics.hpp>
#endif
// boost // boost
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>

View file

@ -93,7 +93,7 @@ public:
class metawriter class metawriter
{ {
public: public:
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
metawriter(metawriter_properties dflt_properties) : metawriter(metawriter_properties dflt_properties) :
dflt_properties_(dflt_properties), dflt_properties_(dflt_properties),
width_(0), width_(0),

View file

@ -47,8 +47,8 @@ class string_info;
class text_path; class text_path;
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> ClippedPathType; typedef coord_transform<CoordTransform,clipped_geometry_type> ClippedPathType;
typedef coord_transform2<CoordTransform,geometry_type> PathType; typedef coord_transform<CoordTransform,geometry_type> PathType;
typedef label_collision_detector4 DetectorType; typedef label_collision_detector4 DetectorType;

View file

@ -428,7 +428,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25
else if (palette.size() == 1) else if (palette.size() == 1)
{ {
// 1 color image -> write 1-bit color depth PNG // 1 color image -> write 1-bit color depth PNG
unsigned image_width = width > 7 ? (int(0.125*width) + 1)&~1 : 1; unsigned image_width = ((width + 15) >> 3) & ~1U; // 1-bit image, round up to 16-bit boundary
unsigned image_height = height; unsigned image_height = height;
image_data_8 reduced_image(image_width,image_height); image_data_8 reduced_image(image_width,image_height);
reduce_1(image,reduced_image,trees, limits, alphaTable); reduce_1(image,reduced_image,trees, limits, alphaTable);
@ -441,7 +441,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25
else else
{ {
// <=16 colors -> write 4-bit color depth PNG // <=16 colors -> write 4-bit color depth PNG
unsigned image_width = width > 3 ? (int(0.5*width) + 3)&~3 : 4; unsigned image_width = ((width + 7) >> 1) & ~3U; // 4-bit image, round up to 32-bit boundary
unsigned image_height = height; unsigned image_height = height;
image_data_8 reduced_image(image_width,image_height); image_data_8 reduced_image(image_width,image_height);
reduce_4(image, reduced_image, trees, limits, TRANSPARENCY_LEVELS, alphaTable); reduce_4(image, reduced_image, trees, limits, TRANSPARENCY_LEVELS, alphaTable);
@ -478,7 +478,7 @@ void save_as_png8(T1 & file, T2 const& image, T3 const & tree,
else if (palette.size() == 1) else if (palette.size() == 1)
{ {
// 1 color image -> write 1-bit color depth PNG // 1 color image -> write 1-bit color depth PNG
unsigned image_width = width > 7 ? (int(0.125*width) + 1)&~1 : 1; unsigned image_width = ((width + 15) >> 3) & ~1U; // 1-bit image, round up to 16-bit boundary
unsigned image_height = height; unsigned image_height = height;
image_data_8 reduced_image(image_width, image_height); image_data_8 reduced_image(image_width, image_height);
reduced_image.set(0); reduced_image.set(0);
@ -487,7 +487,7 @@ void save_as_png8(T1 & file, T2 const& image, T3 const & tree,
else else
{ {
// <=16 colors -> write 4-bit color depth PNG // <=16 colors -> write 4-bit color depth PNG
unsigned image_width = width > 3 ? (int(0.5*width) + 3)&~3 : 4; unsigned image_width = ((width + 7) >> 1) & ~3U; // 4-bit image, round up to 32-bit boundary
unsigned image_height = height; unsigned image_height = height;
image_data_8 reduced_image(image_width, image_height); image_data_8 reduced_image(image_width, image_height);
for (unsigned y = 0; y < height; ++y) for (unsigned y = 0; y < height; ++y)

View file

@ -206,7 +206,7 @@ private:
template <class T> template <class T>
void copy_height_ptr(T & sym) const void copy_height_ptr(T & sym) const
{ {
std::string height_expr = to_expression_string(sym.height()); std::string height_expr = to_expression_string(*sym.height());
sym.set_height(parse_expression(height_expr,"utf8")); sym.set_height(parse_expression(height_expr,"utf8"));
} }
}; };

View file

@ -44,7 +44,7 @@ namespace mapnik { namespace svg {
template <typename OutputIterator> template <typename OutputIterator>
class svg_generator : private boost::noncopyable class svg_generator : private boost::noncopyable
{ {
typedef coord_transform2<CoordTransform, geometry_type> path_type; typedef coord_transform<CoordTransform, geometry_type> path_type;
typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar; typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar;
typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar; typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar;

View file

@ -94,7 +94,7 @@ BOOST_FUSION_ADAPT_STRUCT(
*/ */
namespace boost { namespace spirit { namespace traits { namespace boost { namespace spirit { namespace traits {
typedef mapnik::coord_transform2<mapnik::CoordTransform, mapnik::geometry_type> path_type; typedef mapnik::coord_transform<mapnik::CoordTransform, mapnik::geometry_type> path_type;
template <> template <>
struct is_container<path_type const> struct is_container<path_type const>

View file

@ -174,7 +174,7 @@ private:
* Each coordinate is stored twice to match the needs of the grammar. * Each coordinate is stored twice to match the needs of the grammar.
*/ */
typedef path_iterator<boost::tuple<unsigned, geometry_type::value_type, geometry_type::value_type>, typedef path_iterator<boost::tuple<unsigned, geometry_type::value_type, geometry_type::value_type>,
coord_transform2<CoordTransform, geometry_type> > path_iterator_type; coord_transform<CoordTransform, geometry_type> > path_iterator_type;
}} }}

View file

@ -269,8 +269,6 @@ public:
transform *= mtx; transform *= mtx;
double scl = transform.scale(); double scl = transform.scale();
curved_stroked_trans.transformer(transform);
curved_trans.transformer(transform);
//curved_.approximation_method(curve_inc); //curved_.approximation_method(curve_inc);
curved_.approximation_scale(scl); curved_.approximation_scale(scl);
curved_.angle_tolerance(0.0); curved_.angle_tolerance(0.0);
@ -377,8 +375,6 @@ public:
transform *= mtx; transform *= mtx;
double scl = transform.scale(); double scl = transform.scale();
curved_stroked_trans.transformer(transform);
curved_trans.transformer(transform);
//curved_.approximation_method(curve_inc); //curved_.approximation_method(curve_inc);
curved_.approximation_scale(scl); curved_.approximation_scale(scl);
curved_.angle_tolerance(0.0); curved_.angle_tolerance(0.0);

View file

@ -524,6 +524,29 @@ struct mod: public boost::static_visitor<V>
} }
}; };
template <typename V>
struct negate : public boost::static_visitor<V>
{
typedef V value_type;
template <typename T>
value_type operator() (T val) const
{
return -val;
}
value_type operator() (value_null const& val) const
{
return val;
}
value_type operator() (UnicodeString const& ustr) const
{
UnicodeString inplace(ustr);
return inplace.reverse();
}
};
struct to_bool : public boost::static_visitor<bool> struct to_bool : public boost::static_visitor<bool>
{ {
bool operator() (bool val) const bool operator() (bool val) const
@ -763,6 +786,11 @@ public:
return boost::apply_visitor(impl::less_or_equal(),base_,other.base_); return boost::apply_visitor(impl::less_or_equal(),base_,other.base_);
} }
value operator- () const
{
return boost::apply_visitor(impl::negate<value>(), base_);
}
value_base const& base() const value_base const& base() const
{ {
return base_; return base_;

View file

@ -76,7 +76,7 @@ struct converter_traits
typedef T0 geometry_type; typedef T0 geometry_type;
typedef geometry_type conv_type; typedef geometry_type conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
throw "BOOM!"; throw "BOOM!";
} }
@ -89,7 +89,7 @@ struct converter_traits<T,mapnik::smooth_tag>
typedef typename agg::conv_smooth_poly1_curve<geometry_type> conv_type; typedef typename agg::conv_smooth_poly1_curve<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
geom.smooth_value(boost::fusion::at_c<2>(args).smooth()); geom.smooth_value(boost::fusion::at_c<2>(args).smooth());
} }
@ -103,7 +103,7 @@ struct converter_traits<T, mapnik::clip_line_tag>
typedef typename agg::conv_clip_polyline<geometry_type> conv_type; typedef typename agg::conv_clip_polyline<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args); typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy());
@ -118,10 +118,11 @@ struct converter_traits<T, mapnik::dash_tag>
typedef typename agg::conv_dash<geometry_type> conv_type; typedef typename agg::conv_dash<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args); typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
double scale_factor = boost::fusion::at_c<5>(args); double scale_factor = boost::fusion::at_c<5>(args);
stroke const& stroke_ = sym.get_stroke(); stroke const& stroke_ = sym.get_stroke();
dash_array const& d = stroke_.get_dash_array(); dash_array const& d = stroke_.get_dash_array();
dash_array::const_iterator itr = d.begin(); dash_array::const_iterator itr = d.begin();
@ -142,7 +143,7 @@ struct converter_traits<T, mapnik::stroke_tag>
typedef typename agg::conv_stroke<geometry_type> conv_type; typedef typename agg::conv_stroke<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args); typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
stroke const& stroke_ = sym.get_stroke(); stroke const& stroke_ = sym.get_stroke();
@ -161,7 +162,7 @@ struct converter_traits<T,mapnik::clip_poly_tag>
typedef typename agg::conv_clip_polygon<geometry_type> conv_type; typedef typename agg::conv_clip_polygon<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args); typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy());
@ -173,10 +174,10 @@ template <typename T>
struct converter_traits<T,mapnik::transform_tag> struct converter_traits<T,mapnik::transform_tag>
{ {
typedef T geometry_type; typedef T geometry_type;
typedef coord_transform2<CoordTransform, geometry_type> conv_type; typedef coord_transform<CoordTransform, geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<3> >::type tr = boost::fusion::at_c<3>(args); typename boost::mpl::at<Args,boost::mpl::int_<3> >::type tr = boost::fusion::at_c<3>(args);
typename boost::mpl::at<Args,boost::mpl::int_<4> >::type prj_trans = boost::fusion::at_c<4>(args); typename boost::mpl::at<Args,boost::mpl::int_<4> >::type prj_trans = boost::fusion::at_c<4>(args);
@ -190,16 +191,21 @@ template <typename T>
struct converter_traits<T,mapnik::affine_transform_tag> struct converter_traits<T,mapnik::affine_transform_tag>
{ {
typedef T geometry_type; typedef T geometry_type;
typedef typename agg::conv_transform<geometry_type> conv_type;
struct conv_type : public agg::conv_transform<geometry_type>
{
agg::trans_affine trans_;
conv_type(geometry_type& geom)
: agg::conv_transform<geometry_type>(geom, trans_) {}
};
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args & args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args); typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_transform(); boost::array<double,6> const& m = sym.get_transform();
tr.load_from(&m[0]); geom.trans_.load_from(&m[0]);
geom.transformer(tr);
} }
}; };
@ -208,10 +214,10 @@ struct converter_traits<T,mapnik::offset_transform_tag>
{ {
typedef T geometry_type; typedef T geometry_type;
typedef offset_converter<geometry_type> conv_type; typedef offset_converter<geometry_type> conv_type;
template <typename Args> template <typename Args>
static void setup(geometry_type & geom, Args & args) static void setup(geometry_type & geom, Args const& args)
{ {
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args); typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
geom.set_offset(sym.offset()); geom.set_offset(sym.offset());
} }
@ -221,7 +227,7 @@ template <bool>
struct converter_fwd struct converter_fwd
{ {
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End> template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
static void forward(Base& base, T0 & geom,T1 & args) static void forward(Base& base, T0 & geom,T1 const& args)
{ {
typedef T0 geometry_type; typedef T0 geometry_type;
typedef T2 conv_tag; typedef T2 conv_tag;
@ -236,7 +242,7 @@ template <>
struct converter_fwd<true> struct converter_fwd<true>
{ {
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End> template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
static void forward(Base& base, T0 & geom,T1 & args) static void forward(Base& base, T0 & geom,T1 const& args)
{ {
base.template dispatch<Iter,End>(geom, typename boost::is_same<Iter,End>::type()); base.template dispatch<Iter,End>(geom, typename boost::is_same<Iter,End>::type());
} }
@ -249,7 +255,7 @@ struct dispatcher
typedef A args_type; typedef A args_type;
typedef C conv_types; typedef C conv_types;
dispatcher(args_type args) dispatcher(args_type const& args)
: args_(args) : args_(args)
{ {
std::memset(&vec_[0], 0, sizeof(unsigned)*vec_.size()); std::memset(&vec_[0], 0, sizeof(unsigned)*vec_.size());
@ -291,7 +297,7 @@ struct dispatcher
} }
boost::array<unsigned, boost::mpl::size<conv_types>::value> vec_; boost::array<unsigned, boost::mpl::size<conv_types>::value> vec_;
args_type args_; args_type args_;
}; };
} }
@ -315,23 +321,20 @@ struct vertex_converter : private boost::noncopyable
proj_trans_type const&, proj_trans_type const&,
double //scale-factor double //scale-factor
> args_type; > args_type;
vertex_converter(bbox_type const& b, rasterizer_type & ras, vertex_converter(bbox_type const& b, rasterizer_type & ras,
symbolizer_type const& sym, trans_type & tr, symbolizer_type const& sym, trans_type & tr,
proj_trans_type const& prj_trans, proj_trans_type const& prj_trans,
double scale_factor) double scale_factor)
: disp_(args_type(boost::cref(b),boost::ref(ras), : disp_(args_type(boost::cref(b),boost::ref(ras),
boost::cref(sym),boost::cref(tr), boost::cref(sym),boost::cref(tr),
boost::cref(prj_trans),scale_factor)) {} boost::cref(prj_trans),scale_factor)) {}
template <typename Geometry> template <typename Geometry>
void apply(Geometry & geom) void apply(Geometry & geom)
{ {
typedef Geometry geometry_type; typedef Geometry geometry_type;
//BOOST_FOREACH(geometry_type & geom, cont) disp_.template apply<geometry_type>(geom);
{
disp_.template apply<geometry_type>(geom);
}
} }
template <typename Conv> template <typename Conv>

View file

@ -47,7 +47,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base; typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer; typedef agg::renderer_scanline_aa_solid<ren_base> renderer;

View file

@ -54,7 +54,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
typedef agg::rgba8 color_type; typedef agg::rgba8 color_type;
typedef agg::order_rgba order_type; typedef agg::order_rgba order_type;
typedef agg::pixel32_type pixel_type; typedef agg::pixel32_type pixel_type;

View file

@ -53,8 +53,8 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4); agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
ras_ptr->reset(); ras_ptr->reset();
set_gamma_method(sym,ras_ptr); set_gamma_method(sym,ras_ptr);
@ -80,71 +80,71 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
} }
boost::optional<image_ptr> pat = (*marker)->get_bitmap_data(); boost::optional<image_ptr> pat = (*marker)->get_bitmap_data();
if (!pat) return; if (!pat) return;
typedef agg::rgba8 color; typedef agg::rgba8 color;
typedef agg::order_rgba order; typedef agg::order_rgba order;
typedef agg::pixel32_type pixel_type; typedef agg::pixel32_type pixel_type;
typedef agg::comp_op_adaptor_rgba<color, order> blender_type; typedef agg::comp_op_adaptor_rgba<color, order> blender_type;
typedef agg::wrap_mode_repeat wrap_x_type; typedef agg::wrap_mode_repeat wrap_x_type;
typedef agg::wrap_mode_repeat wrap_y_type; typedef agg::wrap_mode_repeat wrap_y_type;
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type; typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32, typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
wrap_x_type, wrap_x_type,
wrap_y_type> img_source_type; wrap_y_type> img_source_type;
typedef agg::span_pattern_rgba<img_source_type> span_gen_type; typedef agg::span_pattern_rgba<img_source_type> span_gen_type;
typedef agg::renderer_base<pixfmt_type> ren_base; typedef agg::renderer_base<pixfmt_type> ren_base;
typedef agg::renderer_scanline_aa<ren_base, typedef agg::renderer_scanline_aa<ren_base,
agg::span_allocator<agg::rgba8>, agg::span_allocator<agg::rgba8>,
span_gen_type> renderer_type; span_gen_type> renderer_type;
pixfmt_type pixf(buf); pixfmt_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op())); pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
ren_base renb(pixf); ren_base renb(pixf);
unsigned w=(*pat)->width(); unsigned w=(*pat)->width();
unsigned h=(*pat)->height(); unsigned h=(*pat)->height();
agg::rendering_buffer pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4); agg::rendering_buffer pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4);
agg::pixfmt_rgba32 pixf_pattern(pattern_rbuf); agg::pixfmt_rgba32 pixf_pattern(pattern_rbuf);
pixf_pattern.premultiply();
img_source_type img_src(pixf_pattern); img_source_type img_src(pixf_pattern);
unsigned num_geometries = feature->num_geometries();
pattern_alignment_e align = sym.get_alignment(); pattern_alignment_e align = sym.get_alignment();
unsigned offset_x=0; unsigned offset_x=0;
unsigned offset_y=0; unsigned offset_y=0;
if (align == LOCAL_ALIGNMENT) if (align == LOCAL_ALIGNMENT)
{ {
double x0=0,y0=0; double x0 = 0;
if (num_geometries>0) double y0 = 0;
if (feature->num_geometries() > 0)
{ {
clipped_geometry_type clipped(feature->get_geometry(0)); clipped_geometry_type clipped(feature->get_geometry(0));
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy()); clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
path_type path(t_,clipped,prj_trans); path_type path(t_,clipped,prj_trans);
path.vertex(&x0,&y0); path.vertex(&x0,&y0);
} }
offset_x = unsigned(width_-x0); offset_x = unsigned(width_ - x0);
offset_y = unsigned(height_-y0); offset_y = unsigned(height_ - y0);
} }
span_gen_type sg(img_src, offset_x, offset_y); span_gen_type sg(img_src, offset_x, offset_y);
agg::span_allocator<agg::rgba8> sa; agg::span_allocator<agg::rgba8> sa;
renderer_type rp(renb,sa, sg); renderer_type rp(renb,sa, sg);
box2d<double> inflated_extent = query_extent_ * 1.0; box2d<double> inflated_extent = query_extent_ * 1.0;
typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>,rasterizer,polygon_pattern_symbolizer, proj_transform, CoordTransform,conv_types> vertex_converter<box2d<double>,rasterizer,polygon_pattern_symbolizer, proj_transform, CoordTransform,conv_types>
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans, scale_factor_); converter(inflated_extent,*ras_ptr,sym,t_,prj_trans, scale_factor_);
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true) if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
converter.set<transform_tag>(); //always transform converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature->paths())
{ {
if (geom.num_points() > 2) if (geom.num_points() > 2)
@ -162,4 +162,3 @@ template void agg_renderer<image_32>::process(polygon_pattern_symbolizer const&,
proj_transform const&); proj_transform const&);
} }

View file

@ -75,10 +75,7 @@ if env['RUNTIME_LINK'] == 'static':
lib_env['LIBS'].append('icudata') lib_env['LIBS'].append('icudata')
lib_env['LIBS'].append('icui18n') lib_env['LIBS'].append('icui18n')
else: else:
if env['INTERNAL_LIBAGG']: lib_env['LIBS'].insert(0, 'agg')
lib_env['LIBS'].insert(0, 'agg')
else:
lib_env['LIBS'].append([lib for lib in env['LIBS'] if lib.startswith('agg')])
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
mapnik_libname = env.subst(env['MAPNIK_LIB_NAME']) mapnik_libname = env.subst(env['MAPNIK_LIB_NAME'])

View file

@ -46,6 +46,7 @@
#include <cairomm/context.h> #include <cairomm/context.h>
#include <cairomm/surface.h> #include <cairomm/surface.h>
#include <cairo-ft.h> #include <cairo-ft.h>
#include <cairo-version.h>
// boost // boost
#include <boost/utility.hpp> #include <boost/utility.hpp>
@ -382,6 +383,8 @@ public:
case minus: case minus:
case invert: case invert:
case invert_rgb: case invert_rgb:
case grain_merge:
case grain_extract:
break; break;
} }
} }
@ -854,7 +857,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
cairo_context context(context_); cairo_context context(context_);
context.set_operator(sym.comp_op()); context.set_operator(sym.comp_op());
@ -864,7 +867,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature), *height_expr);
height = 0.7071 * result.to_double(); height = result.to_double(); //scale_factor is always 1.0 atm
} }
for (unsigned i = 0; i < feature->num_geometries(); ++i) for (unsigned i = 0; i < feature->num_geometries(); ++i)
@ -946,11 +949,11 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
} }
path_type path(t_, *frame, prj_trans); //path_type path(t_, *frame, prj_trans);
context.set_color(128, 128, 128, sym.get_opacity()); //context.set_color(128, 128, 128, sym.get_opacity());
context.add_path(path); //context.add_path(path);
context.stroke(); //context.stroke();
path_type roof_path(t_, *roof, prj_trans); path_type roof_path(t_, *roof, prj_trans);
context.set_color(sym.get_fill(), sym.get_opacity()); context.set_color(sym.get_fill(), sym.get_opacity());
context.add_path(roof_path); context.add_path(roof_path);
@ -1023,7 +1026,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
mtx.translate(pos.x+0.5 * marker.width(), pos.y+0.5 * marker.height()); mtx.translate(pos.x+0.5 * marker.width(), pos.y+0.5 * marker.height());
} }
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
agg::trans_affine transform; agg::trans_affine transform;
mapnik::path_ptr vmarker = *marker.get_vector_data(); mapnik::path_ptr vmarker = *marker.get_vector_data();
using namespace mapnik::svg; using namespace mapnik::svg;
@ -1072,12 +1075,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
else if(attr.fill_flag) else if(attr.fill_flag)
{ {
context.set_color(attr.fill_color.r,attr.fill_color.g,attr.fill_color.b,attr.opacity*opacity); double fill_opacity = attr.opacity * opacity * attr.fill_color.opacity();
context.set_color(attr.fill_color.r,attr.fill_color.g,attr.fill_color.b, fill_opacity);
context.fill(); context.fill();
} }
} }
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT || attr.stroke_flag) if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT || attr.stroke_flag)
{ {
context.add_agg_path(svg_path,attr.index); context.add_agg_path(svg_path,attr.index);
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT) if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
@ -1090,9 +1094,10 @@ void cairo_renderer_base::start_map_processing(Map const& map)
context.set_gradient(g,bbox); context.set_gradient(g,bbox);
context.stroke(); context.stroke();
} }
else if(attr.stroke_flag) else if (attr.stroke_flag)
{ {
context.set_color(attr.stroke_color.r,attr.stroke_color.g,attr.stroke_color.b,attr.opacity*opacity); double stroke_opacity = attr.opacity * opacity * attr.stroke_color.opacity();
context.set_color(attr.stroke_color.r,attr.stroke_color.g,attr.stroke_color.b, stroke_opacity);
context.set_line_width(attr.stroke_width); context.set_line_width(attr.stroke_width);
context.set_line_cap(line_cap_enum(attr.line_cap)); context.set_line_cap(line_cap_enum(attr.line_cap));
context.set_line_join(line_join_enum(attr.line_join)); context.set_line_join(line_join_enum(attr.line_join));
@ -1202,7 +1207,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true);
@ -1363,7 +1368,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
double scale_factor_ = 1; double scale_factor_ = 1;
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
agg::trans_affine tr; agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_image_transform(); boost::array<double,6> const& m = sym.get_image_transform();

View file

@ -106,7 +106,7 @@ struct feature_style_processor<Processor>::symbol_dispatch : public boost::stati
} }
Processor & output_; Processor & output_;
mapnik::feature_ptr f_; mapnik::feature_ptr const& f_;
proj_transform const& prj_trans_; proj_transform const& prj_trans_;
}; };

View file

@ -40,7 +40,7 @@ void expression_format::to_xml(boost::property_tree::ptree &xml) const
ptree &new_node = xml.push_back(ptree::value_type("ExpressionFormat", ptree()))->second; ptree &new_node = xml.push_back(ptree::value_type("ExpressionFormat", ptree()))->second;
if (face_name) set_attr(new_node, "face-name", to_expression_string(*face_name)); if (face_name) set_attr(new_node, "face-name", to_expression_string(*face_name));
if (text_size) set_attr(new_node, "size", to_expression_string(*text_size)); if (text_size) set_attr(new_node, "size", to_expression_string(*text_size));
if (character_spacing) set_attr(new_node, "character-spacing", to_expression_string*character_spacing); if (character_spacing) set_attr(new_node, "character-spacing", to_expression_string(*character_spacing));
if (line_spacing) set_attr(new_node, "line-spacing", to_expression_string(*line_spacing)); if (line_spacing) set_attr(new_node, "line-spacing", to_expression_string(*line_spacing));
if (text_opacity) set_attr(new_node, "opacity", to_expression_string(*text_opacity)); if (text_opacity) set_attr(new_node, "opacity", to_expression_string(*text_opacity));
if (wrap_before) set_attr(new_node, "wrap-before", to_expression_string(*wrap_before)); if (wrap_before) set_attr(new_node, "wrap-before", to_expression_string(*wrap_before));

View file

@ -104,7 +104,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
{ {
if (marker.is_vector()) if (marker.is_vector())
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -46,7 +46,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -45,7 +45,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -45,7 +45,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -55,7 +55,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -44,7 +44,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -44,7 +44,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base; typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer; typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl; agg::scanline_bin sl;

View file

@ -67,7 +67,10 @@ static const comp_op_lookup_type comp_lookup = boost::assign::list_of<comp_op_lo
(exclusion,"exclusion") (exclusion,"exclusion")
(contrast,"contrast") (contrast,"contrast")
(invert,"invert") (invert,"invert")
(invert_rgb,"invert-rgb"); (invert_rgb,"invert-rgb")
(grain_merge,"grain-merge")
(grain_extract,"grain-extract")
;
boost::optional<composite_mode_e> comp_op_from_string(std::string const& name) boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
{ {

View file

@ -936,7 +936,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym)
} }
boost::array<double,6> matrix; boost::array<double,6> matrix;
tr.store_to(&matrix[0]); tr.store_to(&matrix[0]);
symbol.set_transform(matrix); symbol.set_image_transform(matrix);
} }
} }
catch (image_reader_exception const & ex) catch (image_reader_exception const & ex)

View file

@ -7,6 +7,7 @@
// agg // agg
#include "agg_basics.h" #include "agg_basics.h"
#include "agg_conv_clip_polyline.h" #include "agg_conv_clip_polyline.h"
#include "agg_trans_affine.h"
// stl // stl
#include <cmath> #include <cmath>
@ -191,18 +192,23 @@ bool markers_placement<Locator, Detector>::get_point(
template <typename Locator, typename Detector> template <typename Locator, typename Detector>
box2d<double> markers_placement<Locator, Detector>::perform_transform(double angle, double dx, double dy) box2d<double> markers_placement<Locator, Detector>::perform_transform(double angle, double dx, double dy)
{ {
double c = cos(angle), s = sin(angle);
double x1 = size_.minx(); double x1 = size_.minx();
double x2 = size_.maxx(); double x2 = size_.maxx();
double y1 = size_.miny(); double y1 = size_.miny();
double y2 = size_.maxy(); double y2 = size_.maxy();
double x1_ = dx + x1 * c - y1 * s; agg::trans_affine tr = agg::trans_affine_rotation(angle).translate(dx, dy);
double y1_ = dy + x1 * s + y1 * c;
double x2_ = dx + x2 * c - y2 * s;
double y2_ = dy + x2 * s + y2 * c;
return box2d<double>(x1_, y1_, x2_, y2_); double xA = x1, yA = y1, xB = x2, yB = y1, xC = x2, yC = y2, xD = x1, yD = y2;
tr.transform(&xA, &yA);
tr.transform(&xB, &yB);
tr.transform(&xC, &yC);
tr.transform(&xD, &yD);
box2d<double> result(xA, yA, xB, yB);
result.expand_to_include(xC, yC);
result.expand_to_include(xD, yD);
return result;
} }
template <typename Locator, typename Detector> template <typename Locator, typename Detector>
@ -226,8 +232,8 @@ void markers_placement<Locator, Detector>::set_spacing_left(double sl, bool allo
} }
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> clipped_path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> clipped_path_type;
template class markers_placement<path_type, label_collision_detector4>; template class markers_placement<path_type, label_collision_detector4>;
template class markers_placement<clipped_path_type, label_collision_detector4>; template class markers_placement<clipped_path_type, label_collision_detector4>;

View file

@ -33,7 +33,6 @@
// STL // STL
#include <iomanip> #include <iomanip>
#include <cstdio>
namespace mapnik { namespace mapnik {
@ -334,7 +333,10 @@ void metawriter_json::start(metawriter_property_map const& properties)
void metawriter_json::write_header() void metawriter_json::write_header()
{ {
f_.open(filename_.c_str(), std::fstream::out | std::fstream::trunc); f_.open(filename_.c_str(), std::fstream::out | std::fstream::trunc);
if (f_.fail()) perror((std::string("Metawriter JSON: Failed to open file ") + filename_).c_str()); if (f_.fail())
{
MAPNIK_LOG_DEBUG(metawriter) << "metawriter_json: Failed to open file " << filename_;
}
set_stream(&f_); set_stream(&f_);
metawriter_json_stream::write_header(); metawriter_json_stream::write_header();
} }

View file

@ -32,7 +32,7 @@ bool svg_renderer<OutputIterator>::process(rule::symbolizers const& syms,
{ {
// svg renderer supports processing of multiple symbolizers. // svg renderer supports processing of multiple symbolizers.
typedef coord_transform2<CoordTransform, geometry_type> path_type; typedef coord_transform<CoordTransform, geometry_type> path_type;
// process each symbolizer to collect its (path) information. // process each symbolizer to collect its (path) information.
// path information (attributes from line_ and polygon_ symbolizers) // path information (attributes from line_ and polygon_ symbolizers)

View file

@ -53,7 +53,7 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_line_placement()
} }
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
clipped_geometry_type clipped(**geo_itr_); clipped_geometry_type clipped(**geo_itr_);
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy()); clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
path_type path(t_, clipped, prj_trans_); path_type path(t_, clipped, prj_trans_);

View file

@ -24,6 +24,7 @@
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/text_symbolizer.hpp> #include <mapnik/text_symbolizer.hpp>
#include <mapnik/enumeration.hpp> #include <mapnik/enumeration.hpp>
#include <mapnik/formatting/text.hpp>
// boost // boost
@ -137,7 +138,9 @@ text_symbolizer& text_symbolizer::operator=(text_symbolizer const& other)
expression_ptr text_symbolizer::get_name() const expression_ptr text_symbolizer::get_name() const
{ {
return expression_ptr(); formatting::text_node *node = dynamic_cast<formatting::text_node *>(placement_options_->defaults.format_tree().get());
if (!node) return expression_ptr();
return node->get_text();
} }
void text_symbolizer::set_name(expression_ptr name) void text_symbolizer::set_name(expression_ptr name)

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="transparent">
<Style name="white" filter-mode="first">
<Rule>
<RasterSymbolizer opacity="1" scaling="bilinear" />
</Rule>
</Style>
<Layer name="white"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<StyleName>white</StyleName>
<Datasource>
<Parameter name="file">../raster/transp.tiff</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
</Map>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="red">
<Style name="white" filter-mode="first">
<Rule>
<RasterSymbolizer opacity="1" scaling="bilinear" />
</Rule>
</Style>
<Layer name="white"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<StyleName>white</StyleName>
<Datasource>
<Parameter name="file">../raster/white-alpha.tiff</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
</Map>

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
from nose.tools import *
from utilities import execution_path
from copy import deepcopy
import os, mapnik
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
def test_map_alpha_compare():
m = mapnik.Map(600,400)
mapnik.load_map(m,'../data/good_maps/raster-alpha.xml')
m.zoom_all()
actual = '/tmp/mapnik-raster-alpha.png'
expected = 'images/support/raster-alpha.png'
im = mapnik.Image(m.width,m.height)
mapnik.render(m,im)
im.save(actual)
expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
if __name__ == "__main__":
setup()
[eval(run)() for run in dir() if 'test_' in run]

View file

@ -56,8 +56,8 @@ ldflags = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_en
dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']]) dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])
if env['INTERNAL_LIBAGG']: # remove local agg from public linking
dep_libs = dep_libs.replace('-lagg','') dep_libs = dep_libs.replace('-lagg','')
git_revision = os.popen("git rev-list --max-count=1 HEAD").read() git_revision = os.popen("git rev-list --max-count=1 HEAD").read()