diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a61da5f6..2e44500b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ For a complete change history, see the git log. Not yet released +- Increased grid encoding performance (#1315) + - Added support for overriding fill, stroke, and opacity for svg markers using marker properties - Added support for setting opacity dynamically on images in polygon pattern and markers symbolizers @@ -135,7 +137,7 @@ Released September 26, 2011 - Add support for png quantization using fixed palettes (#843) -- Add AlsoFilter functionality - http://trac.mapnik.org/wiki/AlsoFilter +- Add AlsoFilter functionality - https://github.com/mapnik/mapnik/wiki/AlsoFilter - SQLite Plugin: optimize i/o using shared cache and no mutexes (#797) @@ -224,7 +226,7 @@ Released Oct 18, 2011 (Packaged from bc5cabeb6a) -- Added forward compatibility for Mapnik 2.0 XML syntax (https://trac.mapnik.org/wiki/Mapnik2/Changes) +- Added forward compatibility for Mapnik 2.0 XML syntax (https://github.com/mapnik/mapnik/wiki/Mapnik2/Changes) - Build fixes to ensure boost_threads are not used unless THREADING=multi build option is used diff --git a/INSTALL.md b/INSTALL.md index d525be56a..c9e46de45 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -15,9 +15,9 @@ If you need to uninstall do: For more details see the 'Building' Section below. -Platform specific install guides at http://trac.mapnik.org/wiki/MapnikInstallation +Platform specific install guides at https://github.com/mapnik/mapnik/wiki/Mapnik-Installation -For troubleshooting help see http://trac.mapnik.org/wiki/InstallationTroubleshooting +For troubleshooting help see https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting ## Depends @@ -26,7 +26,7 @@ Mapnik is cross platform and runs on Linux, Mac OSX, Solaris, *BSD, and Windows. The build system should work for all posix/unix systems but for windows see: - http://trac.mapnik.org/wiki/BuildingOnWindows + https://github.com/mapnik/mapnik/wiki/BuildingOnWindows Build dependencies are: @@ -74,7 +74,7 @@ Optional dependencies: Instructions for installing many of these dependencies on various platforms can be found at the Mapnik Community Wiki -(http://trac.mapnik.org/wiki/MapnikInstallation). +(https://github.com/mapnik/mapnik/wiki/Mapnik-Installation). @@ -124,7 +124,7 @@ If you want to see configure options do: For more details on all the options see: - http://trac.mapnik.org/wiki/UsingScons + https://github.com/mapnik/mapnik/wiki/UsingScons ## Testing Installation @@ -155,11 +155,11 @@ For further tests see the `tests` folder within the Mapnik source code. ### Users -Visit http://trac.mapnik.org/wiki/LearningMapnik for basic tutorials on making maps with Mapnik using the Python bindings. +Visit https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic tutorials on making maps with Mapnik using the Python bindings. ### Developers -Visit http://trac.mapnik.org/#DevelopersCorner for resources for getting involved with Mapnik development. +Read docs/contributing.markdown for resources for getting involved with Mapnik development. ## Mapnik Community @@ -168,22 +168,7 @@ Visit http://trac.mapnik.org/#DevelopersCorner for resources for getting involve Mapnik has an active community of talented users and developers making amazing maps. -If you are looking for further help on installation or usage and you can't -find what you are looking for from searching the users list archives -(http://lists.berlios.de/pipermail/mapnik-users/) or the trac wiki -(http://trac.mapnik.org/), feel free to join the Mapnik community and -introduce yourself. +Please feel free to subscribe to the community list and post on both +usage and development topics: http://mapnik.org/contact/ -You can get involved by: - - * Subscribing to the mapnik-users list: - - http://lists.berlios.de/mailman/listinfo/mapnik-users - - * Subscribing to the mapnik-developers list: - - http://lists.berlios.de/mailman/listinfo/mapnik-devel - - * Joining the #mapnik channel on irc://irc.freenode.net/mapnik - - * Signing up as a user or contributor at http://www.ohloh.net/p/mapnik/ +You can also get involved by joining the #mapnik channel on irc://irc.freenode.net/mapnik diff --git a/Makefile b/Makefile index 9ed95ef70..58b999acc 100755 --- a/Makefile +++ b/Makefile @@ -1,21 +1,24 @@ all: mapnik install: - @python scons/scons.py --config=cache --implicit-deps-unchanged --max-drift=1 install + @python scons/scons.py --config=cache --implicit-cache --max-drift=1 install mapnik: - @python scons/scons.py --config=cache --implicit-deps-unchanged --max-drift=1 + @python scons/scons.py --config=cache --implicit-cache --max-drift=1 clean: - python scons/scons.py -c --config=cache --implicit-deps-unchanged --max-drift=1 + @python scons/scons.py -c --config=cache --implicit-cache --max-drift=1 + @if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi -reset: +distclean: if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi if test -e "config.cache"; then rm "config.cache"; fi +reset: distclean + uninstall: - python scons/scons.py --config=cache --implicit-deps-unchanged --max-drift=1 uninstall + python scons/scons.py --config=cache --implicit-cache --max-drift=1 uninstall test: @echo "*** Running visual tests..." @@ -27,6 +30,10 @@ test: @echo "*** Running python tests..." @python tests/run_tests.py -q +demo: + @echo "*** Running rundemo.cpp…" + cd demo/c++; ./rundemo `mapnik-config --prefix`/lib/mapnik + pep8: # https://gist.github.com/1903033 # gsed on osx @@ -43,4 +50,4 @@ render: nik2img.py $${FILE} /tmp/$$(basename $${FILE}).png; \ done -.PHONY: clean reset uninstall test install +.PHONY: clean reset uninstall test install demo diff --git a/SConstruct b/SConstruct index 755eb0f0a..2d5b057e1 100644 --- a/SConstruct +++ b/SConstruct @@ -32,10 +32,8 @@ try: except: HAS_DISTUTILS = False -if platform.uname()[4] == 'ppc64': - LIBDIR_SCHEMA='lib64' -else: - LIBDIR_SCHEMA='lib' +LIBDIR_SCHEMA_DEFAULT='lib' +severities = ['debug', 'warn', 'error', 'none'] py3 = None @@ -57,17 +55,17 @@ DEFAULT_LINK_PRIORITY = ['internal','other','frameworks','user','system'] pretty_dep_names = { - 'ociei':'Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: http://trac.mapnik.org/wiki/OCCI', - 'gdal':'GDAL C++ library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: http://trac.mapnik.org/wiki/GDAL', - 'ogr':'OGR-enabled GDAL C++ Library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: http://trac.mapnik.org/wiki/OGR', - 'geos_c':'GEOS Simple Geometry Specification C Library | configured with GEOS_LIB & GEOS_INCLUDE | more info: http://trac.mapnik.org/wiki/GEOS', + 'ociei':'Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki//OCCI', + 'gdal':'GDAL C++ library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: https://github.com/mapnik/mapnik/wiki/GDAL', + 'ogr':'OGR-enabled GDAL C++ Library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: https://github.com/mapnik/mapnik/wiki//OGR', + 'geos_c':'GEOS Simple Geometry Specification C Library | configured with GEOS_LIB & GEOS_INCLUDE | more info: https://github.com/mapnik/mapnik/wiki//GEOS', 'cairo':'Cairo C library | configured using pkg-config | try setting PKG_CONFIG_PATH SCons option', 'cairomm':'Cairomm C++ bindings to Cairo library | configured using pkg-config | try setting PKG_CONFIG_PATH SCons option', 'cairomm-version':'Cairomm version is too old (so cairo renderer will not be built), you need at least %s' % CAIROMM_MIN_VERSION, 'pycairo':'Python bindings to Cairo library | configured using pkg-config | try setting PKG_CONFIG_PATH SCons option', 'proj':'Proj.4 C Projections library | configure with PROJ_LIBS & PROJ_INCLUDES | more info: http://trac.osgeo.org/proj/', - 'pg':'Postgres C Library requiered for PostGIS plugin | configure with pg_config program | more info: http://trac.mapnik.org/wiki/PostGIS', - 'sqlite3':'SQLite3 C Library | configure with SQLITE_LIBS & SQLITE_INCLUDES | more info: http://trac.mapnik.org/wiki/SQLite', + 'pg':'Postgres C Library requiered for PostGIS plugin | configure with pg_config program | more info: https://github.com/mapnik/mapnik/wiki//PostGIS', + 'sqlite3':'SQLite3 C Library | configure with SQLITE_LIBS & SQLITE_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki//SQLite', 'jpeg':'JPEG C library | configure with JPEG_LIBS & JPEG_INCLUDES', 'tiff':'TIFF C library | configure with TIFF_LIBS & TIFF_INCLUDES', 'png':'PNG C library | configure with PNG_LIBS & PNG_INCLUDES', @@ -81,8 +79,8 @@ pretty_dep_names = { 'gdal-config':'gdal-config program | try setting GDAL_CONFIG SCons option', 'geos-config':'geos-config program | try setting GEOS_CONFIG SCons option', 'freetype-config':'freetype-config program | try setting FREETYPE_CONFIG SCons option', - 'osm':'more info: http://trac.mapnik.org/wiki/OsmPlugin', - 'curl':'libcurl is required for the "osm" plugin - more info: http://trac.mapnik.org/wiki/OsmPlugin', + 'osm':'more info: https://github.com/mapnik/mapnik/wiki//OsmPlugin', + 'curl':'libcurl is required for the "osm" plugin - more info: https://github.com/mapnik/mapnik/wiki//OsmPlugin', 'boost_regex_icu':'libboost_regex built with optional ICU unicode support is needed for unicode regex support in mapnik.', '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)' @@ -141,7 +139,7 @@ def call(cmd, silent=False): if not stderr: return stdin.strip() elif not silent: - color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr) + color_print(1,'Problem encounted with SCons scripts, please post bug report to: https://github.com/mapnik/mapnik/issues \nError was: %s' % stderr) def strip_first(string,find,replace=''): if string.startswith(find): @@ -247,7 +245,7 @@ def pretty_dep(dep): if pretty: return '%s (%s)' % (dep,pretty) elif 'boost' in dep: - return '%s (%s)' % (dep,'more info see: http://trac.mapnik.org/wiki/MapnikInstallation & http://www.boost.org') + return '%s (%s)' % (dep,'more info see: https://github.com/mapnik/mapnik/wiki//MapnikInstallation & http://www.boost.org') return dep @@ -287,6 +285,7 @@ opts.AddVariables( # Install Variables ('PREFIX', 'The install path "prefix"', '/usr/local'), + ('LIBDIR_SCHEMA', 'The library sub-directory appended to the "prefix", sometimes lib64 on 64bit linux systems', LIBDIR_SCHEMA_DEFAULT), ('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''), ('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'), ('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)', ''), @@ -307,17 +306,17 @@ opts.AddVariables( ('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'), ('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'), PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept), - PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), ('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_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), 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_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept), - PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA, 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('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), + PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/include', PathVariable.PathAccept), + PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), ('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 @@ -336,16 +335,16 @@ opts.AddVariables( ('GDAL_CONFIG', 'The path to the gdal-config executable for finding gdal and ogr details.', 'gdal-config'), ('PG_CONFIG', 'The path to the pg_config executable.', 'pg_config'), PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include', PathVariable.PathAccept), - PathVariable('OCCI_LIBS', 'Search path for OCCI library files', '/usr/lib/oracle/10.2.0.3/client/'+ LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('OCCI_LIBS', 'Search path for OCCI library files', '/usr/lib/oracle/10.2.0.3/client/'+ LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('SQLITE_INCLUDES', 'Search path for SQLITE include files', '/usr/include/', PathVariable.PathAccept), - PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('RASTERLITE_INCLUDES', 'Search path for RASTERLITE include files', '/usr/include/', PathVariable.PathAccept), - PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), + PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), # Variables for logging and statistics BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'), BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'), - ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. "info", "debug", "warn", "error", "fatal", "none")', 'error'), + ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities), 'error'), # Other variables BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), @@ -657,7 +656,7 @@ def FindBoost(context, prefixes, thread_flag): prefixes.insert(0,os.path.dirname(os.path.normpath(env['BOOST_INCLUDES']))) prefixes.insert(0,os.path.dirname(os.path.normpath(env['BOOST_LIBS']))) for searchDir in prefixes: - libItems = glob(os.path.join(searchDir, LIBDIR_SCHEMA, '%s*.*' % search_lib)) + libItems = glob(os.path.join(searchDir, env['LIBDIR_SCHEMA'], '%s*.*' % search_lib)) if not libItems: libItems = glob(os.path.join(searchDir, 'lib/%s*.*' % search_lib)) incItems = glob(os.path.join(searchDir, 'include/boost*/')) @@ -676,7 +675,7 @@ def FindBoost(context, prefixes, thread_flag): msg += '\n *libs found: %s' % BOOST_LIB_DIR env['BOOST_LIBS'] = BOOST_LIB_DIR else: - env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA + env['BOOST_LIBS'] = '/usr/' + env['LIBDIR_SCHEMA'] msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS'] if BOOST_INCLUDE_DIR: @@ -958,7 +957,6 @@ if not preconfigured: env['LIBMAPNIK_LIBS'] = [] env['LIBMAPNIK_CPPATHS'] = [] env['LIBMAPNIK_CXXFLAGS'] = [] - env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA env['PLUGINS'] = PLUGINS env['EXTRA_FREETYPE_LIBS'] = [] env['SQLITE_LINKFLAGS'] = [] @@ -1245,6 +1243,10 @@ if not preconfigured: env.PrependUnique(LIBPATH = '#src', delete_existing=True) if env['PGSQL2SQLITE']: + if 'sqlite3' not in env['LIBS']: + env.AppendUnique(LIBS='sqlite3') + env.AppendUnique(CPPPATH = os.path.realpath(env['SQLITE_INCLUDES'])) + env.AppendUnique(LIBPATH = os.path.realpath(env['SQLITE_LIBS'])) if not conf.sqlite_has_rtree(): env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree') env['PGSQL2SQLITE'] = False @@ -1391,11 +1393,6 @@ if not preconfigured: color_print(1,'Could not find required header files for boost python') env['MISSING_DEPS'].append('boost python') - if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB'],'python%s' % env['PYTHON_VERSION']], header='boost/python/detail/config.hpp', language='C++'): - color_print(1, 'Could not find library "%s" for boost python bindings' % env['BOOST_PYTHON_LIB']) - # failing on launchpad, so let's make it a warning for now - #env['MISSING_DEPS'].append('boost python') - if env['CAIRO']: if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): env['HAS_PYCAIRO'] = True @@ -1419,7 +1416,7 @@ if not preconfigured: color_print(4," $ sudo python scons/scons.py install") color_print(4,"\nTo view available path variables:\n $ python scons/scons.py --help or -h") color_print(4,'\nTo view overall SCons help options:\n $ python scons/scons.py --help-options or -H\n') - color_print(4,'More info: http://trac.mapnik.org/wiki/MapnikInstallation') + color_print(4,'More info: https://github.com/mapnik/mapnik/wiki//MapnikInstallation') if not HELP_REQUESTED: Exit(1) else: @@ -1478,7 +1475,6 @@ if not preconfigured: ndebug_flags = '-DNDEBUG' # 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'] not in severities: severities_list = ', '.join(["'%s'" % s for s in severities]) @@ -1662,11 +1658,6 @@ if not HELP_REQUESTED: SetOption('implicit_cache', 1) SetOption('max_drift', 1) - else: - # 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 - SetCacheMode('force') - if env['JOBS'] > 1: SetOption("num_jobs", env['JOBS']) @@ -1699,7 +1690,6 @@ if not HELP_REQUESTED: 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) # before installing plugins, wipe out any previously # installed plugins that we are no longer building @@ -1715,20 +1705,21 @@ if not HELP_REQUESTED: if env['DEMO']: SConscript('demo/c++/build.py') - # Build the pgsql2psqlite app if requested - if env['PGSQL2SQLITE']: - SConscript('utils/pgsql2sqlite/build.py') - # Build shapeindex and remove its dependency from the LIBS if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']: SConscript('utils/shapeindex/build.py') + # Build the pgsql2psqlite app if requested + if env['PGSQL2SQLITE']: + SConscript('utils/pgsql2sqlite/build.py') + + SConscript('utils/svg2png/build.py') + # devtools not ready for public #SConscript('utils/ogrindex/build.py') - SConscript('utils/svg2png/build.py') env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND']) 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' and other command line programs will not be available") # Build the Python bindings if 'python' in env['BINDINGS']: diff --git a/bindings/python/build.py b/bindings/python/build.py index 646b2eeaf..8d5a9be43 100644 --- a/bindings/python/build.py +++ b/bindings/python/build.py @@ -65,7 +65,7 @@ if env['PLATFORM'] == 'Darwin': # 3) the below will directly link _mapnik.so to a python version # 4) _mapnik.so must link to the same python lib as boost_python.dylib otherwise # python will Abort with a Version Mismatch error. - # See http://trac.mapnik.org/ticket/453 for the seeds of a better approach + # See https://github.com/mapnik/mapnik/issues/453 for the seeds of a better approach # for now we offer control over method of direct linking... # The default below is to link against the python dylib in the form of #/path/to/Python.framework/Python instead of -lpython @@ -86,7 +86,7 @@ if env['PLATFORM'] == 'Darwin': # /System/Library/Frameworks/Python.framework/Python/Versions/ # or # /Library/Frameworks/Python.framework/Python/Versions/ - # See: http://trac.mapnik.org/ticket/380 + # See: https://github.com/mapnik/mapnik/issues/380 link_prefix = env['PYTHON_SYS_PREFIX'] if '.framework' in link_prefix: python_link_flag = '-F%s -framework Python -Z' % os.path.dirname(link_prefix.split('.')[0]) @@ -143,8 +143,14 @@ try: os.chmod('mapnik/paths.py',0666) except: pass -# install the core mapnik python files, including '__init__.py' +# install the shared object beside the module directory +sources = glob.glob('*.cpp') + +py_env = env.Clone() +py_env.Append(CPPPATH = env['PYTHON_INCLUDES']) + if 'install' in COMMAND_LINE_TARGETS: + # install the core mapnik python files, including '__init__.py' init_files = glob.glob('mapnik/*.py') if 'mapnik/paths.py' in init_files: init_files.remove('mapnik/paths.py') @@ -154,8 +160,7 @@ if 'install' in COMMAND_LINE_TARGETS: init_mapnik2 = env.Install(target_path_deprecated, 'mapnik2/__init__.py') env.Alias(target='install', source=init_mapnik2) -# fix perms and install the custom generated 'paths.py' -if 'install' in COMMAND_LINE_TARGETS: + # fix perms and install the custom generated 'paths.py' targetp = os.path.join(target_path,'paths.py') env.Alias("install", targetp) # use env.Command rather than env.Install @@ -166,22 +171,16 @@ if 'install' in COMMAND_LINE_TARGETS: Chmod("$TARGET", 0644), ]) +if 'uninstall' not in COMMAND_LINE_TARGETS: + if env['HAS_CAIRO']: + py_env.Append(CPPPATH = env['CAIROMM_CPPPATHS']) + py_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + if env['PLATFORM'] == 'Darwin': + py_env.Append(LIBS=env['CAIROMM_LINKFLAGS']) -# install the shared object beside the module directory -sources = glob.glob('*.cpp') - -py_env = env.Clone() -py_env.Append(CPPPATH = env['PYTHON_INCLUDES']) - -if env['HAS_CAIRO']: - py_env.Append(CPPPATH = env['CAIROMM_CPPPATHS']) - py_env.Append(CXXFLAGS = '-DHAVE_CAIRO') - if env['PLATFORM'] == 'Darwin': - py_env.Append(LIBS=env['CAIROMM_LINKFLAGS']) - -if env['HAS_PYCAIRO']: - py_env.ParseConfig('pkg-config --cflags pycairo') - py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO') + if env['HAS_PYCAIRO']: + py_env.ParseConfig('pkg-config --cflags pycairo') + py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO') libraries.append('boost_thread%s' % env['BOOST_APPEND']) _mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) @@ -193,7 +192,7 @@ if env['PLATFORM'] == 'SunOS' and env['PYTHON_IS_64BIT']: cxx_module_path = os.path.join(target_path,'64') else: cxx_module_path = target_path - + if 'uninstall' not in COMMAND_LINE_TARGETS: pymapniklib = env.Install(cxx_module_path,_mapnik) py_env.Alias(target='install',source=pymapniklib) diff --git a/bindings/python/mapnik_fontset.cpp b/bindings/python/mapnik_fontset.cpp index b50916229..f467d816f 100644 --- a/bindings/python/mapnik_fontset.cpp +++ b/bindings/python/mapnik_fontset.cpp @@ -30,21 +30,11 @@ using mapnik::font_set; -struct fontset_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const font_set& fs) - { - return boost::python::make_tuple(fs.get_name()); - } -}; - void export_fontset () { using namespace boost::python; class_("FontSet", init<>("default fontset constructor") ) - .def_pickle(fontset_pickle_suite()) .def("add_face_name",&font_set::add_face_name, (arg("name")), "Add a face-name to the fontset.\n" diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 9369af058..85dd99dee 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -56,30 +57,65 @@ geometry_type const& getitem_impl(path_type & p, int key) void add_wkt_impl(path_type& p, std::string const& wkt) { - bool result = mapnik::from_wkt(wkt , p); - if (!result) throw std::runtime_error("Failed to parse WKT"); + if (!mapnik::from_wkt(wkt , p)) + throw std::runtime_error("Failed to parse WKT"); } -bool add_wkb_impl(path_type& p, std::string const& wkb) +void add_wkb_impl(path_type& p, std::string const& wkb) { - return mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size()); + if (!mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size())) + throw std::runtime_error("Failed to parse WKB"); +} + +void add_geojson_impl(path_type& p, std::string const& json) +{ + if (!mapnik::json::from_geojson(json, p)) + throw std::runtime_error("Failed to parse geojson geometry"); } boost::shared_ptr from_wkt_impl(std::string const& wkt) { boost::shared_ptr paths = boost::make_shared(); - bool result = mapnik::from_wkt(wkt, *paths); - if (!result) throw std::runtime_error("Failed to parse WKT"); + if (!mapnik::from_wkt(wkt, *paths)) + throw std::runtime_error("Failed to parse WKT"); return paths; } boost::shared_ptr from_wkb_impl(std::string const& wkb) { boost::shared_ptr paths = boost::make_shared(); - mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size()); + if (!mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size())) + throw std::runtime_error("Failed to parse WKB"); return paths; } +boost::shared_ptr from_geojson_impl(std::string const& json) +{ + boost::shared_ptr paths = boost::make_shared(); + if (! mapnik::json::from_geojson(json, *paths)) + throw std::runtime_error("Failed to parse geojson geometry"); + return paths; +} + +mapnik::box2d envelope_impl(path_type & p) +{ + mapnik::box2d b; + bool first = true; + BOOST_FOREACH(mapnik::geometry_type const& geom, p) + { + if (first) + { + b = geom.envelope(); + first=false; + } + else + { + b.expand_to_include(geom.envelope()); + } + } + return b; +} + } inline std::string boost_version() @@ -218,15 +254,19 @@ void export_geometry() class_, boost::noncopyable>("Path") .def("__getitem__", getitem_impl,return_value_policy()) .def("__len__", &path_type::size) + .def("envelope",envelope_impl) .def("add_wkt",add_wkt_impl) .def("add_wkb",add_wkb_impl) + .def("add_geojson",add_geojson_impl) .def("to_wkt",&to_wkt2) .def("to_wkb",&to_wkb2) .def("from_wkt",from_wkt_impl) .def("from_wkb",from_wkb_impl) + .def("from_geojson",from_geojson_impl) .def("to_geojson",to_geojson) .staticmethod("from_wkt") .staticmethod("from_wkb") + .staticmethod("from_geojson") ; } diff --git a/bindings/python/mapnik_grid.cpp b/bindings/python/mapnik_grid.cpp index 87a7ef852..4bff835c8 100644 --- a/bindings/python/mapnik_grid.cpp +++ b/bindings/python/mapnik_grid.cpp @@ -32,7 +32,7 @@ using namespace boost::python; // help compiler see template definitions -static dict (*encode)( mapnik::grid const&, std::string, bool, unsigned int) = mapnik::grid_encode; +static dict (*encode)( mapnik::grid const&, std::string const& , bool, unsigned int) = mapnik::grid_encode; bool painted(mapnik::grid const& grid) { diff --git a/bindings/python/mapnik_grid_view.cpp b/bindings/python/mapnik_grid_view.cpp index 926ee18f6..aa29dda78 100644 --- a/bindings/python/mapnik_grid_view.cpp +++ b/bindings/python/mapnik_grid_view.cpp @@ -34,7 +34,7 @@ using namespace boost::python; // help compiler see template definitions -static dict (*encode)( mapnik::grid_view const&, std::string, bool, unsigned int) = mapnik::grid_encode; +static dict (*encode)( mapnik::grid_view const&, std::string const& , bool, unsigned int) = mapnik::grid_encode; void export_grid_view() { diff --git a/bindings/python/mapnik_inmem_metawriter.cpp b/bindings/python/mapnik_inmem_metawriter.cpp deleted file mode 100644 index 34760f45b..000000000 --- a/bindings/python/mapnik_inmem_metawriter.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -// boost -#include -#include -#include - -// mapnik -#include - -using mapnik::metawriter_inmem; -using mapnik::metawriter_inmem_ptr; - -namespace { -std::map::const_iterator -mapnik_value_map_begin(const std::map &m) { - return m.begin(); -} - -std::map::const_iterator -mapnik_value_map_end(const std::map &m) { - return m.end(); -} -} - -void export_inmem_metawriter() { - using namespace boost::python; - - class_ > - ("MapnikProperties", "Retarded.", init<>()) - .def("__iter__", range(&mapnik_value_map_begin, &mapnik_value_map_end)) - ; - - class_ - ("MetaInstance", "Single rendered instance of meta-information.", no_init) - .def_readonly("box", &metawriter_inmem::meta_instance::box) - .def_readonly("properties", &metawriter_inmem::meta_instance::properties) - ; - - class_ - ("MetaWriterInMem", - "Collects meta-information about elements rendered.", - no_init) - .def("__iter__", range(&metawriter_inmem::inst_begin, - &metawriter_inmem::inst_end)) - ; -} diff --git a/bindings/python/mapnik_line_pattern_symbolizer.cpp b/bindings/python/mapnik_line_pattern_symbolizer.cpp index e982edf05..ac8fa6c92 100644 --- a/bindings/python/mapnik_line_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_line_pattern_symbolizer.cpp @@ -49,17 +49,6 @@ void set_filename(line_pattern_symbolizer & t, std::string const& file_expr) } -struct line_pattern_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const line_pattern_symbolizer& l) - { - std::string filename = path_processor_type::to_string(*l.get_filename()); - // FIXME : Do we need "type" parameter at all ? - return boost::python::make_tuple(filename, guess_type(filename)); - } -}; - void export_line_pattern_symbolizer() { using namespace boost::python; @@ -67,7 +56,6 @@ void export_line_pattern_symbolizer() class_("LinePatternSymbolizer", init ("")) - //.def_pickle(line_pattern_symbolizer_pickle_suite()) .add_property("transform", mapnik::get_svg_transform, mapnik::set_svg_transform) diff --git a/bindings/python/mapnik_line_symbolizer.cpp b/bindings/python/mapnik_line_symbolizer.cpp index 1c859e62c..29078295b 100644 --- a/bindings/python/mapnik_line_symbolizer.cpp +++ b/bindings/python/mapnik_line_symbolizer.cpp @@ -29,16 +29,6 @@ using mapnik::line_symbolizer; using mapnik::stroke; using mapnik::color; -struct line_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const line_symbolizer& l) - { - return boost::python::make_tuple(l.get_stroke()); - } - -}; - void export_line_symbolizer() { using namespace boost::python; @@ -50,7 +40,6 @@ void export_line_symbolizer() init<>("Default LineSymbolizer - 1px solid black")) .def(init("TODO")) .def(init()) - .def_pickle(line_symbolizer_pickle_suite()) .add_property("rasterizer", &line_symbolizer::get_rasterizer, &line_symbolizer::set_rasterizer, diff --git a/bindings/python/mapnik_logger.cpp b/bindings/python/mapnik_logger.cpp index 257c6e510..0f3b30949 100644 --- a/bindings/python/mapnik_logger.cpp +++ b/bindings/python/mapnik_logger.cpp @@ -39,22 +39,14 @@ void export_logger() ; enum_("severity_type") - .value("Info", logger::info) .value("Debug", logger::debug) .value("Warn", logger::warn) .value("Error", logger::error) - .value("Fatal", logger::fatal) .value("None", logger::none) ; class_ >, boost::noncopyable>("logger",no_init) - .def_readonly("Info", logger::info) - .def_readonly("Debug", logger::debug) - .def_readonly("Warn", logger::warn) - .def_readonly("Error", logger::error) - .def_readonly("Fatal", logger::fatal) - .def_readonly("None", logger::none) .def("get_severity", &logger::get_severity) .def("set_severity", &logger::set_severity) .def("get_object_severity", &logger::get_object_severity) diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index e2a21e674..f7af30291 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -28,9 +28,10 @@ // mapnik #include #include +#include +#include #include -#include -#include +//#include #include "mapnik_enumeration.hpp" using mapnik::color; @@ -39,85 +40,9 @@ using mapnik::box2d; using mapnik::layer; using mapnik::Map; -struct map_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const Map& m) - { - return boost::python::make_tuple(m.width(),m.height(),m.srs()); - } - - static boost::python::tuple - getstate(const Map& m) - { - boost::python::list l; - for (unsigned i=0;ifirst; - const mapnik::feature_type_style & style = it->second; - boost::python::tuple style_pair = boost::python::make_tuple(name,style); - s.append(style_pair); - } - - return boost::python::make_tuple(m.get_current_extent(),m.background(),l,s,m.base_path()); - } - - static void - setstate (Map& m, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 5) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 5-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - box2d ext = extract >(state[0]); - m.zoom_to_box(ext); - if (state[1]) - { - color bg = extract(state[1]); - m.set_background(bg); - } - - boost::python::list l=extract(state[2]); - for (int i=0;i(l[i])); - } - - boost::python::list s=extract(state[3]); - for (int i=0;i(s[i]); - std::string name = extract(style_pair[0]); - mapnik::feature_type_style style = extract(style_pair[1]); - m.insert_style(name, style); - } - - if (state[4]) - { - std::string base_path = extract(state[4]); - m.set_base_path(base_path); - } - } -}; - std::vector& (Map::*layers_nonconst)() = &Map::layers; std::vector const& (Map::*layers_const)() const = &Map::layers; mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters; -//boost::optional > const& (Map::*maximum_extent_const)() const = &Map::maximum_extent; mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name) { @@ -141,26 +66,6 @@ mapnik::font_set find_fontset(mapnik::Map const& m, std::string const& name) return *fontset; } -bool has_metawriter(mapnik::Map const& m) -{ - if (m.metawriters().size() >=1) - return true; - return false; -} - -// returns empty shared_ptr when the metawriter isn't found, or is -// of the wrong type. empty pointers make it back to Python as a None. -mapnik::metawriter_inmem_ptr find_inmem_metawriter(const mapnik::Map & m, std::string const& name) { - mapnik::metawriter_ptr metawriter = m.find_metawriter(name); - mapnik::metawriter_inmem_ptr inmem; - - if (metawriter) { - inmem = boost::dynamic_pointer_cast(metawriter); - } - - return inmem; -} - // TODO - we likely should allow indexing by negative number from python // for now, protect against negative values and kindly throw mapnik::featureset_ptr query_point(mapnik::Map const& m, int index, double x, double y) @@ -184,6 +89,7 @@ mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x } // deepcopy +/* mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo) { // FIXME: ignore memo for now @@ -191,6 +97,7 @@ mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo) mapnik::util::deepcopy(m, result); return result; } +*/ void set_maximum_extent(mapnik::Map & m, boost::optional > const& box) { @@ -240,9 +147,6 @@ void export_map() "'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n" )) - .def_pickle(map_pickle_suite() - ) - .def("append_style",&Map::insert_style, (arg("style_name"),arg("style_object")), "Insert a Mapnik Style onto the map by appending it.\n" @@ -310,15 +214,6 @@ void export_map() "\n" ) - .def("has_metawriter", - has_metawriter, - "Check if the Map has any active metawriters\n" - "\n" - "Usage:\n" - ">>> m.has_metawriter()\n" - "False\n" - ) - .def("pan",&Map::pan, (arg("x"),arg("y")), "Set the Map center at a given x,y location\n" @@ -457,39 +352,8 @@ void export_map() ">>> extext = Box2d(-180.0, -90.0, 180.0, 90.0)\n" ">>> m.zoom_to_box(extent)\n" ) - .def("get_metawriter_property", &Map::get_metawriter_property, - (arg("name")), - "Reads a metawriter property.\n" - "These properties are completely user-defined and can be used to" - "create filenames, etc.\n" - "\n" - "Usage:\n" - ">>> map.set_metawriter_property(\"x\", \"10\")\n" - ">>> map.get_metawriter_property(\"x\")\n" - "10\n" - ) - .def("set_metawriter_property", &Map::set_metawriter_property, - (arg("name"),arg("value")), - "Sets a metawriter property.\n" - "These properties are completely user-defined and can be used to" - "create filenames, etc.\n" - "\n" - "Usage:\n" - ">>> map.set_metawriter_property(\"x\", str(x))\n" - ">>> map.set_metawriter_property(\"y\", str(y))\n" - ">>> map.set_metawriter_property(\"z\", str(z))\n" - "\n" - "Use a path like \"[z]/[x]/[y].json\" to create filenames.\n" - ) - .def("find_inmem_metawriter", find_inmem_metawriter, - (arg("name")), - "Gets an inmem metawriter, or None if no such metawriter " - "exists.\n" - "Use this after the map has been rendered to retrieve information " - "about the hit areas rendered on the map.\n" - ) - .def("__deepcopy__",&map_deepcopy) + //.def("__deepcopy__",&map_deepcopy) .add_property("parameters",make_function(params_nonconst,return_value_policy()),"TODO") .add_property("aspect_fix_mode", diff --git a/bindings/python/mapnik_markers_symbolizer.cpp b/bindings/python/mapnik_markers_symbolizer.cpp index 9eefef2d7..366bdb882 100644 --- a/bindings/python/mapnik_markers_symbolizer.cpp +++ b/bindings/python/mapnik_markers_symbolizer.cpp @@ -49,43 +49,7 @@ void set_filename(mapnik::markers_symbolizer & symbolizer, std::string const& fi } -struct markers_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(markers_symbolizer const& p) - { - std::string filename = path_processor_type::to_string(*p.get_filename()); - return boost::python::make_tuple(filename,mapnik::guess_type(filename)); - } - - static boost::python::tuple - getstate(markers_symbolizer const& p) - { - return boost::python::make_tuple(p.get_allow_overlap(), - p.get_ignore_placement());//,p.get_opacity()); - } - - static void - setstate (markers_symbolizer& p, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 2) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 2-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - p.set_allow_overlap(extract(state[0])); - p.set_ignore_placement(extract(state[1])); - //p.set_opacity(extract(state[2])); - - } - -}; - +// https://github.com/mapnik/mapnik/issues/1367 PyObject* get_fill_opacity_impl(markers_symbolizer & sym) { boost::optional fill_opacity = sym.get_fill_opacity(); @@ -107,7 +71,6 @@ void export_markers_symbolizer() class_("MarkersSymbolizer", init<>("Default Markers Symbolizer - circle")) .def (init("")) - //.def_pickle(markers_symbolizer_pickle_suite()) .add_property("filename", &get_filename, &set_filename) diff --git a/bindings/python/mapnik_point_symbolizer.cpp b/bindings/python/mapnik_point_symbolizer.cpp index 2ca6c9acb..a618377c0 100644 --- a/bindings/python/mapnik_point_symbolizer.cpp +++ b/bindings/python/mapnik_point_symbolizer.cpp @@ -50,47 +50,6 @@ void set_filename(point_symbolizer & t, std::string const& file_expr) } -struct point_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const point_symbolizer& p) - { - std::string filename = path_processor_type::to_string(*p.get_filename()); - return boost::python::make_tuple(filename,mapnik::guess_type(filename)); - } - - static boost::python::tuple - getstate(const point_symbolizer& p) - { - return boost::python::make_tuple(p.get_allow_overlap(), - p.get_opacity(), - p.get_ignore_placement(), - p.get_point_placement()); - } - - static void - setstate (point_symbolizer& p, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 4) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 4-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - p.set_allow_overlap(extract(state[0])); - p.set_opacity(extract(state[1])); - p.set_ignore_placement(extract(state[2])); - p.set_point_placement(extract(state[3])); - - } - -}; - - void export_point_symbolizer() { using namespace boost::python; @@ -103,7 +62,6 @@ void export_point_symbolizer() class_("PointSymbolizer", init<>("Default Point Symbolizer - 4x4 black square")) .def (init("")) - .def_pickle(point_symbolizer_pickle_suite()) .add_property("filename", &get_filename, &set_filename) diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index dc155c5f6..cda55ce3d 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -49,41 +49,6 @@ void set_filename(polygon_pattern_symbolizer & t, std::string const& file_expr) } -struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const polygon_pattern_symbolizer& p) - { - std::string filename = path_processor_type::to_string(*p.get_filename()); - return boost::python::make_tuple(filename,guess_type(filename)); - } - - static boost::python::tuple - getstate(const polygon_pattern_symbolizer& p) - { - return boost::python::make_tuple(p.get_alignment(),p.get_gamma(),p.get_gamma_method()); - } - - static void - setstate (polygon_pattern_symbolizer& p, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 3) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 3-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - p.set_alignment(extract(state[0])); - p.set_gamma(extract(state[1])); - p.set_gamma_method(extract(state[2])); - } - -}; - void export_polygon_pattern_symbolizer() { using namespace boost::python; @@ -95,7 +60,6 @@ void export_polygon_pattern_symbolizer() class_("PolygonPatternSymbolizer", init("")) - .def_pickle(polygon_pattern_symbolizer_pickle_suite()) .add_property("alignment", &polygon_pattern_symbolizer::get_alignment, &polygon_pattern_symbolizer::set_alignment, diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index 9933dbde3..48b94e412 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -28,40 +28,6 @@ using namespace mapnik; using mapnik::polygon_symbolizer; using mapnik::color; -struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const polygon_symbolizer& p) - { - return boost::python::make_tuple(p.get_fill()); - } - - static boost::python::tuple - getstate(const polygon_symbolizer& p) - { - return boost::python::make_tuple(p.get_opacity(),p.get_gamma(),p.get_gamma_method()); - } - - static void - setstate (polygon_symbolizer& p, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 3) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 3-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - p.set_opacity(extract(state[0])); - p.set_gamma(extract(state[1])); - p.set_gamma_method(extract(state[2])); - } - -}; - void export_polygon_symbolizer() { using namespace boost::python; @@ -69,7 +35,6 @@ void export_polygon_symbolizer() class_("PolygonSymbolizer", init<>("Default PolygonSymbolizer - solid fill grey")) .def(init("TODO")) - .def_pickle(polygon_symbolizer_pickle_suite()) .add_property("fill",make_function (&polygon_symbolizer::get_fill, return_value_policy()), diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index f98cec7fa..441811050 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -66,7 +66,6 @@ void export_projection(); void export_proj_transform(); void export_view_transform(); void export_raster_colorizer(); -void export_inmem_metawriter(); void export_label_collision_detector(); void export_logger(); @@ -407,7 +406,6 @@ BOOST_PYTHON_MODULE(_mapnik) export_coord(); export_map(); export_raster_colorizer(); - export_inmem_metawriter(); export_label_collision_detector(); export_logger(); diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index cd49ef967..f0041b8c0 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -32,15 +32,6 @@ using mapnik::box2d; namespace python = boost::python; -struct query_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(query const& q) - { - return boost::python::make_tuple(q.get_bbox(),q.resolution()); - } -}; - struct resolution_to_tuple { static PyObject* convert(query::resolution_type const& x) @@ -64,7 +55,6 @@ void export_query() class_("Query", "a spatial query data object", init,query::resolution_type const&,double>() ) .def(init >()) - .def_pickle(query_pickle_suite()) .add_property("resolution",make_function(&query::resolution, return_value_policy())) .add_property("bbox", make_function(&query::get_bbox, diff --git a/bindings/python/mapnik_raster_symbolizer.cpp b/bindings/python/mapnik_raster_symbolizer.cpp index 3830dd9f1..87b693e19 100644 --- a/bindings/python/mapnik_raster_symbolizer.cpp +++ b/bindings/python/mapnik_raster_symbolizer.cpp @@ -29,44 +29,6 @@ using mapnik::raster_symbolizer; -struct raster_symbolizer_pickle_suite : boost::python::pickle_suite -{ - /* - static boost::python::tuple - getinitargs(const raster_symbolizer& r) - { - return boost::python::make_tuple(); - } - */ - - static boost::python::tuple - getstate(raster_symbolizer const& r) - { - return boost::python::make_tuple(r.get_mode(),r.get_scaling_method(),r.get_opacity(),r.get_filter_factor(),r.get_mesh_size()); - } - - static void - setstate (raster_symbolizer & r, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 5) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 5-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - r.set_mode(extract(state[0])); - r.set_scaling_method(extract(state[1])); - r.set_opacity(extract(state[2])); - r.set_filter_factor(extract(state[3])); - r.set_mesh_size(extract(state[4])); - } - -}; - void export_raster_symbolizer() { using namespace boost::python; @@ -74,8 +36,6 @@ void export_raster_symbolizer() class_("RasterSymbolizer", init<>("Default ctor")) - .def_pickle(raster_symbolizer_pickle_suite()) - .add_property("mode", make_function(&raster_symbolizer::get_mode,return_value_policy()), &raster_symbolizer::set_mode, diff --git a/bindings/python/mapnik_rule.cpp b/bindings/python/mapnik_rule.cpp index 378e22f10..86d5d3522 100644 --- a/bindings/python/mapnik_rule.cpp +++ b/bindings/python/mapnik_rule.cpp @@ -48,108 +48,6 @@ using mapnik::markers_symbolizer; using mapnik::symbolizer; using mapnik::to_expression_string; -struct pickle_symbolizer : public boost::static_visitor<> -{ -public: - pickle_symbolizer( boost::python::list syms): - syms_(syms) {} - - template - void operator () ( T const& sym ) - { - syms_.append(sym); - } - -private: - boost::python::list syms_; -}; - - -struct extract_symbolizer : public boost::static_visitor<> -{ -public: - extract_symbolizer( rule& r): - r_(r) {} - - template - void operator () ( T const& sym ) - { - r_.append(sym); - } -private: - rule& r_; - -}; - -struct rule_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const rule& r) - { - return boost::python::make_tuple(r.get_name(),r.get_min_scale(),r.get_max_scale()); - } - - static boost::python::tuple - getstate(const rule& r) - { - boost::python::list syms; - - rule::symbolizers::const_iterator begin = r.get_symbolizers().begin(); - rule::symbolizers::const_iterator end = r.get_symbolizers().end(); - pickle_symbolizer serializer( syms ); - std::for_each( begin, end , boost::apply_visitor( serializer )); - - // We serialize filter expressions AST as strings - std::string filter_expr = to_expression_string(*r.get_filter()); - - return boost::python::make_tuple(filter_expr,r.has_else_filter(),r.has_also_filter(),syms); - } - - static void - setstate (rule& r, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 4) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 4-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - if (state[0]) - { - rule dfl; - std::string filter = extract(state[1]); - std::string default_filter = "";//dfl.get_filter()->to_string(); - if ( filter != default_filter) - { - r.set_filter(mapnik::parse_expression(filter,"utf8")); - } - } - - if (state[1]) - { - r.set_else(true); - } - - if (state[2]) - { - r.set_also(true); - } - - boost::python::list syms=extract(state[4]); - extract_symbolizer serializer( r ); - for (int i=0;i(syms[i]); - //boost::apply_visitor( serializer, symbol ); - } - } - -}; - void export_rule() { using namespace boost::python; @@ -171,7 +69,6 @@ void export_rule() class_("Rule",init<>("default constructor")) .def(init >()) - .def_pickle(rule_pickle_suite()) .add_property("name",make_function (&rule::get_name, return_value_policy()), diff --git a/bindings/python/mapnik_shield_symbolizer.cpp b/bindings/python/mapnik_shield_symbolizer.cpp index 8a08900bb..0278d8a3b 100644 --- a/bindings/python/mapnik_shield_symbolizer.cpp +++ b/bindings/python/mapnik_shield_symbolizer.cpp @@ -96,7 +96,6 @@ void export_shield_symbolizer() unsigned, mapnik::color const&, path_expression_ptr>() ) - //.def_pickle(shield_symbolizer_pickle_suite()) .add_property("allow_overlap", &shield_symbolizer::get_allow_overlap, &shield_symbolizer::set_allow_overlap, diff --git a/bindings/python/mapnik_stroke.cpp b/bindings/python/mapnik_stroke.cpp index 1f21071c3..70411b80e 100644 --- a/bindings/python/mapnik_stroke.cpp +++ b/bindings/python/mapnik_stroke.cpp @@ -49,63 +49,6 @@ list get_dashes_list(const stroke& stroke) } } -struct stroke_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const stroke& s) - { - - return boost::python::make_tuple(s.get_color(),s.get_width()); - - } - - static boost::python::tuple - getstate(const stroke& s) - { - boost::python::list dashes = get_dashes_list(s); - return boost::python::make_tuple(s.get_opacity(), - dashes, - s.get_line_cap(), - s.get_line_join(), - s.get_gamma(), - s.get_gamma_method()); - } - - static void - setstate (stroke& s, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 6) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 6-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - s.set_opacity(extract(state[0])); - - if (state[1]) - { - list dashes = extract(state[1]); - for(boost::python::ssize_t i=0; i(dashes[i][0]); - double ds2 = extract(dashes[i][1]); - s.add_dash(ds1,ds2); - } - } - - s.set_line_cap(extract(state[2])); - s.set_line_join(extract(state[3])); - s.set_gamma(extract(state[4])); - s.set_gamma_method(extract(state[5])); - - } - -}; - - void export_stroke () { using namespace boost::python; @@ -132,7 +75,6 @@ void export_stroke () (arg("color"),arg("width")), "Creates a new stroke object with a specified color and width.\n") ) - .def_pickle(stroke_pickle_suite()) .add_property("color",make_function (&stroke::get_color,return_value_policy()), &stroke::set_color, diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index c5a70dbad..ee0e1a2de 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -32,45 +32,6 @@ using mapnik::feature_type_style; using mapnik::rules; using mapnik::rule; -struct style_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getstate(const feature_type_style& s) - { - boost::python::list rule_list; - - rules::const_iterator it = s.get_rules().begin(); - rules::const_iterator end = s.get_rules().end(); - for (; it != end; ++it) - { - rule_list.append( *it ); - } - - return boost::python::make_tuple(rule_list); - } - - static void - setstate (feature_type_style& s, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 1) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 1-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - boost::python::list rules = extract(state[0]); - for (int i=0; i(rules[i])); - } - } - -}; - void export_style() { using namespace boost::python; @@ -85,9 +46,6 @@ void export_style() ; class_("Style",init<>("default style constructor")) - .def_pickle(style_pickle_suite() - ) - .add_property("rules",make_function (&feature_type_style::get_rules, return_value_policy()), diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index f0b99f714..9652a4bce 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -233,69 +233,46 @@ void write_features(T const& grid_type, boost::python::dict& feature_data, std::vector const& key_order) { - std::string const& key = grid_type.get_key(); - std::set const& attributes = grid_type.property_names(); typename T::feature_type const& g_features = grid_type.get_grid_features(); - typename T::feature_type::const_iterator feat_itr = g_features.begin(); - typename T::feature_type::const_iterator feat_end = g_features.end(); - bool include_key = (attributes.find(key) != attributes.end()); - for (; feat_itr != feat_end; ++feat_itr) + if (g_features.size() <= 0) { + return; + } + + std::set const& attributes = grid_type.property_names(); + typename T::feature_type::const_iterator feat_end = g_features.end(); + BOOST_FOREACH ( std::string const& key_item, key_order ) + { + if (key_item.empty()) + { + continue; + } + + typename T::feature_type::const_iterator feat_itr = g_features.find(key_item); + if (feat_itr == feat_end) + { + continue; + } + + bool found = false; + boost::python::dict feat; mapnik::feature_ptr feature = feat_itr->second; - boost::optional join_value; - if (key == grid_type.key_name()) + BOOST_FOREACH ( std::string const& attr, attributes ) { - join_value = feat_itr->first; - } - else if (feature->has_key(key)) - { - join_value = feature->get(key).to_string(); - } - - if (join_value) - { - // only serialize features visible in the grid - if(std::find(key_order.begin(), key_order.end(), *join_value) != key_order.end()) { - boost::python::dict feat; - bool found = false; - if (key == grid_type.key_name()) - { - // drop key unless requested - if (include_key) { - found = true; - //TODO - add __id__ as data key? - //feat[key] = *join_value; - } - } - - feature_kv_iterator itr = feature->begin(); - feature_kv_iterator end = feature->end(); - for ( ;itr!=end; ++itr) - { - std::string const& key_name = boost::get<0>(*itr); - if (key_name == key) { - // drop key unless requested - if (include_key) { - found = true; - feat[key_name] = boost::get<1>(*itr); - } - } - else if ( (attributes.find(key_name) != attributes.end()) ) - { - found = true; - feat[key_name] = boost::get<1>(*itr); - } - } - - if (found) - { - feature_data[feat_itr->first] = feat; - } + if (attr == "__id__") + { + feat[attr.c_str()] = feature->id(); + } + else if (feature->has_key(attr)) + { + found = true; + feat[attr.c_str()] = feature->get(attr); } } - else + + if (found) { - MAPNIK_LOG_DEBUG(bindings) << "write_features: Should not get here: key " << key << " not found in grid feature properties"; + feature_data[feat_itr->first] = feat; } } } @@ -342,7 +319,7 @@ void grid_encode_utf(T const& grid_type, } template -boost::python::dict grid_encode( T const& grid, std::string format, bool add_features, unsigned int resolution) +boost::python::dict grid_encode( T const& grid, std::string const& format, bool add_features, unsigned int resolution) { if (format == "utf") { boost::python::dict json; @@ -357,16 +334,16 @@ boost::python::dict grid_encode( T const& grid, std::string format, bool add_fea } } -template boost::python::dict grid_encode( mapnik::grid const& grid, std::string format, bool add_features, unsigned int resolution); -template boost::python::dict grid_encode( mapnik::grid_view const& grid, std::string format, bool add_features, unsigned int resolution); +template boost::python::dict grid_encode( mapnik::grid const& grid, std::string const& format, bool add_features, unsigned int resolution); +template boost::python::dict grid_encode( mapnik::grid_view const& grid, std::string const& format, bool add_features, unsigned int resolution); /* new approach: key comes from grid object * grid size should be same as the map * encoding, resizing handled as method on grid object * whether features are dumped is determined by argument not 'fields' */ -void render_layer_for_grid(const mapnik::Map& map, - mapnik::grid& grid, +void render_layer_for_grid(mapnik::Map const& map, + mapnik::grid & grid, unsigned layer_idx, // TODO - layer by name or index boost::python::list const& fields) { @@ -379,11 +356,12 @@ void render_layer_for_grid(const mapnik::Map& map, throw std::runtime_error(s.str()); } - // convert python list to std::vector + // convert python list to std::set boost::python::ssize_t num_fields = boost::python::len(fields); for(boost::python::ssize_t i=0; i name(fields[i]); - if (name.check()) { + if (name.check()) + { grid.add_property_name(name()); } else @@ -396,25 +374,18 @@ void render_layer_for_grid(const mapnik::Map& map, // copy property names std::set attributes = grid.property_names(); - std::string const& key = grid.get_key(); - - // if key is special __id__ keyword - if (key == grid.key_name()) + // todo - make this a static constant + std::string known_id_key = "__id__"; + if (attributes.find(known_id_key) != attributes.end()) { - // TODO - should feature.id() be a first class attribute? - - // if __id__ is requested to be dumped out - // remove it so that datasource queries will not break - if (attributes.find(key) != attributes.end()) - { - attributes.erase(key); - } + attributes.erase(known_id_key); } - // if key is not the special __id__ keyword - else if (attributes.find(key) == attributes.end()) + + std::string join_field = grid.get_key(); + if (known_id_key != join_field && + attributes.find(join_field) == attributes.end()) { - // them make sure the datasource query includes this field - attributes.insert(key); + attributes.insert(join_field); } mapnik::grid_renderer ren(map,grid,1.0,0,0); @@ -425,7 +396,7 @@ void render_layer_for_grid(const mapnik::Map& map, /* old, original impl - to be removed after further testing * grid object is created on the fly at potentially reduced size */ -boost::python::dict render_grid(const mapnik::Map& map, +boost::python::dict render_grid(mapnik::Map const& map, unsigned layer_idx, // layer std::string const& key, // key_name unsigned int step, // resolution @@ -447,7 +418,7 @@ boost::python::dict render_grid(const mapnik::Map& map, // TODO - no need to pass step here mapnik::grid grid(grid_width,grid_height,key,step); - // convert python list to std::vector + // convert python list to std::set boost::python::ssize_t num_fields = boost::python::len(fields); for(boost::python::ssize_t i=0; i name(fields[i]); @@ -464,24 +435,18 @@ boost::python::dict render_grid(const mapnik::Map& map, // copy property names std::set attributes = grid.property_names(); - - // if key is special __id__ keyword - if (key == grid.key_name()) + // todo - make this a static constant + std::string known_id_key = "__id__"; + if (attributes.find(known_id_key) != attributes.end()) { - // TODO - should feature.id() be a first class attribute? - - // if __id__ is requested to be dumped out - // remove it so that datasource queries will not break - if (attributes.find(key) != attributes.end()) - { - attributes.erase(key); - } + attributes.erase(known_id_key); } - // if key is not the special __id__ keyword - else if (attributes.find(key) == attributes.end()) + + std::string join_field = grid.get_key(); + if (known_id_key != join_field && + attributes.find(join_field) == attributes.end()) { - // them make sure the datasource query includes this field - attributes.insert(key); + attributes.insert(join_field); } try diff --git a/bindings/python/python_grid_utils.hpp b/bindings/python/python_grid_utils.hpp index 30ed4ff43..2c4083d1b 100644 --- a/bindings/python/python_grid_utils.hpp +++ b/bindings/python/python_grid_utils.hpp @@ -64,7 +64,7 @@ void grid_encode_utf(T const& grid_type, unsigned int resolution); template -boost::python::dict grid_encode( T const& grid, std::string format, bool add_features, unsigned int resolution); +boost::python::dict grid_encode( T const& grid, std::string const& format, bool add_features, unsigned int resolution); /* new approach: key comes from grid object * grid size should be same as the map diff --git a/configure b/configure index 99d1fc22a..d609ba421 100755 --- a/configure +++ b/configure @@ -1,3 +1,3 @@ #!/bin/sh -python scons/scons.py --implicit-cache configure "$@" +python scons/scons.py --implicit-deps-changed configure "$@" diff --git a/demo/c++/build.py b/demo/c++/build.py index 9738347f9..ceb31448c 100644 --- a/demo/c++/build.py +++ b/demo/c++/build.py @@ -40,8 +40,7 @@ if env['HAS_CAIRO']: demo_env.Append(CXXFLAGS = '-DHAVE_CAIRO') libraries = copy(env['LIBMAPNIK_LIBS']) -boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] -libraries.extend([boost_program_options,'mapnik']) +libraries.append('mapnik') rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"]) diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp index 436a31ddc..c4fc631b6 100644 --- a/demo/viewer/mainwindow.cpp +++ b/demo/viewer/mainwindow.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #endif // qt diff --git a/deps/agg/include/agg_pixfmt_rgba.h b/deps/agg/include/agg_pixfmt_rgba.h index 41e6923f0..576219d28 100644 --- a/deps/agg/include/agg_pixfmt_rgba.h +++ b/deps/agg/include/agg_pixfmt_rgba.h @@ -1450,6 +1450,9 @@ namespace agg }; // colorize alpha values + // TODO - consider moving to image-filters: + // https://github.com/mapnik/mapnik/issues/1371 + /* template struct comp_op_rgba_colorize_alpha { @@ -1503,6 +1506,7 @@ namespace agg } } }; + */ // grain extract (GIMP) // E = I - M + 128 @@ -1790,7 +1794,7 @@ namespace agg comp_op_rgba_saturation::blend_pix, comp_op_rgba_color::blend_pix, comp_op_rgba_value::blend_pix, - comp_op_rgba_colorize_alpha::blend_pix, + //comp_op_rgba_colorize_alpha::blend_pix, 0 }; @@ -1832,7 +1836,7 @@ namespace agg comp_op_saturation, //----comp_op_saturation comp_op_color, //----comp_op_color comp_op_value, //----comp_op_value - comp_op_colorize_alpha,//----comp_op_colorize_alpha + //comp_op_colorize_alpha,//----comp_op_colorize_alpha end_of_comp_op_e }; diff --git a/fonts/build.py b/fonts/build.py index 99acaaae1..e90529301 100644 --- a/fonts/build.py +++ b/fonts/build.py @@ -28,5 +28,9 @@ includes = glob.glob('*/*/*.ttf') # grab single unifont ttf (available at http://unifoundry.com/unifont.html) includes.extend(glob.glob('unifont*.ttf')) +target_path = env['MAPNIK_FONTS_DEST'] + if 'uninstall' not in COMMAND_LINE_TARGETS and not env['SYSTEM_FONTS']: - env.Alias(target='install', source=env.Install(env['MAPNIK_FONTS_DEST'], includes)) + env.Alias(target='install', source=env.Install(target_path, includes)) + +env['create_uninstall_target'](env, target_path) \ No newline at end of file diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 81cdad888..9ad579c5f 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -102,7 +102,6 @@ struct symbolizer_attributes : public boost::static_visitor<> { if (*it) boost::apply_visitor(f_attr, **it); } - collect_metawriter(sym); collect_transform(sym.get_transform()); } @@ -113,14 +112,12 @@ struct symbolizer_attributes : public boost::static_visitor<> { path_processor_type::collect_attributes(*filename_expr,names_); } - collect_metawriter(sym); collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } void operator () (line_symbolizer const& sym) { - collect_metawriter(sym); collect_transform(sym.get_transform()); } @@ -131,14 +128,12 @@ struct symbolizer_attributes : public boost::static_visitor<> { path_processor_type::collect_attributes(*filename_expr,names_); } - collect_metawriter(sym); collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } void operator () (polygon_symbolizer const& sym) { - collect_metawriter(sym); collect_transform(sym.get_transform()); } @@ -149,7 +144,6 @@ struct symbolizer_attributes : public boost::static_visitor<> { path_processor_type::collect_attributes(*filename_expr,names_); } - collect_metawriter(sym); collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } @@ -169,7 +163,6 @@ struct symbolizer_attributes : public boost::static_visitor<> { path_processor_type::collect_attributes(*filename_expr,names_); } - collect_metawriter(sym); collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } @@ -186,7 +179,6 @@ struct symbolizer_attributes : public boost::static_visitor<> { boost::apply_visitor(f_attr,*width_expr); } - collect_metawriter(sym); collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } @@ -198,7 +190,6 @@ struct symbolizer_attributes : public boost::static_visitor<> { boost::apply_visitor(f_attr,*height_expr); } - collect_metawriter(sym); collect_transform(sym.get_transform()); } // TODO - support remaining syms @@ -206,11 +197,6 @@ struct symbolizer_attributes : public boost::static_visitor<> private: std::set& names_; expression_attributes > f_attr; - void collect_metawriter(symbolizer_base const& sym) - { - metawriter_properties const& properties = sym.get_metawriter_properties(); - names_.insert(properties.begin(), properties.end()); - } void collect_transform(transform_list_ptr const& trans_expr) { if (trans_expr) diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 014c51299..b54273c49 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -37,13 +37,15 @@ #include #include -// fusion -#include -#include - // stl #include +// boost +#include +#if BOOST_VERSION >= 104500 +// fusion +#include + BOOST_FUSION_ADAPT_ADT( mapnik::color, (unsigned, unsigned, obj.red(), obj.set_red(val)) @@ -161,4 +163,373 @@ struct css_color_grammar : qi::grammar } +#else // boost 1.42 compatibility + +#include + +namespace mapnik +{ +// temp workaround . TODO: adapt mapnik::color +struct css +{ + css () + : r(255),g(255),b(255),a(255) {} + css(unsigned r_,unsigned g_, unsigned b_,unsigned a_ = 0xff) + : r(r_),g(g_),b(b_),a(a_) {} + + unsigned r; + unsigned g; + unsigned b; + unsigned a; +}; + +} + +BOOST_FUSION_ADAPT_STRUCT( + mapnik::css, + (unsigned, r) + (unsigned, g) + (unsigned, b) + (unsigned, a) + ) + +namespace mapnik +{ + +namespace qi = boost::spirit::qi; +namespace ascii = boost::spirit::ascii; +namespace phoenix = boost::phoenix; + +typedef boost::spirit::ascii::space_type ascii_space_type; + +struct named_colors_ : qi::symbols +{ + named_colors_() + { + add + ("aliceblue", css(240, 248, 255)) + ("antiquewhite", css(250, 235, 215)) + ("aqua", css(0, 255, 255)) + ("aquamarine", css(127, 255, 212)) + ("azure", css(240, 255, 255)) + ("beige", css(245, 245, 220)) + ("bisque", css(255, 228, 196)) + ("black", css(0, 0, 0)) + ("blanchedalmond", css(255,235,205)) + ("blue", css(0, 0, 255)) + ("blueviolet", css(138, 43, 226)) + ("brown", css(165, 42, 42)) + ("burlywood", css(222, 184, 135)) + ("cadetblue", css(95, 158, 160)) + ("chartreuse", css(127, 255, 0)) + ("chocolate", css(210, 105, 30)) + ("coral", css(255, 127, 80)) + ("cornflowerblue", css(100, 149, 237)) + ("cornsilk", css(255, 248, 220)) + ("crimson", css(220, 20, 60)) + ("cyan", css(0, 255, 255)) + ("darkblue", css(0, 0, 139)) + ("darkcyan", css(0, 139, 139)) + ("darkgoldenrod", css(184, 134, 11)) + ("darkgray", css(169, 169, 169)) + ("darkgreen", css(0, 100, 0)) + ("darkgrey", css(169, 169, 169)) + ("darkkhaki", css(189, 183, 107)) + ("darkmagenta", css(139, 0, 139)) + ("darkolivegreen", css(85, 107, 47)) + ("darkorange", css(255, 140, 0)) + ("darkorchid", css(153, 50, 204)) + ("darkred", css(139, 0, 0)) + ("darksalmon", css(233, 150, 122)) + ("darkseagreen", css(143, 188, 143)) + ("darkslateblue", css(72, 61, 139)) + ("darkslategrey", css(47, 79, 79)) + ("darkturquoise", css(0, 206, 209)) + ("darkviolet", css(148, 0, 211)) + ("deeppink", css(255, 20, 147)) + ("deepskyblue", css(0, 191, 255)) + ("dimgray", css(105, 105, 105)) + ("dimgrey", css(105, 105, 105)) + ("dodgerblue", css(30, 144, 255)) + ("firebrick", css(178, 34, 34)) + ("floralwhite", css(255, 250, 240)) + ("forestgreen", css(34, 139, 34)) + ("fuchsia", css(255, 0, 255)) + ("gainsboro", css(220, 220, 220)) + ("ghostwhite", css(248, 248, 255)) + ("gold", css(255, 215, 0)) + ("goldenrod", css(218, 165, 32)) + ("gray", css(128, 128, 128)) + ("grey", css(128, 128, 128)) + ("green", css(0, 128, 0)) + ("greenyellow", css(173, 255, 47)) + ("honeydew", css(240, 255, 240)) + ("hotpink", css(255, 105, 180)) + ("indianred", css(205, 92, 92)) + ("indigo", css(75, 0, 130)) + ("ivory", css(255, 255, 240)) + ("khaki", css(240, 230, 140)) + ("lavender", css(230, 230, 250)) + ("lavenderblush", css(255, 240, 245)) + ("lawngreen", css(124, 252, 0)) + ("lemonchiffon", css(255, 250, 205)) + ("lightblue", css(173, 216, 230)) + ("lightcoral", css(240, 128, 128)) + ("lightcyan", css(224, 255, 255)) + ("lightgoldenrodyellow", css(250, 250, 210)) + ("lightgray", css(211, 211, 211)) + ("lightgreen", css(144, 238, 144)) + ("lightgrey", css(211, 211, 211)) + ("lightpink", css(255, 182, 193)) + ("lightsalmon", css(255, 160, 122)) + ("lightseagreen", css(32, 178, 170)) + ("lightskyblue", css(135, 206, 250)) + ("lightslategray", css(119, 136, 153)) + ("lightslategrey", css(119, 136, 153)) + ("lightsteelblue", css(176, 196, 222)) + ("lightyellow", css(255, 255, 224)) + ("lime", css(0, 255, 0)) + ("limegreen", css(50, 205, 50)) + ("linen", css(250, 240, 230)) + ("magenta", css(255, 0, 255)) + ("maroon", css(128, 0, 0)) + ("mediumaquamarine", css(102, 205, 170)) + ("mediumblue", css(0, 0, 205)) + ("mediumorchid", css(186, 85, 211)) + ("mediumpurple", css(147, 112, 219)) + ("mediumseagreen", css(60, 179, 113)) + ("mediumslateblue", css(123, 104, 238)) + ("mediumspringgreen", css(0, 250, 154)) + ("mediumturquoise", css(72, 209, 204)) + ("mediumvioletred", css(199, 21, 133)) + ("midnightblue", css(25, 25, 112)) + ("mintcream", css(245, 255, 250)) + ("mistyrose", css(255, 228, 225)) + ("moccasin", css(255, 228, 181)) + ("navajowhite", css(255, 222, 173)) + ("navy", css(0, 0, 128)) + ("oldlace", css(253, 245, 230)) + ("olive", css(128, 128, 0)) + ("olivedrab", css(107, 142, 35)) + ("orange", css(255, 165, 0)) + ("orangered", css(255, 69, 0)) + ("orchid", css(218, 112, 214)) + ("palegoldenrod", css(238, 232, 170)) + ("palegreen", css(152, 251, 152)) + ("paleturquoise", css(175, 238, 238)) + ("palevioletred", css(219, 112, 147)) + ("papayawhip", css(255, 239, 213)) + ("peachpuff", css(255, 218, 185)) + ("peru", css(205, 133, 63)) + ("pink", css(255, 192, 203)) + ("plum", css(221, 160, 221)) + ("powderblue", css(176, 224, 230)) + ("purple", css(128, 0, 128)) + ("red", css(255, 0, 0)) + ("rosybrown", css(188, 143, 143)) + ("royalblue", css(65, 105, 225)) + ("saddlebrown", css(139, 69, 19)) + ("salmon", css(250, 128, 114)) + ("sandybrown", css(244, 164, 96)) + ("seagreen", css(46, 139, 87)) + ("seashell", css(255, 245, 238)) + ("sienna", css(160, 82, 45)) + ("silver", css(192, 192, 192)) + ("skyblue", css(135, 206, 235)) + ("slateblue", css(106, 90, 205)) + ("slategray", css(112, 128, 144)) + ("slategrey", css(112, 128, 144)) + ("snow", css(255, 250, 250)) + ("springgreen", css(0, 255, 127)) + ("steelblue", css(70, 130, 180)) + ("tan", css(210, 180, 140)) + ("teal", css(0, 128, 128)) + ("thistle", css(216, 191, 216)) + ("tomato", css(255, 99, 71)) + ("turquoise", css(64, 224, 208)) + ("violet", css(238, 130, 238)) + ("wheat", css(245, 222, 179)) + ("white", css(255, 255, 255)) + ("whitesmoke", css(245, 245, 245)) + ("yellow", css(255, 255, 0)) + ("yellowgreen", css(154, 205, 50)) + ("transparent", css(0, 0, 0, 0)) + ; + } +} ; + +// clipper helper + +template +inline int clip_int(int val) +{ + if (val < MIN ) return MIN; + if (val > MAX ) return MAX; + return val; +} + +struct percent_conv_impl +{ + template + struct result + { + typedef unsigned type; + }; + + unsigned operator() (double val) const + { + return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); + } +}; + +struct alpha_conv_impl +{ + template + struct result + { + typedef unsigned type; + }; + + unsigned operator() (double val) const + { + return clip_int<0,255>(int((255.0 * val) + 0.5)); + } +}; + + +// http://www.w3.org/TR/css3-color/#hsl-color +inline double hue_to_rgb( double m1, double m2, double h) +{ + if (h < 0.0) h = h + 1.0; + else if (h > 1) h = h - 1.0; + + if (h * 6 < 1.0) + return m1 + (m2 - m1) * h * 6.0; + if (h * 2 < 1.0) + return m2; + if (h * 3 < 2.0) + return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; + return m1; +} + +struct hsl_conv_impl +{ + template + struct result + { + typedef void type; + }; + + template + void operator() (T0 & c, T1 h, T2 s, T3 l) const + { + double m1,m2; + // normalize values + h /= 360.0; + s /= 100.0; + l /= 100.0; + + if (l <= 0.5) + m2 = l * (s + 1.0); + else + m2 = l + s - l*s; + m1 = l * 2 - m2; + + double r = hue_to_rgb(m1, m2, h + 1.0/3.0); + double g = hue_to_rgb(m1, m2, h); + double b = hue_to_rgb(m1, m2, h - 1.0/3.0); + + c.r = clip_int<0,255>(int((255.0 * r) + 0.5)); + c.g = clip_int<0,255>(int((255.0 * g) + 0.5)); + c.b = clip_int<0,255>(int((255.0 * b) + 0.5)); + } +}; + + +template +struct css_color_grammar : qi::grammar +{ + + css_color_grammar() + : css_color_grammar::base_type(css_color) + + { + using qi::lit; + using qi::_val; + using qi::double_; + using qi::_1; + using qi::_a; + using qi::_b; + using qi::_c; + using ascii::no_case; + using phoenix::at_c; + + css_color %= rgba_color + | rgba_percent_color + | hsl_percent_color + | hex_color + | hex_color_small + | no_case[named]; + + hex_color %= lit('#') + >> hex2 + >> hex2 + >> hex2 + >> -hex2 + ; + + hex_color_small = lit('#') + >> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ] + >> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ] + >> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ] + >> -hex1[ at_c<3>(_val) = _1 | _1 << 4 ] + ; + + rgba_color = lit("rgb") >> -lit('a') + >> lit('(') + >> dec3 [at_c<0>(_val) = _1] >> ',' + >> dec3 [at_c<1>(_val) = _1] >> ',' + >> dec3 [at_c<2>(_val) = _1] + >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) + >> lit(')') + ; + + rgba_percent_color = lit("rgb") >> -lit('a') + >> lit('(') + >> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ',' + >> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ',' + >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' + >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) + >> lit(')') + ; + + hsl_percent_color = lit("hsl") >> -lit('a') + >> lit('(') + >> double_ [ _a = _1] >> ',' // hue 0..360 + >> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100% + >> double_ [ _c = _1] >> '%' // lightness 0..100% + >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1 + >> lit (')') [ hsl_converter(_val,_a,_b,_c)] + ; + } + + qi::uint_parser< unsigned, 16, 2, 2 > hex2 ; + qi::uint_parser< unsigned, 16, 1, 1 > hex1 ; + qi::uint_parser< unsigned, 10, 1, 3 > dec3 ; + qi::rule rgba_color; + qi::rule rgba_percent_color; + qi::rule,css(), ascii_space_type> hsl_percent_color; + qi::rule hex_color; + qi::rule hex_color_small; + qi::rule css_color; + named_colors_ named; + phoenix::function percent_converter; + phoenix::function alpha_converter; + phoenix::function hsl_converter; +}; + +} + +#endif + #endif // MAPNIK_CSS_COLOR_GRAMMAR_HPP diff --git a/include/mapnik/css_color_grammar_deprecated.hpp b/include/mapnik/css_color_grammar_deprecated.hpp deleted file mode 100644 index d2987b660..000000000 --- a/include/mapnik/css_color_grammar_deprecated.hpp +++ /dev/null @@ -1,420 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP -#define MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP - -// mapnik -#include - -// spirit2 -#include -#include -#include - -// phoenix -#include -#include -#include -#include - -// fusion -#include - -// not in boost 1.41 -//#include - -// stl -#include - -//BOOST_FUSION_ADAPT_CLASS( -// mapnik::color, -// (unsigned, unsigned, obj.red(), obj.set_red(val)) -// (unsigned, unsigned, obj.green(), obj.set_green(val)) -// (unsigned, unsigned, obj.blue(), obj.set_blue(val)) -// (unsigned, unsigned, obj.alpha(), obj.set_alpha(val)) -// ) - -namespace mapnik -{ -// temp workaround . TODO: adapt mapnik::color -struct css -{ - css () - : r(255),g(255),b(255),a(255) {} - css(unsigned r_,unsigned g_, unsigned b_,unsigned a_ = 0xff) - : r(r_),g(g_),b(b_),a(a_) {} - - unsigned r; - unsigned g; - unsigned b; - unsigned a; -}; - -} - -BOOST_FUSION_ADAPT_STRUCT( - mapnik::css, - (unsigned, r) - (unsigned, g) - (unsigned, b) - (unsigned, a) - ) - -namespace mapnik -{ - -namespace qi = boost::spirit::qi; -namespace ascii = boost::spirit::ascii; -namespace phoenix = boost::phoenix; - -typedef boost::spirit::ascii::space_type ascii_space_type; - -struct named_colors_ : qi::symbols -{ - named_colors_() - { - add - ("aliceblue", css(240, 248, 255)) - ("antiquewhite", css(250, 235, 215)) - ("aqua", css(0, 255, 255)) - ("aquamarine", css(127, 255, 212)) - ("azure", css(240, 255, 255)) - ("beige", css(245, 245, 220)) - ("bisque", css(255, 228, 196)) - ("black", css(0, 0, 0)) - ("blanchedalmond", css(255,235,205)) - ("blue", css(0, 0, 255)) - ("blueviolet", css(138, 43, 226)) - ("brown", css(165, 42, 42)) - ("burlywood", css(222, 184, 135)) - ("cadetblue", css(95, 158, 160)) - ("chartreuse", css(127, 255, 0)) - ("chocolate", css(210, 105, 30)) - ("coral", css(255, 127, 80)) - ("cornflowerblue", css(100, 149, 237)) - ("cornsilk", css(255, 248, 220)) - ("crimson", css(220, 20, 60)) - ("cyan", css(0, 255, 255)) - ("darkblue", css(0, 0, 139)) - ("darkcyan", css(0, 139, 139)) - ("darkgoldenrod", css(184, 134, 11)) - ("darkgray", css(169, 169, 169)) - ("darkgreen", css(0, 100, 0)) - ("darkgrey", css(169, 169, 169)) - ("darkkhaki", css(189, 183, 107)) - ("darkmagenta", css(139, 0, 139)) - ("darkolivegreen", css(85, 107, 47)) - ("darkorange", css(255, 140, 0)) - ("darkorchid", css(153, 50, 204)) - ("darkred", css(139, 0, 0)) - ("darksalmon", css(233, 150, 122)) - ("darkseagreen", css(143, 188, 143)) - ("darkslateblue", css(72, 61, 139)) - ("darkslategrey", css(47, 79, 79)) - ("darkturquoise", css(0, 206, 209)) - ("darkviolet", css(148, 0, 211)) - ("deeppink", css(255, 20, 147)) - ("deepskyblue", css(0, 191, 255)) - ("dimgray", css(105, 105, 105)) - ("dimgrey", css(105, 105, 105)) - ("dodgerblue", css(30, 144, 255)) - ("firebrick", css(178, 34, 34)) - ("floralwhite", css(255, 250, 240)) - ("forestgreen", css(34, 139, 34)) - ("fuchsia", css(255, 0, 255)) - ("gainsboro", css(220, 220, 220)) - ("ghostwhite", css(248, 248, 255)) - ("gold", css(255, 215, 0)) - ("goldenrod", css(218, 165, 32)) - ("gray", css(128, 128, 128)) - ("grey", css(128, 128, 128)) - ("green", css(0, 128, 0)) - ("greenyellow", css(173, 255, 47)) - ("honeydew", css(240, 255, 240)) - ("hotpink", css(255, 105, 180)) - ("indianred", css(205, 92, 92)) - ("indigo", css(75, 0, 130)) - ("ivory", css(255, 255, 240)) - ("khaki", css(240, 230, 140)) - ("lavender", css(230, 230, 250)) - ("lavenderblush", css(255, 240, 245)) - ("lawngreen", css(124, 252, 0)) - ("lemonchiffon", css(255, 250, 205)) - ("lightblue", css(173, 216, 230)) - ("lightcoral", css(240, 128, 128)) - ("lightcyan", css(224, 255, 255)) - ("lightgoldenrodyellow", css(250, 250, 210)) - ("lightgray", css(211, 211, 211)) - ("lightgreen", css(144, 238, 144)) - ("lightgrey", css(211, 211, 211)) - ("lightpink", css(255, 182, 193)) - ("lightsalmon", css(255, 160, 122)) - ("lightseagreen", css(32, 178, 170)) - ("lightskyblue", css(135, 206, 250)) - ("lightslategray", css(119, 136, 153)) - ("lightslategrey", css(119, 136, 153)) - ("lightsteelblue", css(176, 196, 222)) - ("lightyellow", css(255, 255, 224)) - ("lime", css(0, 255, 0)) - ("limegreen", css(50, 205, 50)) - ("linen", css(250, 240, 230)) - ("magenta", css(255, 0, 255)) - ("maroon", css(128, 0, 0)) - ("mediumaquamarine", css(102, 205, 170)) - ("mediumblue", css(0, 0, 205)) - ("mediumorchid", css(186, 85, 211)) - ("mediumpurple", css(147, 112, 219)) - ("mediumseagreen", css(60, 179, 113)) - ("mediumslateblue", css(123, 104, 238)) - ("mediumspringgreen", css(0, 250, 154)) - ("mediumturquoise", css(72, 209, 204)) - ("mediumvioletred", css(199, 21, 133)) - ("midnightblue", css(25, 25, 112)) - ("mintcream", css(245, 255, 250)) - ("mistyrose", css(255, 228, 225)) - ("moccasin", css(255, 228, 181)) - ("navajowhite", css(255, 222, 173)) - ("navy", css(0, 0, 128)) - ("oldlace", css(253, 245, 230)) - ("olive", css(128, 128, 0)) - ("olivedrab", css(107, 142, 35)) - ("orange", css(255, 165, 0)) - ("orangered", css(255, 69, 0)) - ("orchid", css(218, 112, 214)) - ("palegoldenrod", css(238, 232, 170)) - ("palegreen", css(152, 251, 152)) - ("paleturquoise", css(175, 238, 238)) - ("palevioletred", css(219, 112, 147)) - ("papayawhip", css(255, 239, 213)) - ("peachpuff", css(255, 218, 185)) - ("peru", css(205, 133, 63)) - ("pink", css(255, 192, 203)) - ("plum", css(221, 160, 221)) - ("powderblue", css(176, 224, 230)) - ("purple", css(128, 0, 128)) - ("red", css(255, 0, 0)) - ("rosybrown", css(188, 143, 143)) - ("royalblue", css(65, 105, 225)) - ("saddlebrown", css(139, 69, 19)) - ("salmon", css(250, 128, 114)) - ("sandybrown", css(244, 164, 96)) - ("seagreen", css(46, 139, 87)) - ("seashell", css(255, 245, 238)) - ("sienna", css(160, 82, 45)) - ("silver", css(192, 192, 192)) - ("skyblue", css(135, 206, 235)) - ("slateblue", css(106, 90, 205)) - ("slategray", css(112, 128, 144)) - ("slategrey", css(112, 128, 144)) - ("snow", css(255, 250, 250)) - ("springgreen", css(0, 255, 127)) - ("steelblue", css(70, 130, 180)) - ("tan", css(210, 180, 140)) - ("teal", css(0, 128, 128)) - ("thistle", css(216, 191, 216)) - ("tomato", css(255, 99, 71)) - ("turquoise", css(64, 224, 208)) - ("violet", css(238, 130, 238)) - ("wheat", css(245, 222, 179)) - ("white", css(255, 255, 255)) - ("whitesmoke", css(245, 245, 245)) - ("yellow", css(255, 255, 0)) - ("yellowgreen", css(154, 205, 50)) - ("transparent", css(0, 0, 0, 0)) - ; - } -} ; - -// clipper helper - -template -inline int clip_int(int val) -{ - if (val < MIN ) return MIN; - if (val > MAX ) return MAX; - return val; -} - -struct percent_conv_impl -{ - template - struct result - { - typedef unsigned type; - }; - - unsigned operator() (double val) const - { - return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); - } -}; - -struct alpha_conv_impl -{ - template - struct result - { - typedef unsigned type; - }; - - unsigned operator() (double val) const - { - return clip_int<0,255>(int((255.0 * val) + 0.5)); - } -}; - - -// http://www.w3.org/TR/css3-color/#hsl-color -inline double hue_to_rgb( double m1, double m2, double h) -{ - if (h < 0.0) h = h + 1.0; - else if (h > 1) h = h - 1.0; - - if (h * 6 < 1.0) - return m1 + (m2 - m1) * h * 6.0; - if (h * 2 < 1.0) - return m2; - if (h * 3 < 2.0) - return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; - return m1; -} - -struct hsl_conv_impl -{ - template - struct result - { - typedef void type; - }; - - template - void operator() (T0 & c, T1 h, T2 s, T3 l) const - { - double m1,m2; - // normalize values - h /= 360.0; - s /= 100.0; - l /= 100.0; - - if (l <= 0.5) - m2 = l * (s + 1.0); - else - m2 = l + s - l*s; - m1 = l * 2 - m2; - - double r = hue_to_rgb(m1, m2, h + 1.0/3.0); - double g = hue_to_rgb(m1, m2, h); - double b = hue_to_rgb(m1, m2, h - 1.0/3.0); - - c.r = clip_int<0,255>(int((255.0 * r) + 0.5)); - c.g = clip_int<0,255>(int((255.0 * g) + 0.5)); - c.b = clip_int<0,255>(int((255.0 * b) + 0.5)); - } -}; - - -template -struct css_color_grammar : qi::grammar -{ - - css_color_grammar() - : css_color_grammar::base_type(css_color) - - { - using qi::lit; - using qi::_val; - using qi::double_; - using qi::_1; - using qi::_a; - using qi::_b; - using qi::_c; - using ascii::no_case; - using phoenix::at_c; - - css_color %= rgba_color - | rgba_percent_color - | hsl_percent_color - | hex_color - | hex_color_small - | no_case[named]; - - hex_color %= lit('#') - >> hex2 - >> hex2 - >> hex2 - >> -hex2 - ; - - hex_color_small = lit('#') - >> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ] - >> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ] - >> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ] - >> -hex1[ at_c<3>(_val) = _1 | _1 << 4 ] - ; - - rgba_color = lit("rgb") >> -lit('a') - >> lit('(') - >> dec3 [at_c<0>(_val) = _1] >> ',' - >> dec3 [at_c<1>(_val) = _1] >> ',' - >> dec3 [at_c<2>(_val) = _1] - >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) - >> lit(')') - ; - - rgba_percent_color = lit("rgb") >> -lit('a') - >> lit('(') - >> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ',' - >> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ',' - >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' - >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) - >> lit(')') - ; - - hsl_percent_color = lit("hsl") >> -lit('a') - >> lit('(') - >> double_ [ _a = _1] >> ',' // hue 0..360 - >> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100% - >> double_ [ _c = _1] >> '%' // lightness 0..100% - >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1 - >> lit (')') [ hsl_converter(_val,_a,_b,_c)] - ; - } - - qi::uint_parser< unsigned, 16, 2, 2 > hex2 ; - qi::uint_parser< unsigned, 16, 1, 1 > hex1 ; - qi::uint_parser< unsigned, 10, 1, 3 > dec3 ; - qi::rule rgba_color; - qi::rule rgba_percent_color; - qi::rule,css(), ascii_space_type> hsl_percent_color; - qi::rule hex_color; - qi::rule hex_color_small; - qi::rule css_color; - named_colors_ named; - phoenix::function percent_converter; - phoenix::function alpha_converter; - phoenix::function hsl_converter; -}; - -} - -#endif // MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index 874c162b5..ef4d94d23 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -55,12 +55,10 @@ namespace mapnik { public: enum severity_type { - info, - debug, - warn, - error, - fatal, - none + debug = 0, + warn = 1, + error = 2, + none = 3 }; typedef boost::unordered_map severity_map; @@ -180,7 +178,7 @@ namespace mapnik { /* Base log class, should not log anything when no MAPNIK_LOG is defined - This is used for info/debug/warn reporting that should not output + This is used for debug/warn reporting that should not output anything when not compiling for speed. */ template