Merge branch 'master' into grouped-rendering
Conflicts: include/mapnik/feature_type_style.hpp src/feature_type_style.cpp
This commit is contained in:
commit
ac8b4c6d2d
550 changed files with 15151 additions and 10654 deletions
19
.gitignore
vendored
19
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
.DS_Store
|
||||||
|
*~
|
||||||
*.o
|
*.o
|
||||||
*.pyc
|
*.pyc
|
||||||
*.os
|
*.os
|
||||||
|
@ -19,7 +21,24 @@ tests/python_tests/raster_colorizer_test_save.xml
|
||||||
utils/mapnik-config/mapnik-config
|
utils/mapnik-config/mapnik-config
|
||||||
utils/mapnik-config/mapnik2.pc
|
utils/mapnik-config/mapnik2.pc
|
||||||
utils/shapeindex/shapeindex
|
utils/shapeindex/shapeindex
|
||||||
|
utils/ogrindex/ogrindex
|
||||||
utils/pgsql2sqlite/pgsql2sqlite
|
utils/pgsql2sqlite/pgsql2sqlite
|
||||||
utils/svg2png/svg2png
|
utils/svg2png/svg2png
|
||||||
demo/python/demo*
|
demo/python/demo*
|
||||||
demo/python/map.xml
|
demo/python/map.xml
|
||||||
|
tests/cpp_tests/svg_renderer_tests/background_color_test
|
||||||
|
tests/cpp_tests/svg_renderer_tests/combined_test
|
||||||
|
tests/cpp_tests/svg_renderer_tests/compilation_test
|
||||||
|
tests/cpp_tests/svg_renderer_tests/file_output_test
|
||||||
|
tests/cpp_tests/svg_renderer_tests/file_output_test_case.svg
|
||||||
|
tests/cpp_tests/svg_renderer_tests/path_element_test
|
||||||
|
tests/cpp_tests/svg_renderer_tests/path_element_test_case_1.svg
|
||||||
|
tests/cpp_tests/svg_renderer_tests/root_element_test
|
||||||
|
tests/data/sqlite/*index
|
||||||
|
demo/c++/cairo-demo.pdf
|
||||||
|
demo/c++/cairo-demo.png
|
||||||
|
demo/c++/cairo-demo256.png
|
||||||
|
demo/c++/demo.jpg
|
||||||
|
demo/c++/demo.png
|
||||||
|
demo/c++/demo256.png
|
||||||
|
|
||||||
|
|
64
CHANGELOG
64
CHANGELOG
|
@ -11,7 +11,19 @@ Developers: Please commit along with changes.
|
||||||
For a complete change history, see the SVN log.
|
For a complete change history, see the SVN log.
|
||||||
|
|
||||||
|
|
||||||
Mapnik Trunk
|
Mapnik 2.1.0
|
||||||
|
------------
|
||||||
|
|
||||||
|
- New CSV plugin - reads tabular files - autodetecting geo columns, newlines, and delimiters. Uses in-memory featureset for fast rendering and is not designed for large files (#902)
|
||||||
|
|
||||||
|
- Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908)
|
||||||
|
|
||||||
|
- Added <layer_by_sql> parameter in OGR plugin to select a layer by SQL query (besides name or index): see http://www.gdal.org/ogr/ogr_sql.html for specifications (kunitoki) (#472)
|
||||||
|
|
||||||
|
- Added suppport for output maps as tiff files (addresses #967 partially)
|
||||||
|
|
||||||
|
|
||||||
|
Mapnik 2.0.0
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Add minimum-path-length property to text_symbolizer to allow labels to be placed only on lines of a certain length (#865)
|
- Add minimum-path-length property to text_symbolizer to allow labels to be placed only on lines of a certain length (#865)
|
||||||
|
@ -101,6 +113,50 @@ Mapnik Trunk
|
||||||
- Implement MarkersSymbolizer in Cairo render and improve the markers placement finder. (#553)
|
- Implement MarkersSymbolizer in Cairo render and improve the markers placement finder. (#553)
|
||||||
|
|
||||||
|
|
||||||
|
Mapnik 0.7.2 Release
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
- Added forward compatibility for Mapnik 2.0 XML syntax (https://trac.mapnik.org/wiki/Mapnik2/Changes)
|
||||||
|
|
||||||
|
- Build fixes to ensure boost_threads are not used unless THREADING=multi build option is used
|
||||||
|
|
||||||
|
- Fixes for the clang compiler
|
||||||
|
|
||||||
|
- Support for latest libpng (>= 1.5.x) (r2999)
|
||||||
|
|
||||||
|
- Fixes to the postgres pool
|
||||||
|
|
||||||
|
- Fix for correct transparency levels in png256/png8 output (#540)
|
||||||
|
|
||||||
|
- Various build system fixes, especially for gcc compiler on open solaris.
|
||||||
|
|
||||||
|
- When plugins are not found, report the searched directories (#568)
|
||||||
|
|
||||||
|
- Improved font loading support (#559)
|
||||||
|
|
||||||
|
- Fix to shapeindex for allowing indexing of directory of shapefiles like `shapeindex dir/*shp`
|
||||||
|
|
||||||
|
- Fixed handling of null and multipatch shapes in shapefile driver - avoiding inf loop (#573)
|
||||||
|
|
||||||
|
- Fixed raster alpha blending (#589,#674)
|
||||||
|
|
||||||
|
- Enhanced support for faster reprojection if proj >= 4.8 is used (#575)
|
||||||
|
|
||||||
|
- Allow for late-binding of datasources (#622)
|
||||||
|
|
||||||
|
- Fix to OSM plugin to avoid over-caching of data (#542)
|
||||||
|
|
||||||
|
- Various fixes to sqlite, ogr, and occi driver backported from trunk.
|
||||||
|
|
||||||
|
- Ensured that '\n' triggers linebreaks in text rendering (#584)
|
||||||
|
|
||||||
|
- Support for boost filesystem v3
|
||||||
|
|
||||||
|
- Fixes to cairo renderer to avoid missing images (r2526)
|
||||||
|
|
||||||
|
- Fixed reading of label_position_tolerance on text_symbolizer and height for building_symbolizer
|
||||||
|
|
||||||
|
|
||||||
Mapnik 0.7.0 Release
|
Mapnik 0.7.0 Release
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
@ -218,8 +274,6 @@ Mapnik 0.7.0 Release
|
||||||
|
|
||||||
- Python: Fixed potential crash if pycairo support is enabled but python-cairo module is missing (#392)
|
- Python: Fixed potential crash if pycairo support is enabled but python-cairo module is missing (#392)
|
||||||
|
|
||||||
- Python: Added 'mapnik.mapnik_svn_revision()' function to svn revision of Mapnik was compiled at.
|
|
||||||
|
|
||||||
- Python: Added 'mapnik.has_pycairo()' function to test for pycairo support (r1278) (#284)
|
- Python: Added 'mapnik.has_pycairo()' function to test for pycairo support (r1278) (#284)
|
||||||
|
|
||||||
- Python: Added 'mapnik.register_plugins()' and 'mapnik.register_fonts()' functions (r1256)
|
- Python: Added 'mapnik.register_plugins()' and 'mapnik.register_fonts()' functions (r1256)
|
||||||
|
@ -353,10 +407,6 @@ Mapnik 0.6.0 Release
|
||||||
|
|
||||||
- Python: Added further pickling/copy support to Map, Layers, Datasources, Styles,and Rules (r907,r913,r921)
|
- Python: Added further pickling/copy support to Map, Layers, Datasources, Styles,and Rules (r907,r913,r921)
|
||||||
|
|
||||||
- OGCServer: Added support for load_map(), allowing reading of XML styles and layers (r901)
|
|
||||||
|
|
||||||
- OGCServer: Enabled friendly html output when in debug mode (debug=1 in ogcserver.conf) (r899)
|
|
||||||
|
|
||||||
- Plugins: Added Sqlite driver for reading sqlite databases (r881)
|
- Plugins: Added Sqlite driver for reading sqlite databases (r881)
|
||||||
|
|
||||||
- Python: Exposed a number of properties for the Text Symbolizer (r869)
|
- Python: Exposed a number of properties for the Text Symbolizer (r869)
|
||||||
|
|
246
SConstruct
246
SConstruct
|
@ -102,6 +102,7 @@ PLUGINS = { # plugins with external dependencies
|
||||||
|
|
||||||
# plugins without external dependencies requiring CheckLibWithHeader...
|
# plugins without external dependencies requiring CheckLibWithHeader...
|
||||||
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
||||||
|
'csv': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
||||||
'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
||||||
'kismet': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
'kismet': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'},
|
||||||
}
|
}
|
||||||
|
@ -139,34 +140,6 @@ def strip_first(string,find,replace=''):
|
||||||
return string.replace(find,replace,1)
|
return string.replace(find,replace,1)
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def get_libtool_major_version():
|
|
||||||
"""libtool >= 2.1b support lt_dlopenadvise and the previous
|
|
||||||
release appears to be 1.9f (based on NEWS) so checking for
|
|
||||||
>= 2 seems adequate.
|
|
||||||
"""
|
|
||||||
cmd = 'libtool'
|
|
||||||
if platform.uname()[0] == "Darwin":
|
|
||||||
cmd = 'glibtool'
|
|
||||||
version = None
|
|
||||||
fallback_version = 2
|
|
||||||
pattern = r'(.*[^\S])(\d{1}\.\d+\.?\d?)(.*[^\S])'
|
|
||||||
ret = os.popen('%s --version' % cmd).read()
|
|
||||||
match = re.match(pattern,ret)
|
|
||||||
if match:
|
|
||||||
groups = match.groups()
|
|
||||||
if len(groups):
|
|
||||||
version_string = groups[1]
|
|
||||||
if version_string:
|
|
||||||
version_string = version_string.split('.')[0]
|
|
||||||
try:
|
|
||||||
version = int(version_string)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
if not version:
|
|
||||||
color_print(1,'Could not detect libtool --version, assuming major version 2')
|
|
||||||
return fallback_version
|
|
||||||
return version
|
|
||||||
|
|
||||||
# http://www.scons.org/wiki/InstallTargets
|
# http://www.scons.org/wiki/InstallTargets
|
||||||
def create_uninstall_target(env, path, is_glob=False):
|
def create_uninstall_target(env, path, is_glob=False):
|
||||||
if 'uninstall' in COMMAND_LINE_TARGETS:
|
if 'uninstall' in COMMAND_LINE_TARGETS:
|
||||||
|
@ -230,7 +203,7 @@ def sort_paths(items,priority):
|
||||||
else:
|
else:
|
||||||
path_types['user'].append(i)
|
path_types['user'].append(i)
|
||||||
# key system libs (likely others will fall into 'other')
|
# key system libs (likely others will fall into 'other')
|
||||||
elif '/usr/' in i or '/System' in i or '/lib' in i:
|
elif '/usr/' in i or '/System' in i or i.startswith('/lib'):
|
||||||
path_types['system'].append(i)
|
path_types['system'].append(i)
|
||||||
# anything not yet matched...
|
# anything not yet matched...
|
||||||
# likely a combo of rare system lib paths and
|
# likely a combo of rare system lib paths and
|
||||||
|
@ -301,6 +274,7 @@ opts.AddVariables(
|
||||||
EnumVariable('OPTIMIZATION','Set g++ optimization level','3', ['0','1','2','3','4','s']),
|
EnumVariable('OPTIMIZATION','Set g++ optimization level','3', ['0','1','2','3','4','s']),
|
||||||
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
|
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
|
||||||
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
|
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', '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.', ''),
|
||||||
|
|
||||||
|
@ -317,7 +291,9 @@ opts.AddVariables(
|
||||||
('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)',''),
|
||||||
('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'),
|
('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'),
|
||||||
('PATH_INSERT', 'A custom path to append to the $PATH env to prioritize usage of shell programs like pkg-config will be used 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_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
|
||||||
|
@ -327,7 +303,7 @@ opts.AddVariables(
|
||||||
('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False),
|
('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False),
|
||||||
('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 or full path to boost_python lib (e.g. "boost_python-py26" or "/usr/lib/libboost_python.dylib")',''),
|
('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'),
|
||||||
|
@ -373,7 +349,7 @@ opts.AddVariables(
|
||||||
# Other variables
|
# Other variables
|
||||||
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
|
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
|
||||||
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)',''),
|
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)',''),
|
||||||
('LIB_DIR_NAME','Name to use for the subfolder beside libmapnik where fonts and plugins are installed','mapnik2'),
|
('LIB_DIR_NAME','Name to use for the subfolder beside libmapnik where fonts and plugins are installed','mapnik'),
|
||||||
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
|
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
|
||||||
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
|
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
|
||||||
BoolVariable('PYTHON_DYNAMIC_LOOKUP', 'On OSX, do not directly link python lib, but rather dynamically lookup symbols', 'True'),
|
BoolVariable('PYTHON_DYNAMIC_LOOKUP', 'On OSX, do not directly link python lib, but rather dynamically lookup symbols', 'True'),
|
||||||
|
@ -423,16 +399,15 @@ pickle_store = [# Scons internal variables
|
||||||
'PYTHON_INSTALL_LOCATION',
|
'PYTHON_INSTALL_LOCATION',
|
||||||
'PYTHON_SYS_PREFIX',
|
'PYTHON_SYS_PREFIX',
|
||||||
'COLOR_PRINT',
|
'COLOR_PRINT',
|
||||||
'HAS_BOOST_SYSTEM',
|
|
||||||
'SVN_REVISION',
|
|
||||||
'HAS_CAIRO',
|
'HAS_CAIRO',
|
||||||
'HAS_PYCAIRO',
|
'HAS_PYCAIRO',
|
||||||
'HAS_LIBXML2',
|
'HAS_LIBXML2',
|
||||||
'LIBTOOL_SUPPORTS_ADVISE',
|
|
||||||
'PYTHON_IS_64BIT',
|
'PYTHON_IS_64BIT',
|
||||||
'SAMPLE_INPUT_PLUGINS',
|
'SAMPLE_INPUT_PLUGINS',
|
||||||
'PKG_CONFIG_PATH',
|
'PKG_CONFIG_PATH',
|
||||||
'PATH_INSERT',
|
'PATH',
|
||||||
|
'PATH_REMOVE',
|
||||||
|
'PATH_REPLACE',
|
||||||
'MAPNIK_LIB_DIR',
|
'MAPNIK_LIB_DIR',
|
||||||
'MAPNIK_LIB_DIR_DEST',
|
'MAPNIK_LIB_DIR_DEST',
|
||||||
'INSTALL_PREFIX',
|
'INSTALL_PREFIX',
|
||||||
|
@ -448,6 +423,8 @@ pickle_store = [# Scons internal variables
|
||||||
'CAIROMM_LIBPATHS',
|
'CAIROMM_LIBPATHS',
|
||||||
'CAIROMM_LINKFLAGS',
|
'CAIROMM_LINKFLAGS',
|
||||||
'CAIROMM_CPPPATHS',
|
'CAIROMM_CPPPATHS',
|
||||||
|
'SVG_RENDERER',
|
||||||
|
'SQLITE_LINKFLAGS'
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add all other user configurable options to pickle pickle_store
|
# Add all other user configurable options to pickle pickle_store
|
||||||
|
@ -522,19 +499,13 @@ if sys.platform == "win32":
|
||||||
|
|
||||||
color_print(4,'\nWelcome to Mapnik...\n')
|
color_print(4,'\nWelcome to Mapnik...\n')
|
||||||
|
|
||||||
color_print(1,'*'*45)
|
|
||||||
color_print(1,'You are compiling Mapnik trunk (aka Mapnik2)')
|
|
||||||
color_print(1,'See important details at:\nhttp://trac.mapnik.org/wiki/Mapnik2')
|
|
||||||
color_print(1,('*'*45)+'\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:
|
||||||
context.Message( 'Sorting lib and inc compiler paths by priority... %s' % ','.join(prefs) )
|
context.Message( 'Sorting lib and inc compiler paths...')
|
||||||
env['LIBPATH'] = sort_paths(env['LIBPATH'],prefs)
|
env['LIBPATH'] = sort_paths(env['LIBPATH'],prefs)
|
||||||
env['CPPPATH'] = sort_paths(env['CPPPATH'],prefs)
|
env['CPPPATH'] = sort_paths(env['CPPPATH'],prefs)
|
||||||
if silent:
|
if silent:
|
||||||
|
@ -835,10 +806,10 @@ int main()
|
||||||
|
|
||||||
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,'\nFound icu version... %s\n' % result)
|
color_print(4,'found: icu %s' % result)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
color_print(1,'\nFound insufficient icu version... %s\n' % result)
|
color_print(1,'\nFound insufficient icu version... %s' % result)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def boost_regex_has_icu(context):
|
def boost_regex_has_icu(context):
|
||||||
|
@ -877,18 +848,34 @@ def sqlite_has_rtree(context):
|
||||||
|
|
||||||
ret = context.TryRun("""
|
ret = context.TryRun("""
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
}
|
#include <stdio.h>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
sqlite3_rtree_geometry *p;
|
sqlite3* db;
|
||||||
//sqlite3_compileoption_used("ENABLE_RTREE");
|
int rc;
|
||||||
|
rc = sqlite3_open(":memory:", &db);
|
||||||
|
if (rc != SQLITE_OK)
|
||||||
|
{
|
||||||
|
printf("error 1: %s\\n", sqlite3_errmsg(db));
|
||||||
|
}
|
||||||
|
const char * sql = "create virtual table foo using rtree(pkid, xmin, xmax, ymin, ymax)";
|
||||||
|
rc = sqlite3_exec(db, sql, 0, 0, 0);
|
||||||
|
if (rc != SQLITE_OK)
|
||||||
|
{
|
||||||
|
printf("error 2: %s\\n", sqlite3_errmsg(db));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("yes, has rtree!\\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
""", '.cpp')
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
""", '.c')
|
||||||
context.Message('Checking if SQLite supports RTREE... ')
|
context.Message('Checking if SQLite supports RTREE... ')
|
||||||
context.Result(ret[0])
|
context.Result(ret[0])
|
||||||
if ret[0]:
|
if ret[0]:
|
||||||
|
@ -933,7 +920,7 @@ if not preconfigured:
|
||||||
opts.files.append(conf)
|
opts.files.append(conf)
|
||||||
color_print(4,"SCons CONFIG found: '%s', variables will be inherited..." % conf)
|
color_print(4,"SCons CONFIG found: '%s', variables will be inherited..." % conf)
|
||||||
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:
|
||||||
|
@ -956,8 +943,6 @@ if not preconfigured:
|
||||||
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['LIBTOOL_SUPPORTS_ADVISE'] = get_libtool_major_version() >= 2
|
|
||||||
|
|
||||||
env['MISSING_DEPS'] = []
|
env['MISSING_DEPS'] = []
|
||||||
env['SKIPPED_DEPS'] = []
|
env['SKIPPED_DEPS'] = []
|
||||||
env['HAS_CAIRO'] = False
|
env['HAS_CAIRO'] = False
|
||||||
|
@ -966,14 +951,13 @@ if not preconfigured:
|
||||||
env['CAIROMM_CPPPATHS'] = []
|
env['CAIROMM_CPPPATHS'] = []
|
||||||
env['HAS_PYCAIRO'] = False
|
env['HAS_PYCAIRO'] = False
|
||||||
env['HAS_LIBXML2'] = False
|
env['HAS_LIBXML2'] = False
|
||||||
env['SVN_REVISION'] = None
|
|
||||||
env['LIBMAPNIK_LIBS'] = []
|
env['LIBMAPNIK_LIBS'] = []
|
||||||
env['LIBMAPNIK_CPPATHS'] = []
|
env['LIBMAPNIK_CPPATHS'] = []
|
||||||
env['LIBMAPNIK_CXXFLAGS'] = []
|
env['LIBMAPNIK_CXXFLAGS'] = []
|
||||||
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
|
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
|
||||||
env['PLUGINS'] = PLUGINS
|
env['PLUGINS'] = PLUGINS
|
||||||
env['EXTRA_FREETYPE_LIBS'] = []
|
env['EXTRA_FREETYPE_LIBS'] = []
|
||||||
|
env['SQLITE_LINKFLAGS'] = []
|
||||||
# previously a leading / was expected for LIB_DIR_NAME
|
# previously a leading / was expected for LIB_DIR_NAME
|
||||||
# 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):
|
||||||
|
@ -1007,15 +991,16 @@ if not preconfigured:
|
||||||
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}mapnik2${LIBSUFFIX}'
|
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}'
|
||||||
else:
|
else:
|
||||||
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik2${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"]
|
||||||
if env['PATH_INSERT']:
|
|
||||||
env['ENV']['PATH'] = os.path.realpath(env['PATH_INSERT']) + ':' + env['ENV']['PATH']
|
if env['PATH']:
|
||||||
|
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
|
||||||
|
|
||||||
if env['SYSTEM_FONTS']:
|
if env['SYSTEM_FONTS']:
|
||||||
if not os.path.isdir(env['SYSTEM_FONTS']):
|
if not os.path.isdir(env['SYSTEM_FONTS']):
|
||||||
|
@ -1072,15 +1057,17 @@ if not preconfigured:
|
||||||
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
|
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
|
||||||
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
|
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
|
||||||
|
|
||||||
conf.parse_config('FREETYPE_CONFIG')
|
if conf.parse_config('FREETYPE_CONFIG'):
|
||||||
|
|
||||||
# check if freetype links to bz2
|
# check if freetype links to bz2
|
||||||
if env['RUNTIME_LINK'] == 'static':
|
if env['RUNTIME_LINK'] == 'static':
|
||||||
temp_env = env.Clone()
|
temp_env = env.Clone()
|
||||||
temp_env['LIBS'] = []
|
temp_env['LIBS'] = []
|
||||||
|
try:
|
||||||
temp_env.ParseConfig('%s --libs' % env['FREETYPE_CONFIG'])
|
temp_env.ParseConfig('%s --libs' % env['FREETYPE_CONFIG'])
|
||||||
if 'bz2' in temp_env['LIBS']:
|
if 'bz2' in temp_env['LIBS']:
|
||||||
env['EXTRA_FREETYPE_LIBS'].append('bz2')
|
env['EXTRA_FREETYPE_LIBS'].append('bz2')
|
||||||
|
except OSError,e:
|
||||||
|
pass
|
||||||
|
|
||||||
# libxml2 should be optional but is currently not
|
# libxml2 should be optional but is currently not
|
||||||
# https://github.com/mapnik/mapnik/issues/913
|
# https://github.com/mapnik/mapnik/issues/913
|
||||||
|
@ -1107,14 +1094,14 @@ if not preconfigured:
|
||||||
if env['PRIORITIZE_LINKING']:
|
if env['PRIORITIZE_LINKING']:
|
||||||
conf.prioritize_paths(silent=False)
|
conf.prioritize_paths(silent=False)
|
||||||
|
|
||||||
for libinfo in LIBSHEADERS:
|
for libname, headers, required, lang in LIBSHEADERS:
|
||||||
if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], libinfo[3]):
|
if not conf.CheckLibWithHeader(libname, headers, lang):
|
||||||
if libinfo[2]:
|
if required:
|
||||||
color_print(1,'Could not find required header or shared library for %s' % libinfo[0])
|
color_print(1, 'Could not find required header or shared library for %s' % libname)
|
||||||
env['MISSING_DEPS'].append(libinfo[0])
|
env['MISSING_DEPS'].append(libname)
|
||||||
else:
|
else:
|
||||||
color_print(4,'Could not find optional header or shared library for %s' % libinfo[0])
|
color_print(4, 'Could not find optional header or shared library for %s' % libname)
|
||||||
env['SKIPPED_DEPS'].append(libinfo[0])
|
env['SKIPPED_DEPS'].append(libname)
|
||||||
|
|
||||||
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
|
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
|
||||||
if not conf.icu_at_least_four_two():
|
if not conf.icu_at_least_four_two():
|
||||||
|
@ -1128,18 +1115,14 @@ if not preconfigured:
|
||||||
|
|
||||||
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
|
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
|
||||||
|
|
||||||
# boost system is used in boost 1.35 and greater
|
|
||||||
env['HAS_BOOST_SYSTEM'] = False
|
|
||||||
boost_lib_version_from_header = conf.GetBoostLibVersion()
|
boost_lib_version_from_header = conf.GetBoostLibVersion()
|
||||||
if boost_lib_version_from_header:
|
if boost_lib_version_from_header:
|
||||||
boost_version_from_header = int(boost_lib_version_from_header.split('_')[1])
|
boost_version_from_header = int(boost_lib_version_from_header.split('_')[1])
|
||||||
if boost_version_from_header >= 35:
|
|
||||||
env['HAS_BOOST_SYSTEM'] = True
|
|
||||||
|
|
||||||
|
|
||||||
# The other required boost headers.
|
# The other required boost headers.
|
||||||
BOOST_LIBSHEADERS = [
|
BOOST_LIBSHEADERS = [
|
||||||
['system', 'boost/system/system_error.hpp', env['HAS_BOOST_SYSTEM']],
|
['system', 'boost/system/system_error.hpp', True],
|
||||||
['filesystem', 'boost/filesystem/operations.hpp', True],
|
['filesystem', 'boost/filesystem/operations.hpp', True],
|
||||||
['regex', 'boost/regex.hpp', True],
|
['regex', 'boost/regex.hpp', True],
|
||||||
['program_options', 'boost/program_options.hpp', False]
|
['program_options', 'boost/program_options.hpp', False]
|
||||||
|
@ -1222,12 +1205,30 @@ if not preconfigured:
|
||||||
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
|
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
|
||||||
env.Replace(**backup)
|
env.Replace(**backup)
|
||||||
env['SKIPPED_DEPS'].append(details['lib'])
|
env['SKIPPED_DEPS'].append(details['lib'])
|
||||||
#if plugin == 'sqlite':
|
if plugin == 'sqlite':
|
||||||
# if not conf.sqlite_has_rtree():
|
sqlite_backup = env.Clone().Dictionary()
|
||||||
# env.Replace(**backup)
|
|
||||||
# if details['lib'] in env['LIBS']:
|
# if statically linking, on linux we likely
|
||||||
# env['LIBS'].remove(details['lib'])
|
# need to link sqlite to pthreads and dl
|
||||||
# env['SKIPPED_DEPS'].append('sqlite_rtree')
|
if env['RUNTIME_LINK'] == 'static':
|
||||||
|
if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('sqlite3'):
|
||||||
|
sqlite_env = env.Clone()
|
||||||
|
try:
|
||||||
|
sqlite_env.ParseConfig('pkg-config --static --libs sqlite3')
|
||||||
|
for lib in sqlite_env['LIBS']:
|
||||||
|
if not lib in env['LIBS']:
|
||||||
|
env["SQLITE_LINKFLAGS"].append(lib)
|
||||||
|
env.Append(LIBS=lib)
|
||||||
|
except OSError,e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not conf.sqlite_has_rtree():
|
||||||
|
env.Replace(**sqlite_backup)
|
||||||
|
if details['lib'] in env['LIBS']:
|
||||||
|
env['LIBS'].remove(details['lib'])
|
||||||
|
env['SKIPPED_DEPS'].append('sqlite_rtree')
|
||||||
|
else:
|
||||||
|
env.Replace(**sqlite_backup)
|
||||||
|
|
||||||
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']):
|
||||||
|
@ -1239,10 +1240,10 @@ if not preconfigured:
|
||||||
env.PrependUnique(CPPPATH = '#', delete_existing=True)
|
env.PrependUnique(CPPPATH = '#', delete_existing=True)
|
||||||
env.PrependUnique(LIBPATH = '#src', delete_existing=True)
|
env.PrependUnique(LIBPATH = '#src', delete_existing=True)
|
||||||
|
|
||||||
#if env['PGSQL2SQLITE']:
|
if env['PGSQL2SQLITE']:
|
||||||
# if not conf.sqlite_has_rtree():
|
if not conf.sqlite_has_rtree():
|
||||||
# env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree')
|
env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree')
|
||||||
# env['PGSQL2SQLITE'] = False
|
env['PGSQL2SQLITE'] = False
|
||||||
|
|
||||||
# Decide which libagg to use
|
# Decide which libagg to use
|
||||||
# if we are using internal agg, then prepend to make sure
|
# if we are using internal agg, then prepend to make sure
|
||||||
|
@ -1300,10 +1301,12 @@ if not preconfigured:
|
||||||
env['HAS_CAIRO'] = False
|
env['HAS_CAIRO'] = False
|
||||||
env['SKIPPED_DEPS'].append('cairomm-version')
|
env['SKIPPED_DEPS'].append('cairomm-version')
|
||||||
else:
|
else:
|
||||||
|
print 'Checking for cairo/cairomm lib and include paths... ',
|
||||||
cmd = 'pkg-config --libs --cflags cairomm-1.0'
|
cmd = 'pkg-config --libs --cflags cairomm-1.0'
|
||||||
if env['RUNTIME_LINK'] == 'static':
|
if env['RUNTIME_LINK'] == 'static':
|
||||||
cmd += ' --static'
|
cmd += ' --static'
|
||||||
cairo_env = env.Clone()
|
cairo_env = env.Clone()
|
||||||
|
try:
|
||||||
cairo_env.ParseConfig(cmd)
|
cairo_env.ParseConfig(cmd)
|
||||||
for lib in cairo_env['LIBS']:
|
for lib in cairo_env['LIBS']:
|
||||||
if not lib in env['LIBS']:
|
if not lib in env['LIBS']:
|
||||||
|
@ -1315,6 +1318,12 @@ if not preconfigured:
|
||||||
if not inc in env['CPPPATH']:
|
if not inc in env['CPPPATH']:
|
||||||
env["CAIROMM_CPPPATHS"].append(inc)
|
env["CAIROMM_CPPPATHS"].append(inc)
|
||||||
env['HAS_CAIRO'] = True
|
env['HAS_CAIRO'] = True
|
||||||
|
print 'yes'
|
||||||
|
except OSError,e:
|
||||||
|
color_print(1,'no')
|
||||||
|
env['SKIPPED_DEPS'].append('cairo')
|
||||||
|
env['SKIPPED_DEPS'].append('cairomm')
|
||||||
|
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')
|
||||||
|
@ -1390,13 +1399,6 @@ if not preconfigured:
|
||||||
else :
|
else :
|
||||||
common_cxx_flags = '-D%s ' % env['PLATFORM'].upper()
|
common_cxx_flags = '-D%s ' % env['PLATFORM'].upper()
|
||||||
|
|
||||||
svn_version = call('svnversion')
|
|
||||||
if not svn_version == 'exported':
|
|
||||||
pattern = r'(\d+)(.*)'
|
|
||||||
try:
|
|
||||||
env['SVN_REVISION'] = re.match(pattern,svn_version).groups()[0]
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
# Mac OSX (Darwin) special settings
|
# Mac OSX (Darwin) special settings
|
||||||
if env['PLATFORM'] == 'Darwin':
|
if env['PLATFORM'] == 'Darwin':
|
||||||
pthread = ''
|
pthread = ''
|
||||||
|
@ -1414,6 +1416,7 @@ if not preconfigured:
|
||||||
debug_flags = '-g -DDEBUG -DMAPNIK_DEBUG'
|
debug_flags = '-g -DDEBUG -DMAPNIK_DEBUG'
|
||||||
ndebug_flags = '-DNDEBUG'
|
ndebug_flags = '-DNDEBUG'
|
||||||
|
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -1428,7 +1431,9 @@ if not preconfigured:
|
||||||
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 %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']:
|
||||||
|
env.Append(CXXFLAGS = '-fcatch-undefined-behavior') #-ftrapv -fwrapv
|
||||||
|
|
||||||
if 'python' in env['BINDINGS']:
|
if 'python' in env['BINDINGS']:
|
||||||
if not os.access(env['PYTHON'], os.X_OK):
|
if not os.access(env['PYTHON'], os.X_OK):
|
||||||
|
@ -1496,7 +1501,7 @@ if not preconfigured:
|
||||||
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)
|
||||||
env['MISSING_DEPS'].append('python %s development headers' % env['PYTHON_VERSION'])
|
Exit(1)
|
||||||
else:
|
else:
|
||||||
env.Replace(**backup)
|
env.Replace(**backup)
|
||||||
|
|
||||||
|
@ -1504,6 +1509,15 @@ if not preconfigured:
|
||||||
color_print(1,"Python version 2.2 or greater required")
|
color_print(1,"Python version 2.2 or greater required")
|
||||||
Exit(1)
|
Exit(1)
|
||||||
|
|
||||||
|
if env['BOOST_PYTHON_LIB']:
|
||||||
|
env.Append(LIBS='python%s' % env['PYTHON_VERSION'])
|
||||||
|
if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB']], header='boost/python/detail/config.hpp', language='C++'):
|
||||||
|
color_print(1, 'Could not find library %s for boost python' % env['BOOST_PYTHON_LIB'])
|
||||||
|
env.Replace(**backup)
|
||||||
|
Exit(1)
|
||||||
|
else:
|
||||||
|
env.Replace(**backup)
|
||||||
|
|
||||||
color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION'])
|
color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION'])
|
||||||
color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX']))
|
color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX']))
|
||||||
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION']))
|
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION']))
|
||||||
|
@ -1543,7 +1557,7 @@ if not preconfigured:
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
if 'configure' in command_line_args:
|
if 'configure' in command_line_args:
|
||||||
color_print(4,'\n*Configure complete*\nNow run "python scons/scons.py" to build or "python scons/scons.py install" to install')
|
color_print(4,'\nConfigure completed: run `make` to build or `make install`')
|
||||||
if not HELP_REQUESTED:
|
if not HELP_REQUESTED:
|
||||||
Exit(0)
|
Exit(0)
|
||||||
|
|
||||||
|
@ -1562,17 +1576,57 @@ if not HELP_REQUESTED:
|
||||||
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_INSERT']:
|
if env['PATH']:
|
||||||
env['ENV']['PATH'] = os.path.realpath(env['PATH_INSERT']) + ':' + env['ENV']['PATH']
|
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
|
||||||
|
|
||||||
|
if env['PATH_REMOVE']:
|
||||||
|
p = env['PATH_REMOVE']
|
||||||
|
if p in env['ENV']['PATH']:
|
||||||
|
env['ENV']['PATH'].replace(p,'')
|
||||||
|
def rm_path(set):
|
||||||
|
for i in env[set]:
|
||||||
|
if p in i:
|
||||||
|
env[set].remove(i)
|
||||||
|
rm_path('LIBPATH')
|
||||||
|
rm_path('CPPPATH')
|
||||||
|
rm_path('CXXFLAGS')
|
||||||
|
rm_path('CAIROMM_LIBPATHS')
|
||||||
|
rm_path('CAIROMM_CPPPATHS')
|
||||||
|
|
||||||
|
if env['PATH_REPLACE']:
|
||||||
|
searches,replace = env['PATH_REPLACE'].split(':')
|
||||||
|
for search in searches.split(','):
|
||||||
|
if search in env['ENV']['PATH']:
|
||||||
|
env['ENV']['PATH'] = os.path.abspath(env['ENV']['PATH'].replace(search,replace))
|
||||||
|
def replace_path(set,s,r):
|
||||||
|
idx = 0
|
||||||
|
for i in env[set]:
|
||||||
|
if s in i:
|
||||||
|
env[set][idx] = os.path.abspath(env[set][idx].replace(s,r))
|
||||||
|
idx +=1
|
||||||
|
replace_path('LIBPATH',search,replace)
|
||||||
|
replace_path('CPPPATH',search,replace)
|
||||||
|
replace_path('CXXFLAGS',search,replace)
|
||||||
|
replace_path('CAIROMM_LIBPATHS',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()
|
||||||
|
# for this to work you need:
|
||||||
|
# if __GNUC__ >= 4
|
||||||
|
# define MAPNIK_EXP __attribute__ ((visibility ("default")))
|
||||||
|
#plugin_base.Append(CXXFLAGS='-fvisibility=hidden')
|
||||||
|
#plugin_base.Append(CXXFLAGS='-fvisibility-inlines-hidden')
|
||||||
|
|
||||||
|
Export('plugin_base')
|
||||||
|
|
||||||
# clear the '_CPPDEFFLAGS' variable
|
# clear the '_CPPDEFFLAGS' variable
|
||||||
# for unknown reasons this variable puts -DNone
|
# for unknown reasons this variable puts -DNone
|
||||||
# in the g++ args prompting unnecessary recompiles
|
# in the g++ args prompting unnecessary recompiles
|
||||||
env['_CPPDEFFLAGS'] = None
|
env['_CPPDEFFLAGS'] = None
|
||||||
|
plugin_base['_CPPDEFFLAGS'] = None
|
||||||
|
|
||||||
|
|
||||||
if env['FAST']:
|
if env['FAST']:
|
||||||
|
@ -1658,7 +1712,7 @@ if not HELP_REQUESTED:
|
||||||
# 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 mapnik2 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
|
||||||
|
|
|
@ -40,21 +40,15 @@ def is_py3():
|
||||||
|
|
||||||
|
|
||||||
prefix = env['PREFIX']
|
prefix = env['PREFIX']
|
||||||
target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2')
|
target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik')
|
||||||
|
|
||||||
libraries = ['mapnik2','png']
|
libraries = ['mapnik','png']
|
||||||
|
|
||||||
if env['JPEG']:
|
if env['JPEG']:
|
||||||
libraries.append('jpeg')
|
libraries.append('jpeg')
|
||||||
|
|
||||||
if env['BOOST_PYTHON_LIB']:
|
if env['BOOST_PYTHON_LIB']:
|
||||||
if os.path.sep in env['BOOST_PYTHON_LIB']:
|
libraries.append(env['BOOST_PYTHON_LIB'])
|
||||||
pylib_dir = os.path.dirname(env['BOOST_PYTHON_LIB'])
|
|
||||||
env.Prepend(LIBPATH = pylib_dir)
|
|
||||||
pylib_name = os.path.splitext(os.path.basename(env['BOOST_PYTHON_LIB']))[0].replace('lib','',1)
|
|
||||||
libraries.append(pylib_name)
|
|
||||||
else:
|
|
||||||
libraries.append(env['BOOST_PYTHON_LIB'].replace('lib','',1))
|
|
||||||
else:
|
else:
|
||||||
if is_py3():
|
if is_py3():
|
||||||
libraries.append('boost_python3%s' % env['BOOST_APPEND'])
|
libraries.append('boost_python3%s' % env['BOOST_APPEND'])
|
||||||
|
@ -157,6 +151,10 @@ if 'install' in COMMAND_LINE_TARGETS:
|
||||||
init_files.remove('mapnik/paths.py')
|
init_files.remove('mapnik/paths.py')
|
||||||
init_module = env.Install(target_path, init_files)
|
init_module = env.Install(target_path, init_files)
|
||||||
env.Alias(target='install', source=init_module)
|
env.Alias(target='install', source=init_module)
|
||||||
|
# install mapnik2 module which redirects to mapnik and issues DeprecatedWarning
|
||||||
|
path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2')
|
||||||
|
init_mapnik2 = env.Install(path, 'mapnik2/__init__.py')
|
||||||
|
env.Alias(target='install', source=init_mapnik2)
|
||||||
|
|
||||||
# fix perms and install the custom generated 'paths.py'
|
# fix perms and install the custom generated 'paths.py'
|
||||||
if 'install' in COMMAND_LINE_TARGETS:
|
if 'install' in COMMAND_LINE_TARGETS:
|
||||||
|
@ -170,17 +168,10 @@ if 'install' in COMMAND_LINE_TARGETS:
|
||||||
Chmod("$TARGET", 0644),
|
Chmod("$TARGET", 0644),
|
||||||
])
|
])
|
||||||
|
|
||||||
# install the ogcserver module code
|
|
||||||
if 'install' in COMMAND_LINE_TARGETS:
|
|
||||||
ogcserver_files = glob.glob('mapnik/ogcserver/*.py')
|
|
||||||
ogcserver_module = env.Install(target_path + '/ogcserver', ogcserver_files)
|
|
||||||
env.Alias(target='install', source=ogcserver_module)
|
|
||||||
|
|
||||||
|
|
||||||
# install the shared object beside the module directory
|
# install the shared object beside the module directory
|
||||||
sources = glob.glob('*.cpp')
|
sources = glob.glob('*.cpp')
|
||||||
|
|
||||||
|
|
||||||
py_env = env.Clone()
|
py_env = env.Clone()
|
||||||
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
|
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
|
||||||
|
|
||||||
|
@ -194,13 +185,7 @@ if env['HAS_PYCAIRO']:
|
||||||
py_env.ParseConfig('pkg-config --cflags pycairo')
|
py_env.ParseConfig('pkg-config --cflags pycairo')
|
||||||
py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO')
|
py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO')
|
||||||
|
|
||||||
if env['SVN_REVISION']:
|
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
|
||||||
sources.remove('mapnik_python.cpp')
|
|
||||||
env2 = py_env.Clone()
|
|
||||||
env2.Append(CXXFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION'])
|
|
||||||
sources.insert(0,env2.SharedObject('mapnik_python.cpp'))
|
|
||||||
|
|
||||||
_mapnik = py_env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
|
|
||||||
|
|
||||||
Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from _mapnik2 import *
|
from _mapnik import *
|
||||||
from paths import inputpluginspath, fontscollectionpath
|
from paths import inputpluginspath, fontscollectionpath
|
||||||
|
|
||||||
import printing
|
import printing
|
||||||
|
@ -410,6 +410,13 @@ def Raster(**keywords):
|
||||||
|
|
||||||
Optional keyword arguments:
|
Optional keyword arguments:
|
||||||
base -- path prefix (default None)
|
base -- path prefix (default None)
|
||||||
|
multi -- whether the image is in tiles on disk (default False)
|
||||||
|
|
||||||
|
Multi-tiled keyword arguments:
|
||||||
|
x_width -- virtual image number of tiles in X direction (required)
|
||||||
|
y_width -- virtual image number of tiles in Y direction (required)
|
||||||
|
tile_size -- if an image is in tiles, how large are the tiles (default 256)
|
||||||
|
tile_stride -- if an image is in tiles, what's the increment between rows/cols (default 1)
|
||||||
|
|
||||||
>>> from mapnik import Raster, Layer
|
>>> from mapnik import Raster, Layer
|
||||||
>>> raster = Raster(base='/home/mapnik/data',file='elevation.tif',lox=-122.8,loy=48.5,hix=-122.7,hiy=48.6)
|
>>> raster = Raster(base='/home/mapnik/data',file='elevation.tif',lox=-122.8,loy=48.5,hix=-122.7,hiy=48.6)
|
||||||
|
@ -478,10 +485,11 @@ def Ogr(**keywords):
|
||||||
|
|
||||||
Required keyword arguments:
|
Required keyword arguments:
|
||||||
file -- path to OGR supported dataset
|
file -- path to OGR supported dataset
|
||||||
layer -- name of layer to use within datasource (optional if layer_by_index is used)
|
layer -- name of layer to use within datasource (optional if layer_by_index or layer_by_sql is used)
|
||||||
|
|
||||||
Optional keyword arguments:
|
Optional keyword arguments:
|
||||||
layer_by_index -- choose layer by index number instead of by layer name.
|
layer_by_index -- choose layer by index number instead of by layer name or sql.
|
||||||
|
layer_by_sql -- choose layer by sql query number instead of by layer name or index.
|
||||||
base -- path prefix (default None)
|
base -- path prefix (default None)
|
||||||
encoding -- file encoding (default 'utf-8')
|
encoding -- file encoding (default 'utf-8')
|
||||||
multiple_geometries -- boolean, direct the Mapnik wkb reader to interpret as multigeometries (default False)
|
multiple_geometries -- boolean, direct the Mapnik wkb reader to interpret as multigeometries (default False)
|
||||||
|
@ -710,7 +718,6 @@ __all__ = [
|
||||||
# version and environment
|
# version and environment
|
||||||
'mapnik_version_string',
|
'mapnik_version_string',
|
||||||
'mapnik_version',
|
'mapnik_version',
|
||||||
'mapnik_svn_revision',
|
|
||||||
'has_cairo',
|
'has_cairo',
|
||||||
'has_pycairo',
|
'has_pycairo',
|
||||||
# factory methods
|
# factory methods
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""Interface for registering map styles and layers for availability in WMS Requests."""
|
|
||||||
|
|
||||||
from common import Version, copy_style, copy_layer
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from wms111 import ServiceHandler as ServiceHandler111
|
|
||||||
from wms130 import ServiceHandler as ServiceHandler130
|
|
||||||
from mapnik2 import Style, Map, load_map
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def ServiceHandlerFactory(conf, mapfactory, onlineresource, version):
|
|
||||||
|
|
||||||
if not version:
|
|
||||||
version = Version('1.3.0')
|
|
||||||
else:
|
|
||||||
version = Version(version)
|
|
||||||
if version >= '1.3.0':
|
|
||||||
return ServiceHandler130(conf, mapfactory, onlineresource)
|
|
||||||
else:
|
|
||||||
return ServiceHandler111(conf, mapfactory, onlineresource)
|
|
||||||
|
|
||||||
class BaseWMSFactory:
|
|
||||||
def __init__(self):
|
|
||||||
self.layers = {}
|
|
||||||
self.ordered_layers = []
|
|
||||||
self.styles = {}
|
|
||||||
self.aggregatestyles = {}
|
|
||||||
|
|
||||||
def loadXML(self, xmlfile, strict=False):
|
|
||||||
tmp_map = Map(0,0)
|
|
||||||
load_map (tmp_map, xmlfile, strict)
|
|
||||||
for lyr in tmp_map.layers:
|
|
||||||
style_count = len(lyr.styles)
|
|
||||||
if style_count == 0:
|
|
||||||
raise ServerConfigurationError("Cannot register Layer '%s' without a style" % lyr.name)
|
|
||||||
elif style_count == 1:
|
|
||||||
style_obj = tmp_map.find_style(lyr.styles[0])
|
|
||||||
style_obj = copy_style(style_obj)
|
|
||||||
style_name = lyr.styles[0]
|
|
||||||
if style_name not in self.aggregatestyles.keys() and style_name not in self.styles.keys():
|
|
||||||
self.register_style(style_name, style_obj)
|
|
||||||
self.register_layer(copy_layer(lyr), style_name, extrastyles=(style_name,))
|
|
||||||
elif style_count > 1:
|
|
||||||
for style_name in lyr.styles:
|
|
||||||
style_obj = tmp_map.find_style(style_name)
|
|
||||||
style_obj = copy_style(style_obj)
|
|
||||||
if style_name not in self.aggregatestyles.keys() and style_name not in self.styles.keys():
|
|
||||||
self.register_style(style_name, style_obj)
|
|
||||||
aggregates = tuple([sty for sty in lyr.styles])
|
|
||||||
aggregates_name = '%s_aggregates' % lyr.name
|
|
||||||
self.register_aggregate_style(aggregates_name,aggregates)
|
|
||||||
self.register_layer(copy_layer(lyr), aggregates_name, extrastyles=aggregates)
|
|
||||||
|
|
||||||
def register_layer(self, layer, defaultstyle, extrastyles=()):
|
|
||||||
layername = layer.name
|
|
||||||
if not layername:
|
|
||||||
raise ServerConfigurationError('Attempted to register an unnamed layer.')
|
|
||||||
if not re.match('^\+init=epsg:\d+$', layer.srs) and not re.match('^\+proj=.*$', layer.srs):
|
|
||||||
raise ServerConfigurationError('Attempted to register a layer without an epsg projection defined.')
|
|
||||||
if defaultstyle not in self.styles.keys() + self.aggregatestyles.keys():
|
|
||||||
raise ServerConfigurationError('Attempted to register a layer with an non-existent default style.')
|
|
||||||
layer.wmsdefaultstyle = defaultstyle
|
|
||||||
if isinstance(extrastyles, tuple):
|
|
||||||
for stylename in extrastyles:
|
|
||||||
if type(stylename) == type(''):
|
|
||||||
if stylename not in self.styles.keys() + self.aggregatestyles.keys():
|
|
||||||
raise ServerConfigurationError('Attempted to register a layer with an non-existent extra style.')
|
|
||||||
else:
|
|
||||||
ServerConfigurationError('Attempted to register a layer with an invalid extra style name.')
|
|
||||||
layer.wmsextrastyles = extrastyles
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('Layer "%s" was passed an invalid list of extra styles. List must be a tuple of strings.' % layername)
|
|
||||||
self.ordered_layers.append(layer)
|
|
||||||
self.layers[layername] = layer
|
|
||||||
|
|
||||||
def register_style(self, name, style):
|
|
||||||
if not name:
|
|
||||||
raise ServerConfigurationError('Attempted to register a style without providing a name.')
|
|
||||||
if name in self.aggregatestyles.keys() or name in self.styles.keys():
|
|
||||||
raise ServerConfigurationError("Attempted to register a style with a name already in use: '%s'" % name)
|
|
||||||
if not isinstance(style, Style):
|
|
||||||
raise ServerConfigurationError('Bad style object passed to register_style() for style "%s".' % name)
|
|
||||||
self.styles[name] = style
|
|
||||||
|
|
||||||
def register_aggregate_style(self, name, stylenames):
|
|
||||||
if not name:
|
|
||||||
raise ServerConfigurationError('Attempted to register an aggregate style without providing a name.')
|
|
||||||
if name in self.aggregatestyles.keys() or name in self.styles.keys():
|
|
||||||
raise ServerConfigurationError('Attempted to register an aggregate style with a name already in use.')
|
|
||||||
self.aggregatestyles[name] = []
|
|
||||||
for stylename in stylenames:
|
|
||||||
if stylename not in self.styles.keys():
|
|
||||||
raise ServerConfigurationError('Attempted to register an aggregate style containing a style that does not exist.')
|
|
||||||
self.aggregatestyles[name].append(stylename)
|
|
||||||
|
|
||||||
def finalize(self):
|
|
||||||
if len(self.layers) == 0:
|
|
||||||
raise ServerConfigurationError('No layers defined!')
|
|
||||||
if len(self.styles) == 0:
|
|
||||||
raise ServerConfigurationError('No styles defined!')
|
|
||||||
for layer in self.layers.values():
|
|
||||||
for style in list(layer.styles) + list(layer.wmsextrastyles):
|
|
||||||
if style not in self.styles.keys() + self.aggregatestyles.keys():
|
|
||||||
raise ServerConfigurationError('Layer "%s" refers to undefined style "%s".' % (layer.name, style))
|
|
|
@ -1,28 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""Mapnik OGC WMS Server."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
warnings.warn("ogcserver module development has moved to https://github.com/mapnik/OGCServer.\n This code will function fine with this version, but will be removed in Mapnik 2.1.0. Disable this warning by editing this file: %s" % os.path.realpath(__file__), DeprecationWarning, 2)
|
|
||||||
|
|
|
@ -1,116 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""CGI/FastCGI handler for Mapnik OGC WMS Server.
|
|
||||||
|
|
||||||
Requires 'jon' module.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from os import environ
|
|
||||||
from tempfile import gettempdir
|
|
||||||
environ['PYTHON_EGG_CACHE'] = gettempdir()
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from jon import cgi
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from wms111 import ExceptionHandler as ExceptionHandler111
|
|
||||||
from wms130 import ExceptionHandler as ExceptionHandler130
|
|
||||||
from configparser import SafeConfigParser
|
|
||||||
from common import Version
|
|
||||||
|
|
||||||
class Handler(cgi.DebugHandler):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
conf = SafeConfigParser()
|
|
||||||
conf.readfp(open(self.configpath))
|
|
||||||
self.conf = conf
|
|
||||||
if not conf.has_option_with_value('server', 'module'):
|
|
||||||
raise ServerConfigurationError('The factory module is not defined in the configuration file.')
|
|
||||||
try:
|
|
||||||
mapfactorymodule = __import__(conf.get('server', 'module'))
|
|
||||||
except ImportError:
|
|
||||||
raise ServerConfigurationError('The factory module could not be loaded.')
|
|
||||||
if hasattr(mapfactorymodule, 'WMSFactory'):
|
|
||||||
self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
|
|
||||||
if conf.has_option('server', 'debug'):
|
|
||||||
self.debug = int(conf.get('server', 'debug'))
|
|
||||||
else:
|
|
||||||
self.debug = 0
|
|
||||||
|
|
||||||
def process(self, req):
|
|
||||||
reqparams = lowerparams(req.params)
|
|
||||||
onlineresource = 'http://%s:%s%s?' % (req.environ['SERVER_NAME'], req.environ['SERVER_PORT'], req.environ['SCRIPT_NAME'])
|
|
||||||
if not reqparams.has_key('request'):
|
|
||||||
raise OGCException('Missing request parameter.')
|
|
||||||
request = reqparams['request']
|
|
||||||
del reqparams['request']
|
|
||||||
if request == 'GetCapabilities' and not reqparams.has_key('service'):
|
|
||||||
raise OGCException('Missing service parameter.')
|
|
||||||
if request in ['GetMap', 'GetFeatureInfo']:
|
|
||||||
service = 'WMS'
|
|
||||||
else:
|
|
||||||
service = reqparams['service']
|
|
||||||
if reqparams.has_key('service'):
|
|
||||||
del reqparams['service']
|
|
||||||
try:
|
|
||||||
mapnikmodule = __import__('mapnik2.ogcserver.' + service)
|
|
||||||
except:
|
|
||||||
raise OGCException('Unsupported service "%s".' % service)
|
|
||||||
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory
|
|
||||||
servicehandler = ServiceHandlerFactory(self.conf, self.mapfactory, onlineresource, reqparams.get('version', None))
|
|
||||||
if reqparams.has_key('version'):
|
|
||||||
del reqparams['version']
|
|
||||||
if request not in servicehandler.SERVICE_PARAMS.keys():
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
ogcparams = servicehandler.processParameters(request, reqparams)
|
|
||||||
try:
|
|
||||||
requesthandler = getattr(servicehandler, request)
|
|
||||||
except:
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
response = requesthandler(ogcparams)
|
|
||||||
req.set_header('Content-Type', response.content_type)
|
|
||||||
req.set_header('Content-Length', str(len(response.content)))
|
|
||||||
req.write(response.content)
|
|
||||||
|
|
||||||
def traceback(self, req):
|
|
||||||
reqparams = lowerparams(req.params)
|
|
||||||
version = reqparams.get('version', None)
|
|
||||||
if not version:
|
|
||||||
version = Version('1.3.0')
|
|
||||||
else:
|
|
||||||
version = Version(version)
|
|
||||||
if version >= '1.3.0':
|
|
||||||
eh = ExceptionHandler130(self.debug)
|
|
||||||
else:
|
|
||||||
eh = ExceptionHandler111(self.debug)
|
|
||||||
response = eh.getresponse(reqparams)
|
|
||||||
req.set_header('Content-Type', response.content_type)
|
|
||||||
req.set_header('Content-Length', str(len(response.content)))
|
|
||||||
req.write(response.content)
|
|
||||||
|
|
||||||
def lowerparams(params):
|
|
||||||
reqparams = {}
|
|
||||||
for key, value in params.items():
|
|
||||||
reqparams[key.lower()] = value
|
|
||||||
return reqparams
|
|
|
@ -1,539 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""Core OGCServer classes and functions."""
|
|
||||||
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from mapnik2 import Map, Color, Box2d, render, Image, Layer, Style, Projection as MapnikProjection, Coord
|
|
||||||
from PIL.Image import new
|
|
||||||
from PIL.ImageDraw import Draw
|
|
||||||
from StringIO import StringIO
|
|
||||||
from copy import deepcopy
|
|
||||||
from traceback import format_exception, format_exception_only
|
|
||||||
from sys import exc_info
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
|
||||||
from lxml import etree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import xml.etree.ElementTree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import elementtree.ElementTree as ElementTree
|
|
||||||
|
|
||||||
# from elementtree import ElementTree
|
|
||||||
# ElementTree._namespace_map.update({'http://www.opengis.net/wms': 'wms',
|
|
||||||
# 'http://www.opengis.net/ogc': 'ogc',
|
|
||||||
# 'http://www.w3.org/1999/xlink': 'xlink',
|
|
||||||
# 'http://www.w3.org/2001/XMLSchema-instance': 'xsi'
|
|
||||||
# })
|
|
||||||
|
|
||||||
PIL_TYPE_MAPPING = {'image/jpeg': 'jpeg', 'image/png': 'png'}
|
|
||||||
|
|
||||||
class ParameterDefinition:
|
|
||||||
|
|
||||||
def __init__(self, mandatory, cast, default=None, allowedvalues=None, fallback=False):
|
|
||||||
""" An OGC request parameter definition. Used to describe a
|
|
||||||
parameter's characteristics.
|
|
||||||
|
|
||||||
@param mandatory: Is this parameter required by the request?
|
|
||||||
@type mandatory: Boolean.
|
|
||||||
|
|
||||||
@param default: Default value to use if one is not provided
|
|
||||||
and the parameter is optional.
|
|
||||||
@type default: None or any valid value.
|
|
||||||
|
|
||||||
@param allowedvalues: A list of allowed values for the parameter.
|
|
||||||
If a value is provided that is not in this
|
|
||||||
list, an error is raised.
|
|
||||||
@type allowedvalues: A python tuple of values.
|
|
||||||
|
|
||||||
@param fallback: Whether the value of the parameter should fall
|
|
||||||
back to the default should an illegal value be
|
|
||||||
provided.
|
|
||||||
@type fallback: Boolean.
|
|
||||||
|
|
||||||
@return: A L{ParameterDefinition} instance.
|
|
||||||
"""
|
|
||||||
if mandatory not in [True, False]:
|
|
||||||
raise ServerConfigurationError("Bad value for 'mandatory' parameter, must be True or False.")
|
|
||||||
self.mandatory = mandatory
|
|
||||||
if not callable(cast):
|
|
||||||
raise ServerConfigurationError('Cast parameter definition must be callable.')
|
|
||||||
self.cast = cast
|
|
||||||
self.default = default
|
|
||||||
if allowedvalues and type(allowedvalues) != type(()):
|
|
||||||
raise ServerConfigurationError("Bad value for 'allowedvalues' parameter, must be a tuple.")
|
|
||||||
self.allowedvalues = allowedvalues
|
|
||||||
if fallback not in [True, False]:
|
|
||||||
raise ServerConfigurationError("Bad value for 'fallback' parameter, must be True or False.")
|
|
||||||
self.fallback = fallback
|
|
||||||
|
|
||||||
class BaseServiceHandler:
|
|
||||||
|
|
||||||
CONF_CONTACT_PERSON_PRIMARY = [
|
|
||||||
['contactperson', 'ContactPerson', str],
|
|
||||||
['contactorganization', 'ContactOrganization', str]
|
|
||||||
]
|
|
||||||
|
|
||||||
CONF_CONTACT_ADDRESS = [
|
|
||||||
['addresstype', 'AddressType', str],
|
|
||||||
['address', 'Address', str],
|
|
||||||
['city', 'City', str],
|
|
||||||
['stateorprovince', 'StateOrProvince', str],
|
|
||||||
['postcode', 'PostCode', str],
|
|
||||||
['country', 'Country', str]
|
|
||||||
]
|
|
||||||
|
|
||||||
CONF_CONTACT = [
|
|
||||||
['contactposition', 'ContactPosition', str],
|
|
||||||
['contactvoicetelephone', 'ContactVoiceTelephone', str],
|
|
||||||
['contactelectronicmailaddress', 'ContactElectronicMailAddress', str]
|
|
||||||
]
|
|
||||||
|
|
||||||
def processParameters(self, requestname, params):
|
|
||||||
finalparams = {}
|
|
||||||
for paramname, paramdef in self.SERVICE_PARAMS[requestname].items():
|
|
||||||
if paramname not in params.keys() and paramdef.mandatory:
|
|
||||||
raise OGCException('Mandatory parameter "%s" missing from request.' % paramname)
|
|
||||||
elif paramname in params.keys():
|
|
||||||
try:
|
|
||||||
params[paramname] = paramdef.cast(params[paramname])
|
|
||||||
except OGCException:
|
|
||||||
raise
|
|
||||||
except:
|
|
||||||
raise OGCException('Invalid value "%s" for parameter "%s".' % (params[paramname], paramname))
|
|
||||||
if paramdef.allowedvalues and params[paramname] not in paramdef.allowedvalues:
|
|
||||||
if not paramdef.fallback:
|
|
||||||
raise OGCException('Parameter "%s" has an illegal value.' % paramname)
|
|
||||||
else:
|
|
||||||
finalparams[paramname] = paramdef.default
|
|
||||||
else:
|
|
||||||
finalparams[paramname] = params[paramname]
|
|
||||||
elif not paramdef.mandatory and paramdef.default:
|
|
||||||
finalparams[paramname] = paramdef.default
|
|
||||||
return finalparams
|
|
||||||
|
|
||||||
def processServiceCapabilities(self, capetree):
|
|
||||||
if len(self.conf.items('service')) > 0:
|
|
||||||
servicee = capetree.find('{http://www.opengis.net/wms}Service')
|
|
||||||
for item in self.CONF_SERVICE:
|
|
||||||
if self.conf.has_option_with_value('service', item[0]):
|
|
||||||
value = self.conf.get('service', item[0]).strip()
|
|
||||||
try:
|
|
||||||
item[2](value)
|
|
||||||
except:
|
|
||||||
raise ServerConfigurationError('Configuration parameter [%s]->%s has an invalid value: %s.' % ('service', item[0], value))
|
|
||||||
if item[0] == 'onlineresource':
|
|
||||||
element = ElementTree.Element('%s' % item[1])
|
|
||||||
servicee.append(element)
|
|
||||||
element.set('{http://www.w3.org/1999/xlink}href', value)
|
|
||||||
element.set('{http://www.w3.org/1999/xlink}type', 'simple')
|
|
||||||
elif item[0] == 'keywordlist':
|
|
||||||
element = ElementTree.Element('%s' % item[1])
|
|
||||||
servicee.append(element)
|
|
||||||
keywords = value.split(',')
|
|
||||||
keywords = map(str.strip, keywords)
|
|
||||||
for keyword in keywords:
|
|
||||||
kelement = ElementTree.Element('Keyword')
|
|
||||||
kelement.text = keyword
|
|
||||||
element.append(kelement)
|
|
||||||
else:
|
|
||||||
element = ElementTree.Element('%s' % item[1])
|
|
||||||
element.text = value
|
|
||||||
servicee.append(element)
|
|
||||||
if len(self.conf.items_with_value('contact')) > 0:
|
|
||||||
element = ElementTree.Element('ContactInformation')
|
|
||||||
servicee.append(element)
|
|
||||||
for item in self.CONF_CONTACT:
|
|
||||||
if self.conf.has_option_with_value('contact', item[0]):
|
|
||||||
value = self.conf.get('contact', item[0]).strip()
|
|
||||||
try:
|
|
||||||
item[2](value)
|
|
||||||
except:
|
|
||||||
raise ServerConfigurationError('Configuration parameter [%s]->%s has an invalid value: %s.' % ('service', item[0], value))
|
|
||||||
celement = ElementTree.Element('%s' % item[1])
|
|
||||||
celement.text = value
|
|
||||||
element.append(celement)
|
|
||||||
for item in self.CONF_CONTACT_PERSON_PRIMARY + self.CONF_CONTACT_ADDRESS:
|
|
||||||
if item in self.CONF_CONTACT_PERSON_PRIMARY:
|
|
||||||
tagname = 'ContactPersonPrimary'
|
|
||||||
else:
|
|
||||||
tagname = 'ContactAddress'
|
|
||||||
if self.conf.has_option_with_value('contact', item[0]):
|
|
||||||
if element.find(tagname) == None:
|
|
||||||
subelement = ElementTree.Element(tagname)
|
|
||||||
element.append(subelement)
|
|
||||||
value = self.conf.get('contact', item[0]).strip()
|
|
||||||
try:
|
|
||||||
item[2](value)
|
|
||||||
except:
|
|
||||||
raise ServerConfigurationError('Configuration parameter [%s]->%s has an invalid value: %s.' % ('service', item[0], value))
|
|
||||||
celement = ElementTree.Element('%s' % item[1])
|
|
||||||
celement.text = value
|
|
||||||
subelement.append(celement)
|
|
||||||
|
|
||||||
class Response:
|
|
||||||
|
|
||||||
def __init__(self, content_type, content):
|
|
||||||
self.content_type = content_type
|
|
||||||
self.content = content
|
|
||||||
|
|
||||||
class Version:
|
|
||||||
|
|
||||||
def __init__(self, version):
|
|
||||||
version = version.split('.')
|
|
||||||
if len(version) != 3:
|
|
||||||
raise OGCException('Badly formatted version number.')
|
|
||||||
try:
|
|
||||||
version = map(int, version)
|
|
||||||
except:
|
|
||||||
raise OGCException('Badly formatted version number.')
|
|
||||||
self.version = version
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '%s.%s.%s' % (self.version[0], self.version[1], self.version[2])
|
|
||||||
|
|
||||||
def __cmp__(self, other):
|
|
||||||
if isinstance(other, str):
|
|
||||||
other = Version(other)
|
|
||||||
if self.version[0] < other.version[0]:
|
|
||||||
return -1
|
|
||||||
elif self.version[0] > other.version[0]:
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
if self.version[1] < other.version[1]:
|
|
||||||
return -1
|
|
||||||
elif self.version[1] > other.version[1]:
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
if self.version[2] < other.version[2]:
|
|
||||||
return -1
|
|
||||||
elif self.version[2] > other.version[2]:
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
class ListFactory:
|
|
||||||
|
|
||||||
def __init__(self, cast):
|
|
||||||
self.cast = cast
|
|
||||||
|
|
||||||
def __call__(self, string):
|
|
||||||
seq = string.split(',')
|
|
||||||
return map(self.cast, seq)
|
|
||||||
|
|
||||||
def ColorFactory(colorstring):
|
|
||||||
if re.match('^0x[a-fA-F0-9]{6}$', colorstring):
|
|
||||||
return Color(eval('0x' + colorstring[2:4]), eval('0x' + colorstring[4:6]), eval('0x' + colorstring[6:8]))
|
|
||||||
else:
|
|
||||||
raise OGCException('Invalid color value. Must be of format "0xFFFFFF".')
|
|
||||||
|
|
||||||
class CRS:
|
|
||||||
|
|
||||||
def __init__(self, namespace, code):
|
|
||||||
self.namespace = namespace.lower()
|
|
||||||
self.code = int(code)
|
|
||||||
self.proj = None
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '%s:%s' % (self.namespace, self.code)
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
if str(other) == str(self):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def inverse(self, x, y):
|
|
||||||
if not self.proj:
|
|
||||||
self.proj = Projection('+init=%s:%s' % (self.namespace, self.code))
|
|
||||||
return self.proj.inverse(Coord(x, y))
|
|
||||||
|
|
||||||
def forward(self, x, y):
|
|
||||||
if not self.proj:
|
|
||||||
self.proj = Projection('+init=%s:%s' % (self.namespace, self.code))
|
|
||||||
return self.proj.forward(Coord(x, y))
|
|
||||||
|
|
||||||
class CRSFactory:
|
|
||||||
|
|
||||||
def __init__(self, allowednamespaces):
|
|
||||||
self.allowednamespaces = allowednamespaces
|
|
||||||
|
|
||||||
def __call__(self, crsstring):
|
|
||||||
if not re.match('^[A-Z]{3,5}:\d+$', crsstring):
|
|
||||||
raise OGCException('Invalid format for the CRS parameter: %s' % crsstring, 'InvalidCRS')
|
|
||||||
crsparts = crsstring.split(':')
|
|
||||||
if crsparts[0] in self.allowednamespaces:
|
|
||||||
return CRS(crsparts[0], crsparts[1])
|
|
||||||
else:
|
|
||||||
raise OGCException('Invalid CRS Namespace: %s' % crsparts[0], 'InvalidCRS')
|
|
||||||
|
|
||||||
def copy_layer(obj):
|
|
||||||
lyr = Layer(obj.name)
|
|
||||||
lyr.abstract = obj.abstract
|
|
||||||
lyr.active = obj.active
|
|
||||||
lyr.clear_label_cache = obj.clear_label_cache
|
|
||||||
lyr.datasource = obj.datasource
|
|
||||||
#lyr.maxzoom = obj.maxzoom
|
|
||||||
#lyr.minzoom = obj.minzoom
|
|
||||||
lyr.queryable = obj.queryable
|
|
||||||
lyr.srs = obj.srs
|
|
||||||
lyr.title = obj.title
|
|
||||||
if hasattr(obj,'wmsdefaultstyle'):
|
|
||||||
lyr.wmsdefaultstyle = obj.wmsdefaultstyle
|
|
||||||
if hasattr(obj,'wmsextrastyles'):
|
|
||||||
lyr.wmsextrastyles = obj.wmsextrastyles
|
|
||||||
return lyr
|
|
||||||
|
|
||||||
def copy_style(obj):
|
|
||||||
sty = Style()
|
|
||||||
for rule in obj.rules:
|
|
||||||
sty.rules.append(rule)
|
|
||||||
return sty
|
|
||||||
|
|
||||||
class WMSBaseServiceHandler(BaseServiceHandler):
|
|
||||||
|
|
||||||
def GetMap(self, params):
|
|
||||||
m = self._buildMap(params)
|
|
||||||
im = Image(params['width'], params['height'])
|
|
||||||
render(m, im)
|
|
||||||
return Response(params['format'], im.tostring(PIL_TYPE_MAPPING[params['format']]))
|
|
||||||
|
|
||||||
def GetFeatureInfo(self, params, querymethodname='query_point'):
|
|
||||||
m = self._buildMap(params)
|
|
||||||
if params['info_format'] == 'text/plain':
|
|
||||||
writer = TextFeatureInfo()
|
|
||||||
elif params['info_format'] == 'text/xml':
|
|
||||||
writer = XMLFeatureInfo()
|
|
||||||
if params['query_layers'] and params['query_layers'][0] == '__all__':
|
|
||||||
for layerindex, layer in enumerate(m.layers):
|
|
||||||
featureset = getattr(m, querymethodname)(layerindex, params['i'], params['j'])
|
|
||||||
features = featureset.features
|
|
||||||
if features:
|
|
||||||
writer.addlayer(layer.name)
|
|
||||||
for feat in features:
|
|
||||||
writer.addfeature()
|
|
||||||
for prop in feat.properties:
|
|
||||||
writer.addattribute(prop[0], prop[1])
|
|
||||||
else:
|
|
||||||
for layerindex, layername in enumerate(params['query_layers']):
|
|
||||||
if layername in params['layers']:
|
|
||||||
if m.layers[layerindex].queryable:
|
|
||||||
featureset = getattr(m, querymethodname)(layerindex, params['i'], params['j'])
|
|
||||||
features = featureset.features
|
|
||||||
if features:
|
|
||||||
writer.addlayer(m.layers[layerindex].name)
|
|
||||||
for feat in features:
|
|
||||||
writer.addfeature()
|
|
||||||
for prop in feat.properties:
|
|
||||||
writer.addattribute(prop[0], prop[1])
|
|
||||||
else:
|
|
||||||
raise OGCException('Requested query layer "%s" is not marked queryable.' % layername, 'LayerNotQueryable')
|
|
||||||
else:
|
|
||||||
raise OGCException('Requested query layer "%s" not in the LAYERS parameter.' % layername)
|
|
||||||
return Response(params['info_format'], str(writer))
|
|
||||||
|
|
||||||
def _buildMap(self, params):
|
|
||||||
if str(params['crs']) not in self.allowedepsgcodes:
|
|
||||||
raise OGCException('Unsupported CRS "%s" requested.' % str(params['crs']).upper(), 'InvalidCRS')
|
|
||||||
if params['bbox'][0] >= params['bbox'][2]:
|
|
||||||
raise OGCException("BBOX values don't make sense. minx is greater than maxx.")
|
|
||||||
if params['bbox'][1] >= params['bbox'][3]:
|
|
||||||
raise OGCException("BBOX values don't make sense. miny is greater than maxy.")
|
|
||||||
if params.has_key('styles') and len(params['styles']) != len(params['layers']):
|
|
||||||
raise OGCException('STYLES length does not match LAYERS length.')
|
|
||||||
m = Map(params['width'], params['height'], '+init=%s' % params['crs'])
|
|
||||||
if params.has_key('transparent') and params['transparent'] == 'FALSE':
|
|
||||||
if params['bgcolor']:
|
|
||||||
m.background = params['bgcolor']
|
|
||||||
else:
|
|
||||||
m.background = Color(0, 0, 0, 0)
|
|
||||||
maplayers = self.mapfactory.layers
|
|
||||||
orderedmaplayers = self.mapfactory.ordered_layers
|
|
||||||
mapstyles = self.mapfactory.styles
|
|
||||||
mapaggregatestyles = self.mapfactory.aggregatestyles
|
|
||||||
# a non WMS spec way of requesting all layers
|
|
||||||
if params['layers'] and params['layers'][0] == '__all__':
|
|
||||||
for layername in orderedmaplayers:
|
|
||||||
layer = copy_layer(layername)
|
|
||||||
reqstyle = layer.wmsdefaultstyle
|
|
||||||
if reqstyle in mapaggregatestyles.keys():
|
|
||||||
for stylename in mapaggregatestyles[reqstyle]:
|
|
||||||
layer.styles.append(stylename)
|
|
||||||
else:
|
|
||||||
layer.styles.append(reqstyle)
|
|
||||||
for stylename in layer.styles:
|
|
||||||
if stylename in mapstyles.keys():
|
|
||||||
m.append_style(stylename, mapstyles[stylename])
|
|
||||||
m.layers.append(layer)
|
|
||||||
else:
|
|
||||||
for layerindex, layername in enumerate(params['layers']):
|
|
||||||
try:
|
|
||||||
layer = copy_layer(maplayers[layername])
|
|
||||||
except KeyError:
|
|
||||||
raise OGCException('Layer "%s" not defined.' % layername, 'LayerNotDefined')
|
|
||||||
try:
|
|
||||||
reqstyle = params['styles'][layerindex]
|
|
||||||
except IndexError:
|
|
||||||
reqstyle = ''
|
|
||||||
if reqstyle and reqstyle not in layer.wmsextrastyles:
|
|
||||||
raise OGCException('Invalid style "%s" requested for layer "%s".' % (reqstyle, layername), 'StyleNotDefined')
|
|
||||||
if not reqstyle:
|
|
||||||
reqstyle = layer.wmsdefaultstyle
|
|
||||||
if reqstyle in mapaggregatestyles.keys():
|
|
||||||
for stylename in mapaggregatestyles[reqstyle]:
|
|
||||||
layer.styles.append(stylename)
|
|
||||||
else:
|
|
||||||
layer.styles.append(reqstyle)
|
|
||||||
for stylename in layer.styles:
|
|
||||||
if stylename in mapstyles.keys():
|
|
||||||
m.append_style(stylename, mapstyles[stylename])
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('Layer "%s" refers to non-existent style "%s".' % (layername, stylename))
|
|
||||||
m.layers.append(layer)
|
|
||||||
m.zoom_to_box(Box2d(params['bbox'][0], params['bbox'][1], params['bbox'][2], params['bbox'][3]))
|
|
||||||
return m
|
|
||||||
|
|
||||||
class BaseExceptionHandler:
|
|
||||||
|
|
||||||
def __init__(self, debug):
|
|
||||||
self.debug = debug
|
|
||||||
|
|
||||||
def getresponse(self, params):
|
|
||||||
code = ''
|
|
||||||
message = '\n'
|
|
||||||
if not params:
|
|
||||||
message = '''
|
|
||||||
<h2>Welcome to the Mapnik OGCServer.</h2>
|
|
||||||
<h3>Ready to accept map requests...</h5>
|
|
||||||
<h4>For more info see: <a href="http://trac.mapnik.org/wiki/OgcServer">trac.mapnik.org</a></h4>
|
|
||||||
'''
|
|
||||||
return self.htmlhandler('', message)
|
|
||||||
excinfo = exc_info()
|
|
||||||
if self.debug:
|
|
||||||
messagelist = format_exception(excinfo[0], excinfo[1], excinfo[2])
|
|
||||||
else:
|
|
||||||
messagelist = format_exception_only(excinfo[0], excinfo[1])
|
|
||||||
message += ''.join(messagelist)
|
|
||||||
if isinstance(excinfo[1], OGCException) and len(excinfo[1].args) > 1:
|
|
||||||
code = excinfo[1].args[1]
|
|
||||||
exceptions = params.get('exceptions', None)
|
|
||||||
if self.debug:
|
|
||||||
return self.htmlhandler(code, message)
|
|
||||||
if not exceptions or not self.handlers.has_key(exceptions):
|
|
||||||
exceptions = self.defaulthandler
|
|
||||||
return self.handlers[exceptions](self, code, message, params)
|
|
||||||
|
|
||||||
def htmlhandler(self,code,message):
|
|
||||||
if code:
|
|
||||||
resp_text = '<h2>OGCServer Error:</h2><pre>%s</pre>\n<h3>Traceback:</h3><pre>%s</pre>\n' % (message, code)
|
|
||||||
else:
|
|
||||||
resp_text = message
|
|
||||||
return Response('text/html', resp_text)
|
|
||||||
|
|
||||||
def xmlhandler(self, code, message, params):
|
|
||||||
ogcexcetree = deepcopy(self.xmltemplate)
|
|
||||||
e = ogcexcetree.find(self.xpath)
|
|
||||||
e.text = message
|
|
||||||
if code:
|
|
||||||
e.set('code', code)
|
|
||||||
return Response(self.xmlmimetype, ElementTree.tostring(ogcexcetree))
|
|
||||||
|
|
||||||
def inimagehandler(self, code, message, params):
|
|
||||||
im = new('RGBA', (int(params['width']), int(params['height'])))
|
|
||||||
im.putalpha(new('1', (int(params['width']), int(params['height']))))
|
|
||||||
draw = Draw(im)
|
|
||||||
for count, line in enumerate(message.strip().split('\n')):
|
|
||||||
draw.text((12,15*(count+1)), line, fill='#000000')
|
|
||||||
fh = StringIO()
|
|
||||||
im.save(fh, PIL_TYPE_MAPPING[params['format']])
|
|
||||||
fh.seek(0)
|
|
||||||
return Response(params['format'], fh.read())
|
|
||||||
|
|
||||||
def blankhandler(self, code, message, params):
|
|
||||||
bgcolor = params.get('bgcolor', '#FFFFFF')
|
|
||||||
bgcolor = bgcolor.replace('0x', '#')
|
|
||||||
transparent = params.get('transparent', 'FALSE')
|
|
||||||
if transparent == 'TRUE':
|
|
||||||
im = new('RGBA', (int(params['width']), int(params['height'])))
|
|
||||||
im.putalpha(new('1', (int(params['width']), int(params['height']))))
|
|
||||||
else:
|
|
||||||
im = new('RGBA', (int(params['width']), int(params['height'])), bgcolor)
|
|
||||||
fh = StringIO()
|
|
||||||
im.save(fh, PIL_TYPE_MAPPING[params['format']])
|
|
||||||
fh.seek(0)
|
|
||||||
return Response(params['format'], fh.read())
|
|
||||||
|
|
||||||
class Projection(MapnikProjection):
|
|
||||||
|
|
||||||
def epsgstring(self):
|
|
||||||
return self.params().split('=')[1].upper()
|
|
||||||
|
|
||||||
class TextFeatureInfo:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.buffer = ''
|
|
||||||
|
|
||||||
def addlayer(self, name):
|
|
||||||
self.buffer += '\n[%s]\n' % name
|
|
||||||
|
|
||||||
def addfeature(self):
|
|
||||||
pass#self.buffer += '\n'
|
|
||||||
|
|
||||||
def addattribute(self, name, value):
|
|
||||||
self.buffer += '%s=%s\n' % (name, str(value))
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.buffer
|
|
||||||
|
|
||||||
class XMLFeatureInfo:
|
|
||||||
|
|
||||||
basexml = """<?xml version="1.0"?>
|
|
||||||
<resultset>
|
|
||||||
</resultset>
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.rootelement = ElementTree.fromstring(self.basexml)
|
|
||||||
|
|
||||||
def addlayer(self, name):
|
|
||||||
layer = ElementTree.Element('layer')
|
|
||||||
layer.set('name', name)
|
|
||||||
self.rootelement.append(layer)
|
|
||||||
self.currentlayer = layer
|
|
||||||
|
|
||||||
def addfeature(self):
|
|
||||||
feature = ElementTree.Element('feature')
|
|
||||||
self.currentlayer.append(feature)
|
|
||||||
self.currentfeature = feature
|
|
||||||
|
|
||||||
def addattribute(self, name, value):
|
|
||||||
attribute = ElementTree.Element('attribute')
|
|
||||||
attname = ElementTree.Element('name')
|
|
||||||
attname.text = name
|
|
||||||
attvalue = ElementTree.Element('value')
|
|
||||||
attvalue.text = unicode(value)
|
|
||||||
attribute.append(attname)
|
|
||||||
attribute.append(attvalue)
|
|
||||||
self.currentfeature.append(attribute)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '<?xml version="1.0"?>\n' + ElementTree.tostring(self.rootelement)
|
|
|
@ -1,44 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
""" Change SafeConfigParser behavior to treat options without values as
|
|
||||||
non-existent.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from ConfigParser import SafeConfigParser as OrigSafeConfigParser
|
|
||||||
|
|
||||||
class SafeConfigParser(OrigSafeConfigParser):
|
|
||||||
|
|
||||||
def items_with_value(self, section):
|
|
||||||
finallist = []
|
|
||||||
items = self.items(section)
|
|
||||||
for item in items:
|
|
||||||
if item[1] != '':
|
|
||||||
finallist.append(item)
|
|
||||||
return finallist
|
|
||||||
|
|
||||||
def has_option_with_value(self, section, option):
|
|
||||||
if self.has_option(section, option):
|
|
||||||
if self.get(section, option) == '':
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
return True
|
|
|
@ -1,28 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""Custom OGCServer Exceptions"""
|
|
||||||
|
|
||||||
class OGCException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class ServerConfigurationError(Exception):
|
|
||||||
pass
|
|
|
@ -1,133 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id: modserver.py 283 2006-07-22 18:54:53Z jdoyon $
|
|
||||||
|
|
||||||
"""Mod_python handler for Mapnik OGC WMS Server."""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from mod_python import apache, util
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from wms111 import ExceptionHandler as ExceptionHandler111
|
|
||||||
from wms130 import ExceptionHandler as ExceptionHandler130
|
|
||||||
from configparser import SafeConfigParser
|
|
||||||
from common import Version
|
|
||||||
|
|
||||||
|
|
||||||
class ModHandler(object):
|
|
||||||
def __init__(self, configpath):
|
|
||||||
conf = SafeConfigParser()
|
|
||||||
conf.readfp(open(configpath))
|
|
||||||
self.conf = conf
|
|
||||||
if not conf.has_option_with_value('server', 'module'):
|
|
||||||
raise ServerConfigurationError('The factory module is not defined in the configuration file.')
|
|
||||||
try:
|
|
||||||
mapfactorymodule = __import__(conf.get('server', 'module'))
|
|
||||||
except ImportError:
|
|
||||||
raise ServerConfigurationError('The factory module could not be loaded.')
|
|
||||||
if hasattr(mapfactorymodule, 'WMSFactory'):
|
|
||||||
self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
|
|
||||||
if conf.has_option('server', 'debug'):
|
|
||||||
self.debug = int(conf.get('server', 'debug'))
|
|
||||||
else:
|
|
||||||
self.debug = 0
|
|
||||||
if self.conf.has_option_with_value('server', 'maxage'):
|
|
||||||
self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
|
|
||||||
else:
|
|
||||||
self.max_age = None
|
|
||||||
|
|
||||||
def __call__(self, apacheReq):
|
|
||||||
try:
|
|
||||||
reqparams = util.FieldStorage(apacheReq,keep_blank_values=1)
|
|
||||||
if not reqparams:
|
|
||||||
eh = ExceptionHandler130(self.debug)
|
|
||||||
response = eh.getresponse(reqparams)
|
|
||||||
apacheReq.content_type = response.content_type
|
|
||||||
else:
|
|
||||||
reqparams = lowerparams(reqparams)
|
|
||||||
port = apacheReq.connection.local_addr[1]
|
|
||||||
onlineresource = 'http://%s:%s%s?' % (apacheReq.hostname, port, apacheReq.subprocess_env['SCRIPT_NAME'])
|
|
||||||
if not reqparams.has_key('request'):
|
|
||||||
raise OGCException('Missing Request parameter.')
|
|
||||||
request = reqparams['request']
|
|
||||||
del reqparams['request']
|
|
||||||
if request == 'GetCapabilities' and not reqparams.has_key('service'):
|
|
||||||
raise OGCException('Missing service parameter.')
|
|
||||||
if request in ['GetMap', 'GetFeatureInfo']:
|
|
||||||
service = 'WMS'
|
|
||||||
else:
|
|
||||||
service = reqparams['service']
|
|
||||||
if reqparams.has_key('service'):
|
|
||||||
del reqparams['service']
|
|
||||||
try:
|
|
||||||
mapnikmodule = __import__('mapnik2.ogcserver.' + service)
|
|
||||||
except:
|
|
||||||
raise OGCException('Unsupported service "%s".' % service)
|
|
||||||
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory
|
|
||||||
servicehandler = ServiceHandlerFactory(self.conf, self.mapfactory, onlineresource, reqparams.get('version', None))
|
|
||||||
if reqparams.has_key('version'):
|
|
||||||
del reqparams['version']
|
|
||||||
if request not in servicehandler.SERVICE_PARAMS.keys():
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
|
|
||||||
# Get parameters and pass to WMSFactory in custom "setup" method
|
|
||||||
ogcparams = servicehandler.processParameters(request, reqparams)
|
|
||||||
try:
|
|
||||||
requesthandler = getattr(servicehandler, request)
|
|
||||||
except:
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
|
|
||||||
response = requesthandler(ogcparams)
|
|
||||||
apacheReq.content_type = response.content_type
|
|
||||||
apacheReq.status = apache.HTTP_OK
|
|
||||||
except Exception, E:
|
|
||||||
return self.traceback(apacheReq,E)
|
|
||||||
|
|
||||||
if self.max_age:
|
|
||||||
apacheReq.headers_out.add('Cache-Control', max_age)
|
|
||||||
apacheReq.headers_out.add('Content-Length', str(len(response.content)))
|
|
||||||
apacheReq.send_http_header()
|
|
||||||
apacheReq.write(response.content)
|
|
||||||
return apache.OK
|
|
||||||
|
|
||||||
def traceback(self, apacheReq,E):
|
|
||||||
reqparams = lowerparams(util.FieldStorage(apacheReq))
|
|
||||||
version = reqparams.get('version', None)
|
|
||||||
if not version:
|
|
||||||
version = Version('1.3.0')
|
|
||||||
else:
|
|
||||||
version = Version(version)
|
|
||||||
if version >= '1.3.0':
|
|
||||||
eh = ExceptionHandler130(self.debug)
|
|
||||||
else:
|
|
||||||
eh = ExceptionHandler111(self.debug)
|
|
||||||
response = eh.getresponse(reqparams)
|
|
||||||
apacheReq.content_type = response.content_type
|
|
||||||
apacheReq.headers_out.add('Content-Length', str(len(response.content)))
|
|
||||||
apacheReq.send_http_header()
|
|
||||||
apacheReq.write(response.content)
|
|
||||||
return apache.OK
|
|
||||||
|
|
||||||
def lowerparams(params):
|
|
||||||
reqparams = {}
|
|
||||||
for key, value in params.items():
|
|
||||||
reqparams[key.lower()] = value
|
|
||||||
return reqparams
|
|
|
@ -1,238 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""WMS 1.1.1 compliant GetCapabilities, GetMap, GetFeatureInfo, and Exceptions interface."""
|
|
||||||
|
|
||||||
from common import ParameterDefinition, Response, Version, ListFactory, \
|
|
||||||
ColorFactory, CRSFactory, WMSBaseServiceHandler, CRS, \
|
|
||||||
BaseExceptionHandler, Projection
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from mapnik2 import Coord
|
|
||||||
|
|
||||||
try:
|
|
||||||
from lxml import etree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import xml.etree.ElementTree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import elementtree.ElementTree as ElementTree
|
|
||||||
|
|
||||||
class ServiceHandler(WMSBaseServiceHandler):
|
|
||||||
|
|
||||||
SERVICE_PARAMS = {
|
|
||||||
'GetCapabilities': {
|
|
||||||
'updatesequence': ParameterDefinition(False, str)
|
|
||||||
},
|
|
||||||
'GetMap': {
|
|
||||||
'layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'styles': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'srs': ParameterDefinition(True, CRSFactory(['EPSG'])),
|
|
||||||
'bbox': ParameterDefinition(True, ListFactory(float)),
|
|
||||||
'width': ParameterDefinition(True, int),
|
|
||||||
'height': ParameterDefinition(True, int),
|
|
||||||
'format': ParameterDefinition(True, str, allowedvalues=('image/png', 'image/jpeg')),
|
|
||||||
'transparent': ParameterDefinition(False, str, 'FALSE', ('TRUE', 'FALSE')),
|
|
||||||
'bgcolor': ParameterDefinition(False, ColorFactory, ColorFactory('0xFFFFFF')),
|
|
||||||
'exceptions': ParameterDefinition(False, str, 'application/vnd.ogc.se_xml', ('application/vnd.ogc.se_xml', 'application/vnd.ogc.se_inimage', 'application/vnd.ogc.se_blank','text/html'))
|
|
||||||
},
|
|
||||||
'GetFeatureInfo': {
|
|
||||||
'layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'styles': ParameterDefinition(False, ListFactory(str)),
|
|
||||||
'srs': ParameterDefinition(True, CRSFactory(['EPSG'])),
|
|
||||||
'bbox': ParameterDefinition(True, ListFactory(float)),
|
|
||||||
'width': ParameterDefinition(True, int),
|
|
||||||
'height': ParameterDefinition(True, int),
|
|
||||||
'format': ParameterDefinition(False, str, allowedvalues=('image/png', 'image/jpeg')),
|
|
||||||
'transparent': ParameterDefinition(False, str, 'FALSE', ('TRUE', 'FALSE')),
|
|
||||||
'bgcolor': ParameterDefinition(False, ColorFactory, ColorFactory('0xFFFFFF')),
|
|
||||||
'exceptions': ParameterDefinition(False, str, 'application/vnd.ogc.se_xml', ('application/vnd.ogc.se_xml', 'application/vnd.ogc.se_inimage', 'application/vnd.ogc.se_blank','text/html')),
|
|
||||||
'query_layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'info_format': ParameterDefinition(True, str, allowedvalues=('text/plain', 'text/xml')),
|
|
||||||
'feature_count': ParameterDefinition(False, int, 1),
|
|
||||||
'x': ParameterDefinition(True, int),
|
|
||||||
'y': ParameterDefinition(True, int)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CONF_SERVICE = [
|
|
||||||
['title', 'Title', str],
|
|
||||||
['abstract', 'Abstract', str],
|
|
||||||
['onlineresource', 'OnlineResource', str],
|
|
||||||
['fees', 'Fees', str],
|
|
||||||
['accessconstraints', 'AccessConstraints', str],
|
|
||||||
['keywordlist', 'KeywordList', str]
|
|
||||||
]
|
|
||||||
|
|
||||||
capabilitiesxmltemplate = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://www.digitalearth.gov/wmt/xml/capabilities_1_1_1.dtd">
|
|
||||||
<WMT_MS_Capabilities version="1.1.1" updateSequence="0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.opengis.net/wms">
|
|
||||||
<Service>
|
|
||||||
<Name>WMS</Name>
|
|
||||||
</Service>
|
|
||||||
<Capability>
|
|
||||||
<Request>
|
|
||||||
<GetCapabilities>
|
|
||||||
<Format>application/vnd.ogc.wms_xml</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetCapabilities>
|
|
||||||
<GetMap>
|
|
||||||
<Format>image/png</Format>
|
|
||||||
<Format>image/jpeg</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetMap>
|
|
||||||
<GetFeatureInfo>
|
|
||||||
<Format>text/plain</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetFeatureInfo>
|
|
||||||
</Request>
|
|
||||||
<Exception>
|
|
||||||
<Format>application/vnd.ogc.se_xml</Format>
|
|
||||||
<Format>application/vnd.ogc.se_inimage</Format>
|
|
||||||
<Format>application/vnd.ogc.se_blank</Format>
|
|
||||||
</Exception>
|
|
||||||
<Layer>
|
|
||||||
<Title>A Mapnik WMS Server</Title>
|
|
||||||
<Abstract>A Mapnik WMS Server</Abstract>
|
|
||||||
</Layer>
|
|
||||||
</Capability>
|
|
||||||
</WMT_MS_Capabilities>
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, conf, mapfactory, opsonlineresource):
|
|
||||||
self.conf = conf
|
|
||||||
self.mapfactory = mapfactory
|
|
||||||
self.opsonlineresource = opsonlineresource
|
|
||||||
if self.conf.has_option('service', 'allowedepsgcodes'):
|
|
||||||
self.allowedepsgcodes = map(lambda code: 'epsg:%s' % code, self.conf.get('service', 'allowedepsgcodes').split(','))
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('Allowed EPSG codes not properly configured.')
|
|
||||||
self.capabilities = None
|
|
||||||
|
|
||||||
def GetCapabilities(self, params):
|
|
||||||
if not self.capabilities:
|
|
||||||
capetree = ElementTree.fromstring(self.capabilitiesxmltemplate)
|
|
||||||
|
|
||||||
elements = capetree.findall('Capability//OnlineResource')
|
|
||||||
for element in elements:
|
|
||||||
element.set('{http://www.w3.org/1999/xlink}href', self.opsonlineresource)
|
|
||||||
|
|
||||||
self.processServiceCapabilities(capetree)
|
|
||||||
|
|
||||||
rootlayerelem = capetree.find('{http://www.opengis.net/wms}Capability/{http://www.opengis.net/wms}Layer')
|
|
||||||
|
|
||||||
for epsgcode in self.allowedepsgcodes:
|
|
||||||
rootlayercrs = ElementTree.Element('SRS')
|
|
||||||
rootlayercrs.text = epsgcode.upper()
|
|
||||||
rootlayerelem.append(rootlayercrs)
|
|
||||||
|
|
||||||
for layer in self.mapfactory.ordered_layers:
|
|
||||||
layerproj = Projection(layer.srs)
|
|
||||||
layername = ElementTree.Element('Name')
|
|
||||||
layername.text = layer.name
|
|
||||||
env = layer.envelope()
|
|
||||||
llp = layerproj.inverse(Coord(env.minx, env.miny))
|
|
||||||
urp = layerproj.inverse(Coord(env.maxx, env.maxy))
|
|
||||||
latlonbb = ElementTree.Element('LatLonBoundingBox')
|
|
||||||
latlonbb.set('minx', str(llp.x))
|
|
||||||
latlonbb.set('miny', str(llp.y))
|
|
||||||
latlonbb.set('maxx', str(urp.x))
|
|
||||||
latlonbb.set('maxy', str(urp.y))
|
|
||||||
layerbbox = ElementTree.Element('BoundingBox')
|
|
||||||
layerbbox.set('SRS', layerproj.epsgstring())
|
|
||||||
layerbbox.set('minx', str(env.minx))
|
|
||||||
layerbbox.set('miny', str(env.miny))
|
|
||||||
layerbbox.set('maxx', str(env.maxx))
|
|
||||||
layerbbox.set('maxy', str(env.maxy))
|
|
||||||
layere = ElementTree.Element('Layer')
|
|
||||||
layere.append(layername)
|
|
||||||
if layer.title:
|
|
||||||
layertitle = ElementTree.Element('Title')
|
|
||||||
layertitle.text = layer.title
|
|
||||||
layere.append(layertitle)
|
|
||||||
if layer.abstract:
|
|
||||||
layerabstract = ElementTree.Element('Abstract')
|
|
||||||
layerabstract.text = layer.abstract
|
|
||||||
layere.append(layerabstract)
|
|
||||||
if layer.queryable:
|
|
||||||
layere.set('queryable', '1')
|
|
||||||
layere.append(latlonbb)
|
|
||||||
layere.append(layerbbox)
|
|
||||||
if len(layer.wmsextrastyles) > 0:
|
|
||||||
for extrastyle in [layer.wmsdefaultstyle] + list(layer.wmsextrastyles):
|
|
||||||
style = ElementTree.Element('Style')
|
|
||||||
stylename = ElementTree.Element('Name')
|
|
||||||
stylename.text = extrastyle
|
|
||||||
styletitle = ElementTree.Element('Title')
|
|
||||||
styletitle.text = extrastyle
|
|
||||||
style.append(stylename)
|
|
||||||
style.append(styletitle)
|
|
||||||
layere.append(style)
|
|
||||||
rootlayerelem.append(layere)
|
|
||||||
self.capabilities = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' + ElementTree.tostring(capetree)
|
|
||||||
response = Response('application/vnd.ogc.wms_xml', self.capabilities)
|
|
||||||
return response
|
|
||||||
|
|
||||||
def GetMap(self, params):
|
|
||||||
params['crs'] = params['srs']
|
|
||||||
return WMSBaseServiceHandler.GetMap(self, params)
|
|
||||||
|
|
||||||
def GetFeatureInfo(self, params):
|
|
||||||
params['crs'] = params['srs']
|
|
||||||
params['i'] = params['x']
|
|
||||||
params['j'] = params['y']
|
|
||||||
return WMSBaseServiceHandler.GetFeatureInfo(self, params, 'query_map_point')
|
|
||||||
|
|
||||||
class ExceptionHandler(BaseExceptionHandler):
|
|
||||||
|
|
||||||
xmlmimetype = "application/vnd.ogc.se_xml"
|
|
||||||
|
|
||||||
xmltemplate = ElementTree.fromstring("""<?xml version='1.0' encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE ServiceExceptionReport SYSTEM "http://www.digitalearth.gov/wmt/xml/exception_1_1_1.dtd">
|
|
||||||
<ServiceExceptionReport version="1.1.1">
|
|
||||||
<ServiceException />
|
|
||||||
</ServiceExceptionReport>
|
|
||||||
""")
|
|
||||||
|
|
||||||
xpath = 'ServiceException'
|
|
||||||
|
|
||||||
handlers = {'application/vnd.ogc.se_xml': BaseExceptionHandler.xmlhandler,
|
|
||||||
'application/vnd.ogc.se_inimage': BaseExceptionHandler.inimagehandler,
|
|
||||||
'application/vnd.ogc.se_blank': BaseExceptionHandler.blankhandler,
|
|
||||||
'text/html': BaseExceptionHandler.htmlhandler}
|
|
||||||
|
|
||||||
defaulthandler = 'application/vnd.ogc.se_xml'
|
|
|
@ -1,264 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""WMS 1.3.0 compliant GetCapabilities, GetMap, GetFeatureInfo, and Exceptions interface."""
|
|
||||||
|
|
||||||
from common import ParameterDefinition, Response, Version, ListFactory, \
|
|
||||||
ColorFactory, CRSFactory, CRS, WMSBaseServiceHandler, \
|
|
||||||
BaseExceptionHandler, Projection, Box2d
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from mapnik2 import Coord
|
|
||||||
|
|
||||||
try:
|
|
||||||
from lxml import etree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import xml.etree.ElementTree as ElementTree
|
|
||||||
except ImportError:
|
|
||||||
import elementtree.ElementTree as ElementTree
|
|
||||||
|
|
||||||
class ServiceHandler(WMSBaseServiceHandler):
|
|
||||||
|
|
||||||
SERVICE_PARAMS = {
|
|
||||||
'GetCapabilities': {
|
|
||||||
'format': ParameterDefinition(False, str, 'text/xml', ('text/xml',), True),
|
|
||||||
'updatesequence': ParameterDefinition(False, str)
|
|
||||||
},
|
|
||||||
'GetMap': {
|
|
||||||
'layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'styles': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'crs': ParameterDefinition(True, CRSFactory(['EPSG'])),
|
|
||||||
'bbox': ParameterDefinition(True, ListFactory(float)),
|
|
||||||
'width': ParameterDefinition(True, int),
|
|
||||||
'height': ParameterDefinition(True, int),
|
|
||||||
'format': ParameterDefinition(True, str, allowedvalues=('image/png', 'image/jpeg')),
|
|
||||||
'transparent': ParameterDefinition(False, str, 'FALSE', ('TRUE', 'FALSE')),
|
|
||||||
'bgcolor': ParameterDefinition(False, ColorFactory, ColorFactory('0xFFFFFF')),
|
|
||||||
'exceptions': ParameterDefinition(False, str, 'XML', ('XML', 'INIMAGE', 'BLANK','HTML')),
|
|
||||||
},
|
|
||||||
'GetFeatureInfo': {
|
|
||||||
'layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'styles': ParameterDefinition(False, ListFactory(str)),
|
|
||||||
'crs': ParameterDefinition(True, CRSFactory(['EPSG'])),
|
|
||||||
'bbox': ParameterDefinition(True, ListFactory(float)),
|
|
||||||
'width': ParameterDefinition(True, int),
|
|
||||||
'height': ParameterDefinition(True, int),
|
|
||||||
'format': ParameterDefinition(False, str, allowedvalues=('image/png', 'image/jpeg')),
|
|
||||||
'transparent': ParameterDefinition(False, str, 'FALSE', ('TRUE', 'FALSE')),
|
|
||||||
'bgcolor': ParameterDefinition(False, ColorFactory, ColorFactory('0xFFFFFF')),
|
|
||||||
'exceptions': ParameterDefinition(False, str, 'XML', ('XML', 'INIMAGE', 'BLANK','HTML')),
|
|
||||||
'query_layers': ParameterDefinition(True, ListFactory(str)),
|
|
||||||
'info_format': ParameterDefinition(True, str, allowedvalues=('text/plain', 'text/xml')),
|
|
||||||
'feature_count': ParameterDefinition(False, int, 1),
|
|
||||||
'i': ParameterDefinition(True, float),
|
|
||||||
'j': ParameterDefinition(True, float)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CONF_SERVICE = [
|
|
||||||
['title', 'Title', str],
|
|
||||||
['abstract', 'Abstract', str],
|
|
||||||
['onlineresource', 'OnlineResource', str],
|
|
||||||
['fees', 'Fees', str],
|
|
||||||
['accessconstraints', 'AccessConstraints', str],
|
|
||||||
['layerlimit', 'LayerLimit', int],
|
|
||||||
['maxwidth', 'MaxWidth', int],
|
|
||||||
['maxheight', 'MaxHeight', int],
|
|
||||||
['keywordlist', 'KeywordList', str]
|
|
||||||
]
|
|
||||||
|
|
||||||
capabilitiesxmltemplate = """<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<WMS_Capabilities version="1.3.0" xmlns="http://www.opengis.net/wms"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd">
|
|
||||||
<Service>
|
|
||||||
<Name>WMS</Name>
|
|
||||||
</Service>
|
|
||||||
<Capability>
|
|
||||||
<Request>
|
|
||||||
<GetCapabilities>
|
|
||||||
<Format>text/xml</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetCapabilities>
|
|
||||||
<GetMap>
|
|
||||||
<Format>image/png</Format>
|
|
||||||
<Format>image/jpeg</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetMap>
|
|
||||||
<GetFeatureInfo>
|
|
||||||
<Format>text/plain</Format>
|
|
||||||
<DCPType>
|
|
||||||
<HTTP>
|
|
||||||
<Get>
|
|
||||||
<OnlineResource xlink:type="simple"/>
|
|
||||||
</Get>
|
|
||||||
</HTTP>
|
|
||||||
</DCPType>
|
|
||||||
</GetFeatureInfo>
|
|
||||||
</Request>
|
|
||||||
<Exception>
|
|
||||||
<Format>XML</Format>
|
|
||||||
<Format>INIMAGE</Format>
|
|
||||||
<Format>BLANK</Format>
|
|
||||||
</Exception>
|
|
||||||
<Layer>
|
|
||||||
<Title>A Mapnik WMS Server</Title>
|
|
||||||
<Abstract>A Mapnik WMS Server</Abstract>
|
|
||||||
</Layer>
|
|
||||||
</Capability>
|
|
||||||
</WMS_Capabilities>
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, conf, mapfactory, opsonlineresource):
|
|
||||||
self.conf = conf
|
|
||||||
self.mapfactory = mapfactory
|
|
||||||
self.opsonlineresource = opsonlineresource
|
|
||||||
if self.conf.has_option('service', 'allowedepsgcodes'):
|
|
||||||
self.allowedepsgcodes = map(lambda code: 'epsg:%s' % code, self.conf.get('service', 'allowedepsgcodes').split(','))
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('Allowed EPSG codes not properly configured.')
|
|
||||||
self.capabilities = None
|
|
||||||
|
|
||||||
def GetCapabilities(self, params):
|
|
||||||
if not self.capabilities:
|
|
||||||
capetree = ElementTree.fromstring(self.capabilitiesxmltemplate)
|
|
||||||
|
|
||||||
elements = capetree.findall('{http://www.opengis.net/wms}Capability//{http://www.opengis.net/wms}OnlineResource')
|
|
||||||
for element in elements:
|
|
||||||
element.set('{http://www.w3.org/1999/xlink}href', self.opsonlineresource)
|
|
||||||
|
|
||||||
self.processServiceCapabilities(capetree)
|
|
||||||
|
|
||||||
rootlayerelem = capetree.find('{http://www.opengis.net/wms}Capability/{http://www.opengis.net/wms}Layer')
|
|
||||||
|
|
||||||
for epsgcode in self.allowedepsgcodes:
|
|
||||||
rootlayercrs = ElementTree.Element('CRS')
|
|
||||||
rootlayercrs.text = epsgcode.upper()
|
|
||||||
rootlayerelem.append(rootlayercrs)
|
|
||||||
|
|
||||||
for layer in self.mapfactory.ordered_layers:
|
|
||||||
layerproj = Projection(layer.srs)
|
|
||||||
layername = ElementTree.Element('Name')
|
|
||||||
layername.text = layer.name
|
|
||||||
env = layer.envelope()
|
|
||||||
layerexgbb = ElementTree.Element('EX_GeographicBoundingBox')
|
|
||||||
ll = layerproj.inverse(Coord(env.minx, env.miny))
|
|
||||||
ur = layerproj.inverse(Coord(env.maxx, env.maxy))
|
|
||||||
exgbb_wbl = ElementTree.Element('westBoundLongitude')
|
|
||||||
exgbb_wbl.text = str(ll.x)
|
|
||||||
layerexgbb.append(exgbb_wbl)
|
|
||||||
exgbb_ebl = ElementTree.Element('eastBoundLongitude')
|
|
||||||
exgbb_ebl.text = str(ur.x)
|
|
||||||
layerexgbb.append(exgbb_ebl)
|
|
||||||
exgbb_sbl = ElementTree.Element('southBoundLatitude')
|
|
||||||
exgbb_sbl.text = str(ll.y)
|
|
||||||
layerexgbb.append(exgbb_sbl)
|
|
||||||
exgbb_nbl = ElementTree.Element('northBoundLatitude')
|
|
||||||
exgbb_nbl.text = str(ur.y)
|
|
||||||
layerexgbb.append(exgbb_nbl)
|
|
||||||
layerbbox = ElementTree.Element('BoundingBox')
|
|
||||||
layerbbox.set('CRS', layerproj.epsgstring())
|
|
||||||
layerbbox.set('minx', str(env.minx))
|
|
||||||
layerbbox.set('miny', str(env.miny))
|
|
||||||
layerbbox.set('maxx', str(env.maxx))
|
|
||||||
layerbbox.set('maxy', str(env.maxy))
|
|
||||||
layere = ElementTree.Element('Layer')
|
|
||||||
layere.append(layername)
|
|
||||||
if layer.title:
|
|
||||||
layertitle = ElementTree.Element('Title')
|
|
||||||
layertitle.text = layer.title
|
|
||||||
layere.append(layertitle)
|
|
||||||
if layer.abstract:
|
|
||||||
layerabstract = ElementTree.Element('Abstract')
|
|
||||||
layerabstract.text = layer.abstract
|
|
||||||
layere.append(layerabstract)
|
|
||||||
if layer.queryable:
|
|
||||||
layere.set('queryable', '1')
|
|
||||||
layere.append(layerexgbb)
|
|
||||||
layere.append(layerbbox)
|
|
||||||
if len(layer.wmsextrastyles) > 0:
|
|
||||||
for extrastyle in [layer.wmsdefaultstyle] + list(layer.wmsextrastyles):
|
|
||||||
style = ElementTree.Element('Style')
|
|
||||||
stylename = ElementTree.Element('Name')
|
|
||||||
stylename.text = extrastyle
|
|
||||||
styletitle = ElementTree.Element('Title')
|
|
||||||
styletitle.text = extrastyle
|
|
||||||
style.append(stylename)
|
|
||||||
style.append(styletitle)
|
|
||||||
layere.append(style)
|
|
||||||
rootlayerelem.append(layere)
|
|
||||||
self.capabilities = '<?xml version="1.0" encoding="UTF-8"?>' + ElementTree.tostring(capetree)
|
|
||||||
response = Response('text/xml', self.capabilities)
|
|
||||||
return response
|
|
||||||
|
|
||||||
def GetMap(self, params):
|
|
||||||
if params['width'] > int(self.conf.get('service', 'maxwidth')) or params['height'] > int(self.conf.get('service', 'maxheight')):
|
|
||||||
raise OGCException('Requested map size exceeds limits set by this server.')
|
|
||||||
return WMSBaseServiceHandler.GetMap(self, params)
|
|
||||||
|
|
||||||
def _buildMap(self, params):
|
|
||||||
""" Override _buildMap method to handle reverse axis ordering in WMS 1.3.0.
|
|
||||||
|
|
||||||
More info: http://mapserver.org/development/rfc/ms-rfc-30.html
|
|
||||||
|
|
||||||
'when using epsg code >=4000 and <5000 will be assumed to have a reversed axes.'
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Call superclass method
|
|
||||||
m = WMSBaseServiceHandler._buildMap(self, params)
|
|
||||||
# for range of epsg codes reverse axis
|
|
||||||
if params['crs'].code >= 4000 and params['crs'].code < 5000:
|
|
||||||
m.zoom_to_box(Box2d(params['bbox'][1], params['bbox'][0], params['bbox'][3], params['bbox'][2]))
|
|
||||||
return m
|
|
||||||
|
|
||||||
class ExceptionHandler(BaseExceptionHandler):
|
|
||||||
|
|
||||||
xmlmimetype = "text/xml"
|
|
||||||
|
|
||||||
xmltemplate = ElementTree.fromstring("""<?xml version='1.0' encoding="UTF-8"?>
|
|
||||||
<ServiceExceptionReport version="1.3.0"
|
|
||||||
xmlns="http://www.opengis.net/ogc"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
|
|
||||||
<ServiceException/>
|
|
||||||
</ServiceExceptionReport>
|
|
||||||
""")
|
|
||||||
|
|
||||||
xpath = '{http://www.opengis.net/ogc}ServiceException'
|
|
||||||
|
|
||||||
handlers = {'XML': BaseExceptionHandler.xmlhandler,
|
|
||||||
'INIMAGE': BaseExceptionHandler.inimagehandler,
|
|
||||||
'BLANK': BaseExceptionHandler.blankhandler,
|
|
||||||
'HTML': BaseExceptionHandler.htmlhandler}
|
|
||||||
|
|
||||||
defaulthandler = 'XML'
|
|
|
@ -1,106 +0,0 @@
|
||||||
#
|
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
#
|
|
||||||
# Copyright (C) 2006 Jean-Francois Doyon
|
|
||||||
#
|
|
||||||
# Mapnik 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
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""WSGI application wrapper for Mapnik OGC WMS Server."""
|
|
||||||
|
|
||||||
from exceptions import OGCException, ServerConfigurationError
|
|
||||||
from configparser import SafeConfigParser
|
|
||||||
from cgi import parse_qs
|
|
||||||
from wms111 import ExceptionHandler as ExceptionHandler111
|
|
||||||
from wms130 import ExceptionHandler as ExceptionHandler130
|
|
||||||
from common import Version
|
|
||||||
|
|
||||||
class WSGIApp:
|
|
||||||
|
|
||||||
def __init__(self, configpath):
|
|
||||||
conf = SafeConfigParser()
|
|
||||||
conf.readfp(open(configpath))
|
|
||||||
self.conf = conf
|
|
||||||
if not conf.has_option_with_value('server', 'module'):
|
|
||||||
raise ServerConfigurationError('The factory module is not defined in the configuration file.')
|
|
||||||
try:
|
|
||||||
mapfactorymodule = __import__(conf.get('server', 'module'))
|
|
||||||
except ImportError:
|
|
||||||
raise ServerConfigurationError('The factory module could not be loaded.')
|
|
||||||
if hasattr(mapfactorymodule, 'WMSFactory'):
|
|
||||||
self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
|
|
||||||
else:
|
|
||||||
raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
|
|
||||||
if conf.has_option('server', 'debug'):
|
|
||||||
self.debug = int(conf.get('server', 'debug'))
|
|
||||||
else:
|
|
||||||
self.debug = 0
|
|
||||||
if self.conf.has_option_with_value('server', 'maxage'):
|
|
||||||
self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
|
|
||||||
else:
|
|
||||||
self.max_age = None
|
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
|
||||||
reqparams = {}
|
|
||||||
for key, value in parse_qs(environ['QUERY_STRING'], True).items():
|
|
||||||
reqparams[key.lower()] = value[0]
|
|
||||||
onlineresource = 'http://%s:%s%s?' % (environ['SERVER_NAME'], environ['SERVER_PORT'], environ['PATH_INFO'])
|
|
||||||
try:
|
|
||||||
if not reqparams.has_key('request'):
|
|
||||||
raise OGCException('Missing request parameter.')
|
|
||||||
request = reqparams['request']
|
|
||||||
del reqparams['request']
|
|
||||||
if request == 'GetCapabilities' and not reqparams.has_key('service'):
|
|
||||||
raise OGCException('Missing service parameter.')
|
|
||||||
if request in ['GetMap', 'GetFeatureInfo']:
|
|
||||||
service = 'WMS'
|
|
||||||
else:
|
|
||||||
service = reqparams['service']
|
|
||||||
if reqparams.has_key('service'):
|
|
||||||
del reqparams['service']
|
|
||||||
try:
|
|
||||||
mapnikmodule = __import__('mapnik2.ogcserver.' + service)
|
|
||||||
except:
|
|
||||||
raise OGCException('Unsupported service "%s".' % service)
|
|
||||||
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory
|
|
||||||
servicehandler = ServiceHandlerFactory(self.conf, self.mapfactory, onlineresource, reqparams.get('version', None))
|
|
||||||
if reqparams.has_key('version'):
|
|
||||||
del reqparams['version']
|
|
||||||
if request not in servicehandler.SERVICE_PARAMS.keys():
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
ogcparams = servicehandler.processParameters(request, reqparams)
|
|
||||||
try:
|
|
||||||
requesthandler = getattr(servicehandler, request)
|
|
||||||
except:
|
|
||||||
raise OGCException('Operation "%s" not supported.' % request, 'OperationNotSupported')
|
|
||||||
response = requesthandler(ogcparams)
|
|
||||||
except:
|
|
||||||
version = reqparams.get('version', None)
|
|
||||||
if not version:
|
|
||||||
version = Version('1.3.0')
|
|
||||||
else:
|
|
||||||
version = Version(version)
|
|
||||||
if version >= '1.3.0':
|
|
||||||
eh = ExceptionHandler130(self.debug)
|
|
||||||
else:
|
|
||||||
eh = ExceptionHandler111(self.debug)
|
|
||||||
response = eh.getresponse(reqparams)
|
|
||||||
response_headers = [('Content-Type', response.content_type),('Content-Length', str(len(response.content)))]
|
|
||||||
if self.max_age:
|
|
||||||
response_headers.append(('Cache-Control', max_age))
|
|
||||||
start_response('200 OK', response_headers)
|
|
||||||
yield response.content
|
|
||||||
|
|
|
@ -4,17 +4,18 @@
|
||||||
|
|
||||||
basic usage is along the lines of
|
basic usage is along the lines of
|
||||||
|
|
||||||
import mapnik2
|
import mapnik
|
||||||
|
|
||||||
page = mapnik2.printing.PDFPrinter()
|
page = mapnik.printing.PDFPrinter()
|
||||||
m = mapnik2.Map(100,100)
|
m = mapnik.Map(100,100)
|
||||||
mapnik2.load_map(m, "my_xml_map_description", True)
|
mapnik.load_map(m, "my_xml_map_description", True)
|
||||||
m.zoom_all()
|
m.zoom_all()
|
||||||
page.render_map(m,"my_output_file.pdf")
|
page.render_map(m,"my_output_file.pdf")
|
||||||
|
|
||||||
see the documentation of mapnik2.printing.PDFPrinter() for options
|
see the documentation of mapnik.printing.PDFPrinter() for options
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from . import render, Map, Box2d, MemoryDatasource, Layer, Feature, Projection, ProjTransform, Coord, Style, Rule, Geometry2d
|
from . import render, Map, Box2d, MemoryDatasource, Layer, Feature, Projection, ProjTransform, Coord, Style, Rule, Geometry2d
|
||||||
import math
|
import math
|
||||||
|
|
27
bindings/python/mapnik2/__init__.py
Normal file
27
bindings/python/mapnik2/__init__.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#
|
||||||
|
# This file is part of Mapnik (C++/Python mapping toolkit)
|
||||||
|
# Copyright (C) 2011 Artem Pavlenko
|
||||||
|
#
|
||||||
|
# Mapnik is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or any later version.
|
||||||
|
#
|
||||||
|
# This program 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
# mapnik2 module (Deprecated)
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
from mapnik import *
|
||||||
|
warnings.simplefilter("default")
|
||||||
|
msg=""" mapnik2 module has been deprecated,
|
||||||
|
please use 'import mapnik' """
|
||||||
|
warnings.warn(msg, DeprecationWarning)
|
|
@ -264,7 +264,6 @@ void export_envelope()
|
||||||
.def(self == self) // __eq__
|
.def(self == self) // __eq__
|
||||||
.def(self != self) // __neq__
|
.def(self != self) // __neq__
|
||||||
.def(self + self) // __add__
|
.def(self + self) // __add__
|
||||||
//.def(self - self) // __sub__
|
|
||||||
.def(self * float()) // __mult__
|
.def(self * float()) // __mult__
|
||||||
.def(float() * self)
|
.def(float() * self)
|
||||||
.def(self / float()) // __div__
|
.def(self / float()) // __div__
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
#include <mapnik/wkb.hpp>
|
#include <mapnik/wkb.hpp>
|
||||||
#include <mapnik/wkt/wkt_factory.hpp>
|
#include <mapnik/wkt/wkt_factory.hpp>
|
||||||
#include "mapnik_value_converter.hpp"
|
|
||||||
|
|
||||||
mapnik::geometry_type & (mapnik::Feature::*get_geom1)(unsigned) = &mapnik::Feature::get_geometry;
|
mapnik::geometry_type & (mapnik::Feature::*get_geom1)(unsigned) = &mapnik::Feature::get_geometry;
|
||||||
|
|
||||||
|
@ -95,9 +94,11 @@ namespace boost { namespace python {
|
||||||
|
|
||||||
template <class Class>
|
template <class Class>
|
||||||
static void
|
static void
|
||||||
extension_def(Class& /*cl*/)
|
extension_def(Class& cl)
|
||||||
{
|
{
|
||||||
|
cl
|
||||||
|
.def("get", &get)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static data_type&
|
static data_type&
|
||||||
|
@ -106,12 +107,25 @@ namespace boost { namespace python {
|
||||||
typename Container::iterator i = container.props().find(i_);
|
typename Container::iterator i = container.props().find(i_);
|
||||||
if (i == container.end())
|
if (i == container.end())
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_KeyError, "Invalid key");
|
PyErr_SetString(PyExc_KeyError, i_.c_str());
|
||||||
throw_error_already_set();
|
throw_error_already_set();
|
||||||
}
|
}
|
||||||
|
// will be auto-converted to proper python type by `mapnik_value_to_python`
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static data_type
|
||||||
|
get(Container& container, index_type i_)
|
||||||
|
{
|
||||||
|
typename Container::iterator i = container.props().find(i_);
|
||||||
|
if (i != container.end())
|
||||||
|
{
|
||||||
|
// will be auto-converted to proper python type by `mapnik_value_to_python`
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
return mapnik::value_null();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_item(Container& container, index_type i, data_type const& v)
|
set_item(Container& container, index_type i, data_type const& v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,11 +75,11 @@ void export_featureset()
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> m.query_map_point(0, 10, 10)\n"
|
">>> m.query_map_point(0, 10, 10)\n"
|
||||||
"<mapnik2._mapnik2.Featureset object at 0x1004d2938>\n"
|
"<mapnik._mapnik.Featureset object at 0x1004d2938>\n"
|
||||||
">>> fs = m.query_map_point(0, 10, 10)\n"
|
">>> fs = m.query_map_point(0, 10, 10)\n"
|
||||||
">>> for f in fs.features:\n"
|
">>> for f in fs.features:\n"
|
||||||
">>> print f\n"
|
">>> print f\n"
|
||||||
"<mapnik2.Feature object at 0x105e64140>\n"
|
"<mapnik.Feature object at 0x105e64140>\n"
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/wkt/wkt_factory.hpp>
|
#include <mapnik/wkt/wkt_factory.hpp>
|
||||||
#include <mapnik/wkb.hpp>
|
#include <mapnik/wkb.hpp>
|
||||||
|
#include <mapnik/util/geometry_to_wkb.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -47,19 +48,47 @@ geometry_type const& getitem_impl(path_type & p, int key)
|
||||||
throw boost::python::error_already_set();
|
throw boost::python::error_already_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_wkt_impl(path_type& p, std::string const& wkt)
|
void add_wkt_impl(path_type& p, std::string const& wkt)
|
||||||
{
|
{
|
||||||
bool result = mapnik::from_wkt(wkt , p);
|
bool result = mapnik::from_wkt(wkt , p);
|
||||||
if (!result) throw std::runtime_error("Failed to parse WKT");
|
if (!result) throw std::runtime_error("Failed to parse WKT");
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_wkb_impl(path_type& p, std::string const& wkb)
|
void add_wkb_impl(path_type& p, std::string const& wkb)
|
||||||
{
|
{
|
||||||
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size(), true);
|
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<path_type> paths = boost::make_shared<path_type>();
|
||||||
|
bool result = mapnik::from_wkt(wkt, *paths);
|
||||||
|
if (!result) throw std::runtime_error("Failed to parse WKT");
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<path_type> from_wkb_impl(std::string const& wkb)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<path_type> paths = boost::make_shared<path_type>();
|
||||||
|
mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size(), true);
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* to_wkb( geometry_type const& geom)
|
||||||
|
{
|
||||||
|
mapnik::util::wkb_buffer_ptr wkb = mapnik::util::to_wkb(geom,mapnik::util::wkbXDR);
|
||||||
|
return
|
||||||
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
::PyBytes_FromStringAndSize
|
||||||
|
#else
|
||||||
|
::PyString_FromStringAndSize
|
||||||
|
#endif
|
||||||
|
((const char*)wkb->buffer(),wkb->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void export_geometry()
|
void export_geometry()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -78,15 +107,19 @@ void export_geometry()
|
||||||
.def("envelope",&geometry_type::envelope)
|
.def("envelope",&geometry_type::envelope)
|
||||||
// .def("__str__",&geometry_type::to_string)
|
// .def("__str__",&geometry_type::to_string)
|
||||||
.def("type",&geometry_type::type)
|
.def("type",&geometry_type::type)
|
||||||
.def("area",&geometry_type::area)
|
.def("to_wkb",&to_wkb)
|
||||||
// TODO add other geometry_type methods
|
// TODO add other geometry_type methods
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<path_type,boost::noncopyable>("Path")
|
class_<path_type, boost::shared_ptr<path_type>, boost::noncopyable>("Path")
|
||||||
.def("__getitem__", getitem_impl,return_value_policy<reference_existing_object>())
|
.def("__getitem__", getitem_impl,return_value_policy<reference_existing_object>())
|
||||||
.def("__len__", &path_type::size)
|
.def("__len__", &path_type::size)
|
||||||
|
.def("add_wkt",add_wkt_impl)
|
||||||
|
.def("add_wkb",add_wkb_impl)
|
||||||
.def("from_wkt",from_wkt_impl)
|
.def("from_wkt",from_wkt_impl)
|
||||||
.def("from_wkb",from_wkb_impl)
|
.def("from_wkb",from_wkb_impl)
|
||||||
|
.staticmethod("from_wkt")
|
||||||
|
.staticmethod("from_wkb")
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ void export_grid()
|
||||||
"Grid",
|
"Grid",
|
||||||
"This class represents a feature hitgrid.",
|
"This class represents a feature hitgrid.",
|
||||||
init<int,int,std::string,unsigned>(
|
init<int,int,std::string,unsigned>(
|
||||||
( arg("width"),arg("height"),arg("key")="__id__",arg("resolution")=1 ),
|
( boost::python::arg("width"), boost::python::arg("height"),boost::python::arg("key")="__id__", boost::python::arg("resolution")=1 ),
|
||||||
"Create a mapnik.Grid object\n"
|
"Create a mapnik.Grid object\n"
|
||||||
))
|
))
|
||||||
.def("painted",&painted)
|
.def("painted",&painted)
|
||||||
|
@ -54,7 +54,7 @@ void export_grid()
|
||||||
.def("height",&mapnik::grid::height)
|
.def("height",&mapnik::grid::height)
|
||||||
.def("view",&mapnik::grid::get_view)
|
.def("view",&mapnik::grid::get_view)
|
||||||
.def("encode",encode,
|
.def("encode",encode,
|
||||||
( arg("encoding")="utf",arg("features")=true,arg("resolution")=4 ),
|
( boost::python::arg("encoding")="utf", boost::python::arg("features")=true,boost::python::arg("resolution")=4 ),
|
||||||
"Encode the grid as as optimized json\n"
|
"Encode the grid as as optimized json\n"
|
||||||
)
|
)
|
||||||
.add_property("key",
|
.add_property("key",
|
||||||
|
|
|
@ -45,7 +45,7 @@ void export_grid_view()
|
||||||
.def("width",&mapnik::grid_view::width)
|
.def("width",&mapnik::grid_view::width)
|
||||||
.def("height",&mapnik::grid_view::height)
|
.def("height",&mapnik::grid_view::height)
|
||||||
.def("encode",encode,
|
.def("encode",encode,
|
||||||
( arg("encoding")="utf",arg("add_features")=true,arg("resolution")=4 ),
|
( boost::python::arg("encoding")="utf",boost::python::arg("add_features")=true,boost::python::arg("resolution")=4 ),
|
||||||
"Encode the grid as as optimized json\n"
|
"Encode the grid as as optimized json\n"
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
123
bindings/python/mapnik_label_collision_detector.cpp
Normal file
123
bindings/python/mapnik_label_collision_detector.cpp
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/python/module.hpp>
|
||||||
|
#include <boost/python/def.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
#include <mapnik/label_collision_detector.hpp>
|
||||||
|
#include <mapnik/map.hpp>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
using mapnik::label_collision_detector4;
|
||||||
|
using mapnik::box2d;
|
||||||
|
using mapnik::Map;
|
||||||
|
using boost::make_shared;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
boost::shared_ptr<label_collision_detector4>
|
||||||
|
create_label_collision_detector_from_extent(box2d<double> const &extent)
|
||||||
|
{
|
||||||
|
return make_shared<label_collision_detector4>(extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<label_collision_detector4>
|
||||||
|
create_label_collision_detector_from_map(Map const &m)
|
||||||
|
{
|
||||||
|
double buffer = m.buffer_size();
|
||||||
|
box2d<double> extent(-buffer, -buffer, m.width() + buffer, m.height() + buffer);
|
||||||
|
return make_shared<label_collision_detector4>(extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::python::list
|
||||||
|
make_label_boxes(boost::shared_ptr<label_collision_detector4> det)
|
||||||
|
{
|
||||||
|
boost::python::list boxes;
|
||||||
|
|
||||||
|
for (label_collision_detector4::query_iterator jtr = det->begin();
|
||||||
|
jtr != det->end(); ++jtr)
|
||||||
|
{
|
||||||
|
boxes.append<box2d<double> >(jtr->box);
|
||||||
|
}
|
||||||
|
|
||||||
|
return boxes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void export_label_collision_detector()
|
||||||
|
{
|
||||||
|
using namespace boost::python;
|
||||||
|
|
||||||
|
// for overload resolution
|
||||||
|
void (label_collision_detector4::*insert_box)(box2d<double> const &) = &label_collision_detector4::insert;
|
||||||
|
|
||||||
|
class_<label_collision_detector4, boost::shared_ptr<label_collision_detector4>, boost::noncopyable>
|
||||||
|
("LabelCollisionDetector",
|
||||||
|
"Object to detect collisions between labels, used in the rendering process.",
|
||||||
|
no_init)
|
||||||
|
|
||||||
|
.def("__init__", make_constructor(create_label_collision_detector_from_extent),
|
||||||
|
"Creates an empty collision detection object with a given extent. Note "
|
||||||
|
"that the constructor from Map objects is a sensible default and usually "
|
||||||
|
"what you want to do.\n"
|
||||||
|
"\n"
|
||||||
|
"Example:\n"
|
||||||
|
">>> m = Map(size_x, size_y)\n"
|
||||||
|
">>> buf_sz = m.buffer_size\n"
|
||||||
|
">>> extent = mapnik.Box2d(-buf_sz, -buf_sz, m.width + buf_sz, m.height + buf_sz)\n"
|
||||||
|
">>> detector = mapnik.LabelCollisionDetector(extent)")
|
||||||
|
|
||||||
|
.def("__init__", make_constructor(create_label_collision_detector_from_map),
|
||||||
|
"Creates an empty collision detection object matching the given Map object. "
|
||||||
|
"The created detector will have the same size, including the buffer, as the "
|
||||||
|
"map object. This is usually what you want to do.\n"
|
||||||
|
"\n"
|
||||||
|
"Example:\n"
|
||||||
|
">>> m = Map(size_x, size_y)\n"
|
||||||
|
">>> detector = mapnik.LabelCollisionDetector(m)")
|
||||||
|
|
||||||
|
.def("extent", &label_collision_detector4::extent, return_value_policy<copy_const_reference>(),
|
||||||
|
"Returns the total extent (bounding box) of all labels inside the detector.\n"
|
||||||
|
"\n"
|
||||||
|
"Example:\n"
|
||||||
|
">>> detector.extent()\n"
|
||||||
|
"Box2d(573.252589209,494.789179821,584.261023823,496.83610261)")
|
||||||
|
|
||||||
|
.def("boxes", &make_label_boxes,
|
||||||
|
"Returns a list of all the label boxes inside the detector.")
|
||||||
|
|
||||||
|
.def("insert", insert_box,
|
||||||
|
"Insert a 2d box into the collision detector. This can be used to ensure that "
|
||||||
|
"some space is left clear on the map for later overdrawing, for example by "
|
||||||
|
"non-Mapnik processes.\n"
|
||||||
|
"\n"
|
||||||
|
"Example:\n"
|
||||||
|
">>> m = Map(size_x, size_y)\n"
|
||||||
|
">>> detector = mapnik.LabelCollisionDetector(m)"
|
||||||
|
">>> detector.insert(mapnik.Box2d(196, 254, 291, 389))")
|
||||||
|
;
|
||||||
|
}
|
|
@ -119,6 +119,8 @@ struct map_pickle_suite : boost::python::pickle_suite
|
||||||
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
||||||
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
||||||
|
|
||||||
|
mapnik::parameters& (Map::*attr_nonconst)() = &Map::get_extra_attributes;
|
||||||
|
mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters;
|
||||||
|
|
||||||
mapnik::feature_type_style find_style (mapnik::Map const& m, std::string const& name)
|
mapnik::feature_type_style find_style (mapnik::Map const& m, std::string const& name)
|
||||||
{
|
{
|
||||||
|
@ -173,6 +175,7 @@ mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x
|
||||||
return m.query_map_point(idx, x, y);
|
return m.query_map_point(idx, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void export_map()
|
void export_map()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -449,7 +452,8 @@ void export_map()
|
||||||
"about the hit areas rendered on the map.\n"
|
"about the hit areas rendered on the map.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
.def("extra_attributes",&Map::get_extra_attributes,return_value_policy<copy_const_reference>(),"TODO")
|
.add_property("extra_attributes",make_function(attr_nonconst,return_value_policy<reference_existing_object>()),"TODO")
|
||||||
|
.add_property("parameters",make_function(params_nonconst,return_value_policy<reference_existing_object>()),"TODO")
|
||||||
|
|
||||||
.add_property("aspect_fix_mode",
|
.add_property("aspect_fix_mode",
|
||||||
&Map::get_aspect_fix_mode,
|
&Map::get_aspect_fix_mode,
|
||||||
|
|
|
@ -48,6 +48,6 @@ void export_palette ()
|
||||||
( arg("palette"), arg("type")),
|
( arg("palette"), arg("type")),
|
||||||
"Creates a new color palette from a file\n"
|
"Creates a new color palette from a file\n"
|
||||||
)*/
|
)*/
|
||||||
.def( "__init__", boost::python::make_constructor( &make_palette))
|
.def( "__init__", boost::python::make_constructor(make_palette))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,50 +19,26 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id: mapnik_parameters.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/params.hpp>
|
#include <mapnik/params.hpp>
|
||||||
|
#include <mapnik/unicode.hpp>
|
||||||
|
#include <mapnik/value.hpp>
|
||||||
|
|
||||||
using mapnik::parameter;
|
using mapnik::parameter;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
struct pickle_value : public boost::static_visitor<>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
pickle_value( boost::python::list vals):
|
|
||||||
vals_(vals) {}
|
|
||||||
|
|
||||||
void operator () ( int val )
|
|
||||||
{
|
|
||||||
vals_.append(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () ( double val )
|
|
||||||
{
|
|
||||||
vals_.append(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator () ( std::string val )
|
|
||||||
{
|
|
||||||
vals_.append(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
boost::python::list vals_;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct parameter_pickle_suite : boost::python::pickle_suite
|
struct parameter_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
getinitargs(const parameter& p)
|
getinitargs(const parameter& p)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
return boost::python::make_tuple(p.first,boost::get<std::string>(p.second));
|
return boost::python::make_tuple(p.first,p.second);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,11 +52,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
parameters::const_iterator pos=p.begin();
|
parameters::const_iterator pos=p.begin();
|
||||||
while(pos!=p.end())
|
while(pos!=p.end())
|
||||||
{
|
{
|
||||||
boost::python::list vals;
|
d[pos->first] = pos->second;
|
||||||
pickle_value serializer( vals );
|
|
||||||
mapnik::value_holder val = pos->second;
|
|
||||||
boost::apply_visitor( serializer, val );
|
|
||||||
d[pos->first] = vals[0];
|
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
return boost::python::make_tuple(d);
|
return boost::python::make_tuple(d);
|
||||||
|
@ -107,7 +79,9 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
extract<std::string> ex0(obj);
|
extract<std::string> ex0(obj);
|
||||||
extract<int> ex1(obj);
|
extract<int> ex1(obj);
|
||||||
extract<double> ex2(obj);
|
extract<double> ex2(obj);
|
||||||
|
extract<UnicodeString> ex3(obj);
|
||||||
|
|
||||||
|
// TODO - this is never hit - we need proper python string -> std::string to get invoked here
|
||||||
if (ex0.check())
|
if (ex0.check())
|
||||||
{
|
{
|
||||||
p[key] = ex0();
|
p[key] = ex0();
|
||||||
|
@ -120,72 +94,131 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
p[key] = ex2();
|
p[key] = ex2();
|
||||||
}
|
}
|
||||||
|
else if (ex3.check())
|
||||||
/*
|
{
|
||||||
extract_value serializer( p, key );
|
std::string buffer;
|
||||||
mapnik::value_holder val = extract<mapnik::value_holder>(d[key]);
|
mapnik::to_utf8(ex3(),buffer);
|
||||||
boost::apply_visitor( serializer, val );
|
p[key] = buffer;
|
||||||
*/
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::clog << "could not unpickle key: " << key << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::python::dict dict_params(parameters& p)
|
|
||||||
|
mapnik::value_holder get_params_by_key1(mapnik::parameters const& p, std::string const& key)
|
||||||
{
|
{
|
||||||
boost::python::dict d;
|
parameters::const_iterator pos = p.find(key);
|
||||||
parameters::const_iterator pos=p.begin();
|
if (pos != p.end())
|
||||||
while(pos!=p.end())
|
|
||||||
{
|
{
|
||||||
boost::python::list vals;
|
// will be auto-converted to proper python type by `mapnik_params_to_python`
|
||||||
pickle_value serializer( vals );
|
return pos->second;
|
||||||
mapnik::value_holder val = pos->second;
|
|
||||||
boost::apply_visitor( serializer, val );
|
|
||||||
d[pos->first] = vals[0];
|
|
||||||
++pos;
|
|
||||||
}
|
}
|
||||||
return d;
|
return mapnik::value_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::python::list list_params(parameters& p)
|
mapnik::value_holder get_params_by_key2(mapnik::parameters const& p, std::string const& key)
|
||||||
{
|
{
|
||||||
boost::python::list l;
|
parameters::const_iterator pos = p.find(key);
|
||||||
parameters::const_iterator pos=p.begin();
|
if (pos == p.end())
|
||||||
while(pos!=p.end())
|
|
||||||
{
|
{
|
||||||
boost::python::list vals;
|
PyErr_SetString(PyExc_KeyError, key.c_str());
|
||||||
pickle_value serializer( vals );
|
boost::python::throw_error_already_set();
|
||||||
mapnik::value_holder val = pos->second;
|
|
||||||
boost::apply_visitor( serializer, val );
|
|
||||||
l.append(boost::python::make_tuple(pos->first,vals[0]));
|
|
||||||
++pos;
|
|
||||||
}
|
}
|
||||||
return l;
|
// will be auto-converted to proper python type by `mapnik_params_to_python`
|
||||||
|
return pos->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::python::dict dict_param(parameter& p)
|
mapnik::parameter get_params_by_index(mapnik::parameters const& p, int index)
|
||||||
{
|
{
|
||||||
boost::python::dict d;
|
if (index < 0 || index > p.size())
|
||||||
d[p.first] = boost::get<std::string>(p.second);
|
{
|
||||||
return d;
|
PyErr_SetString(PyExc_IndexError, "Index is out of range");
|
||||||
|
throw boost::python::error_already_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::python::tuple tuple_param(parameter& p)
|
parameters::const_iterator itr = p.begin();
|
||||||
|
parameters::const_iterator end = p.end();
|
||||||
|
|
||||||
|
unsigned idx = 0;
|
||||||
|
while (itr != p.end())
|
||||||
{
|
{
|
||||||
return boost::python::make_tuple(p.first,boost::get<std::string>(p.second));
|
if (idx == index)
|
||||||
|
{
|
||||||
|
return *itr;
|
||||||
}
|
}
|
||||||
|
++idx;
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
PyErr_SetString(PyExc_IndexError, "Index is out of range");
|
||||||
|
throw boost::python::error_already_set();
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_parameter(mapnik::parameters & p, mapnik::parameter const& param)
|
||||||
|
{
|
||||||
|
p[param.first] = param.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapnik::value_holder get_param(mapnik::parameter const& p, int index)
|
||||||
|
{
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
return p.first;
|
||||||
|
}
|
||||||
|
else if (index == 1)
|
||||||
|
{
|
||||||
|
return p.second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PyErr_SetString(PyExc_IndexError, "Index is out of range");
|
||||||
|
throw boost::python::error_already_set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<mapnik::parameter> create_parameter_from_string(std::string const& key, std::string const& value)
|
||||||
|
{
|
||||||
|
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, int value)
|
||||||
|
{
|
||||||
|
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<mapnik::parameter> create_parameter_from_float(std::string const& key, double value)
|
||||||
|
{
|
||||||
|
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void export_parameters()
|
void export_parameters()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
class_<parameter>("Parameter",init<std::string,std::string>())
|
class_<parameter,boost::shared_ptr<parameter> >("Parameter",no_init)
|
||||||
|
.def("__init__", make_constructor(create_parameter_from_string),
|
||||||
|
"Create a mapnik.Parameter from a pair of values, the first being a string\n"
|
||||||
|
"and the second being either a string, and integer, or a float")
|
||||||
|
.def("__init__", make_constructor(create_parameter_from_int),
|
||||||
|
"Create a mapnik.Parameter from a pair of values, the first being a string\n"
|
||||||
|
"and the second being either a string, and integer, or a float")
|
||||||
|
.def("__init__", make_constructor(create_parameter_from_float),
|
||||||
|
"Create a mapnik.Parameter from a pair of values, the first being a string\n"
|
||||||
|
"and the second being either a string, and integer, or a float")
|
||||||
.def_pickle(parameter_pickle_suite())
|
.def_pickle(parameter_pickle_suite())
|
||||||
.def("as_dict",dict_param)
|
.def("__getitem__",get_param)
|
||||||
.def("as_tuple",tuple_param)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<parameters>("Parameters",init<>())
|
class_<parameters>("Parameters",init<>())
|
||||||
.def_pickle(parameters_pickle_suite())
|
.def_pickle(parameters_pickle_suite())
|
||||||
.def("as_dict",dict_params)
|
.def("get",get_params_by_key1)
|
||||||
.def("as_list",list_params)
|
.def("__getitem__",get_params_by_key2)
|
||||||
|
.def("__getitem__",get_params_by_index)
|
||||||
|
.def("__len__",¶meters::size)
|
||||||
|
.def("append",add_parameter)
|
||||||
|
.def("iteritems",iterator<parameters>())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ void export_view_transform();
|
||||||
void export_raster_colorizer();
|
void export_raster_colorizer();
|
||||||
void export_glyph_symbolizer();
|
void export_glyph_symbolizer();
|
||||||
void export_inmem_metawriter();
|
void export_inmem_metawriter();
|
||||||
|
void export_label_collision_detector();
|
||||||
|
|
||||||
#include <mapnik/version.hpp>
|
#include <mapnik/version.hpp>
|
||||||
#include <mapnik/value_error.hpp>
|
#include <mapnik/value_error.hpp>
|
||||||
|
@ -82,24 +83,13 @@ void export_inmem_metawriter();
|
||||||
#include <mapnik/value_error.hpp>
|
#include <mapnik/value_error.hpp>
|
||||||
#include <mapnik/save_map.hpp>
|
#include <mapnik/save_map.hpp>
|
||||||
#include "python_grid_utils.hpp"
|
#include "python_grid_utils.hpp"
|
||||||
|
#include "mapnik_value_converter.hpp"
|
||||||
|
|
||||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||||
#include <pycairo.h>
|
#include <pycairo.h>
|
||||||
static Pycairo_CAPI_t *Pycairo_CAPI;
|
static Pycairo_CAPI_t *Pycairo_CAPI;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace boost { namespace python {
|
|
||||||
|
|
||||||
struct mapnik_value_to_python
|
|
||||||
{
|
|
||||||
static PyObject* convert(mapnik::value const& v)
|
|
||||||
{
|
|
||||||
return boost::apply_visitor(value_converter(),v.base());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
|
|
||||||
void render(const mapnik::Map& map,
|
void render(const mapnik::Map& map,
|
||||||
mapnik::image_32& image,
|
mapnik::image_32& image,
|
||||||
double scale_factor = 1.0,
|
double scale_factor = 1.0,
|
||||||
|
@ -120,6 +110,28 @@ void render(const mapnik::Map& map,
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void render_with_detector(
|
||||||
|
const mapnik::Map &map,
|
||||||
|
mapnik::image_32 &image,
|
||||||
|
boost::shared_ptr<mapnik::label_collision_detector4> detector,
|
||||||
|
double scale_factor = 1.0,
|
||||||
|
unsigned offset_x = 0u,
|
||||||
|
unsigned offset_y = 0u)
|
||||||
|
{
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mapnik::agg_renderer<mapnik::image_32> ren(map,image,detector);
|
||||||
|
ren.apply();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
Py_BLOCK_THREADS
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
}
|
||||||
|
|
||||||
void render_layer2(const mapnik::Map& map,
|
void render_layer2(const mapnik::Map& map,
|
||||||
mapnik::image_32& image,
|
mapnik::image_32& image,
|
||||||
unsigned layer_idx)
|
unsigned layer_idx)
|
||||||
|
@ -319,15 +331,6 @@ unsigned mapnik_version()
|
||||||
return MAPNIK_VERSION;
|
return MAPNIK_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned mapnik_svn_revision()
|
|
||||||
{
|
|
||||||
#if defined(SVN_REVISION)
|
|
||||||
return SVN_REVISION;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// indicator for jpeg read/write support within libmapnik
|
// indicator for jpeg read/write support within libmapnik
|
||||||
bool has_jpeg()
|
bool has_jpeg()
|
||||||
{
|
{
|
||||||
|
@ -374,8 +377,9 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3)
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3)
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2)
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2)
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(render_overloads, render, 2, 5)
|
BOOST_PYTHON_FUNCTION_OVERLOADS(render_overloads, render, 2, 5)
|
||||||
|
BOOST_PYTHON_FUNCTION_OVERLOADS(render_with_detector_overloads, render_with_detector, 3, 6)
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE(_mapnik2)
|
BOOST_PYTHON_MODULE(_mapnik)
|
||||||
{
|
{
|
||||||
|
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -427,6 +431,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
export_raster_colorizer();
|
export_raster_colorizer();
|
||||||
export_glyph_symbolizer();
|
export_glyph_symbolizer();
|
||||||
export_inmem_metawriter();
|
export_inmem_metawriter();
|
||||||
|
export_label_collision_detector();
|
||||||
|
|
||||||
def("render_grid",&render_grid,
|
def("render_grid",&render_grid,
|
||||||
( arg("map"),
|
( arg("map"),
|
||||||
|
@ -503,6 +508,19 @@ BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
"\n"
|
"\n"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
def("render_with_detector", &render_with_detector, render_with_detector_overloads(
|
||||||
|
"\n"
|
||||||
|
"Render Map to an AGG image_32 using a pre-constructed detector.\n"
|
||||||
|
"\n"
|
||||||
|
"Usage:\n"
|
||||||
|
">>> from mapnik import Map, Image, LabelCollisionDetector, render_with_detector, load_map\n"
|
||||||
|
">>> m = Map(256,256)\n"
|
||||||
|
">>> load_map(m,'mapfile.xml')\n"
|
||||||
|
">>> im = Image(m.width,m.height)\n"
|
||||||
|
">>> detector = LabelCollisionDetector(m)\n"
|
||||||
|
">>> render_with_detector(m, im, detector)\n"
|
||||||
|
));
|
||||||
|
|
||||||
def("render_layer", &render_layer2,
|
def("render_layer", &render_layer2,
|
||||||
(arg("map"),arg("image"),args("layer"))
|
(arg("map"),arg("image"),args("layer"))
|
||||||
);
|
);
|
||||||
|
@ -606,12 +624,12 @@ BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
|
|
||||||
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
|
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
|
||||||
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
|
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
|
||||||
def("mapnik_svn_revision", &mapnik_svn_revision,"Get the Mapnik svn revision");
|
|
||||||
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
|
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
|
||||||
def("has_cairo", &has_cairo, "Get cairo library status");
|
def("has_cairo", &has_cairo, "Get cairo library status");
|
||||||
def("has_pycairo", &has_pycairo, "Get pycairo module status");
|
def("has_pycairo", &has_pycairo, "Get pycairo module status");
|
||||||
|
|
||||||
register_ptr_to_python<mapnik::expression_ptr>();
|
register_ptr_to_python<mapnik::expression_ptr>();
|
||||||
register_ptr_to_python<mapnik::path_expression_ptr>();
|
register_ptr_to_python<mapnik::path_expression_ptr>();
|
||||||
|
to_python_converter<mapnik::value_holder,mapnik_param_to_python>();
|
||||||
to_python_converter<mapnik::value,mapnik_value_to_python>();
|
to_python_converter<mapnik::value,mapnik_value_to_python>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ void export_raster_colorizer()
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
||||||
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
|
">>> colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, default_color)\n"
|
||||||
">>> colorizer.add_stop(100)\n"
|
">>> colorizer.add_stop(100)\n"
|
||||||
)
|
)
|
||||||
.def("add_stop", add_stop3,
|
.def("add_stop", add_stop3,
|
||||||
|
@ -119,7 +119,7 @@ void export_raster_colorizer()
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
||||||
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
|
">>> colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, default_color)\n"
|
||||||
">>> colorizer.add_stop(100, mapnik.Color(\"#123456\"))\n"
|
">>> colorizer.add_stop(100, mapnik.Color(\"#123456\"))\n"
|
||||||
)
|
)
|
||||||
.def("add_stop", add_stop4,
|
.def("add_stop", add_stop4,
|
||||||
|
@ -128,8 +128,8 @@ void export_raster_colorizer()
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
||||||
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
|
">>> colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, default_color)\n"
|
||||||
">>> colorizer.add_stop(100, mapnik2.COLORIZER_EXACT)\n"
|
">>> colorizer.add_stop(100, mapnik.COLORIZER_EXACT)\n"
|
||||||
)
|
)
|
||||||
.def("add_stop", add_stop5,
|
.def("add_stop", add_stop5,
|
||||||
(arg("value")),
|
(arg("value")),
|
||||||
|
@ -137,7 +137,7 @@ void export_raster_colorizer()
|
||||||
"\n"
|
"\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
">>> default_color = mapnik.Color(\"#0044cc\")\n"
|
||||||
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
|
">>> colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, default_color)\n"
|
||||||
">>> colorizer.add_stop(100, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#112233\"))\n"
|
">>> colorizer.add_stop(100, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#112233\"))\n"
|
||||||
)
|
)
|
||||||
.def("get_color", &raster_colorizer::get_color,
|
.def("get_color", &raster_colorizer::get_color,
|
||||||
|
@ -146,8 +146,8 @@ void export_raster_colorizer()
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> colorizer = mapnik.RasterColorizer()\n"
|
">>> colorizer = mapnik.RasterColorizer()\n"
|
||||||
">>> color = mapnik.Color(\"#0044cc\")\n"
|
">>> color = mapnik.Color(\"#0044cc\")\n"
|
||||||
">>> colorizer.add_stop(0, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#000000\"))\n"
|
">>> colorizer.add_stop(0, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#000000\"))\n"
|
||||||
">>> colorizer.add_stop(100, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#0E0A06\"))\n"
|
">>> colorizer.add_stop(100, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#0E0A06\"))\n"
|
||||||
">>> colorizer.get_color(50)\n"
|
">>> colorizer.get_color(50)\n"
|
||||||
"Color('#070503')\n"
|
"Color('#070503')\n"
|
||||||
)
|
)
|
||||||
|
|
|
@ -148,8 +148,8 @@ struct rule_pickle_suite : boost::python::pickle_suite
|
||||||
extract_symbolizer serializer( r );
|
extract_symbolizer serializer( r );
|
||||||
for (int i=0;i<len(syms);++i)
|
for (int i=0;i<len(syms);++i)
|
||||||
{
|
{
|
||||||
symbolizer symbol = extract<symbolizer>(syms[i]);
|
//symbolizer symbol = extract<symbolizer>(syms[i]);
|
||||||
boost::apply_visitor( serializer, symbol );
|
//boost::apply_visitor( serializer, symbol );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ void export_style()
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
">>> for r in m.find_style('style 1').rules:\n"
|
">>> for r in m.find_style('style 1').rules:\n"
|
||||||
">>> print r\n"
|
">>> print r\n"
|
||||||
"<mapnik2._mapnik2.Rule object at 0x100549910>\n"
|
"<mapnik._mapnik.Rule object at 0x100549910>\n"
|
||||||
"<mapnik2._mapnik2.Rule object at 0x100549980>\n"
|
"<mapnik._mapnik.Rule object at 0x100549980>\n"
|
||||||
)
|
)
|
||||||
.add_property("filter_mode",
|
.add_property("filter_mode",
|
||||||
&feature_type_style::get_filter_mode,
|
&feature_type_style::get_filter_mode,
|
||||||
|
|
|
@ -43,7 +43,7 @@ template <class T>
|
||||||
void set_svg_transform(T& symbolizer, std::string const& transform_wkt)
|
void set_svg_transform(T& symbolizer, std::string const& transform_wkt)
|
||||||
{
|
{
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
if (!mapnik::svg::parse_transform(transform_wkt, tr))
|
if (!mapnik::svg::parse_transform(transform_wkt.c_str(), tr))
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Could not parse transform from '" << transform_wkt << "', expected string like: 'matrix(1, 0, 0, 1, 0, 0)'";
|
ss << "Could not parse transform from '" << transform_wkt << "', expected string like: 'matrix(1, 0, 0, 1, 0, 0)'";
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <boost/implicit_cast.hpp>
|
#include <boost/implicit_cast.hpp>
|
||||||
|
|
||||||
namespace boost { namespace python {
|
namespace boost { namespace python {
|
||||||
|
|
||||||
struct value_converter : public boost::static_visitor<PyObject*>
|
struct value_converter : public boost::static_visitor<PyObject*>
|
||||||
{
|
{
|
||||||
PyObject * operator() (int val) const
|
PyObject * operator() (int val) const
|
||||||
|
@ -48,6 +49,13 @@ namespace boost { namespace python {
|
||||||
return ::PyBool_FromLong(val);
|
return ::PyBool_FromLong(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject * operator() (std::string const& s) const
|
||||||
|
{
|
||||||
|
PyObject *obj = Py_None;
|
||||||
|
obj = ::PyUnicode_DecodeUTF8(s.c_str(),implicit_cast<ssize_t>(s.length()),0);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject * operator() (UnicodeString const& s) const
|
PyObject * operator() (UnicodeString const& s) const
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
@ -63,6 +71,25 @@ namespace boost { namespace python {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct mapnik_value_to_python
|
||||||
|
{
|
||||||
|
static PyObject* convert(mapnik::value const& v)
|
||||||
|
{
|
||||||
|
return boost::apply_visitor(value_converter(),v.base());
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mapnik_param_to_python
|
||||||
|
{
|
||||||
|
static PyObject* convert(mapnik::value_holder const& v)
|
||||||
|
{
|
||||||
|
return boost::apply_visitor(value_converter(),v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ static void grid2utf(T const& grid_type,
|
||||||
typename T::key_type::const_iterator key_pos;
|
typename T::key_type::const_iterator key_pos;
|
||||||
typename T::feature_key_type::const_iterator feature_pos;
|
typename T::feature_key_type::const_iterator feature_pos;
|
||||||
// start counting at utf8 codepoint 32, aka space character
|
// start counting at utf8 codepoint 32, aka space character
|
||||||
uint16_t codepoint = 32;
|
boost::uint16_t codepoint = 32;
|
||||||
|
|
||||||
unsigned array_size = data.width();
|
unsigned array_size = data.width();
|
||||||
for (unsigned y = 0; y < data.height(); ++y)
|
for (unsigned y = 0; y < data.height(); ++y)
|
||||||
{
|
{
|
||||||
uint16_t idx = 0;
|
boost::uint16_t idx = 0;
|
||||||
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
|
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
|
||||||
typename T::value_type const* row = data.getRow(y);
|
typename T::value_type const* row = data.getRow(y);
|
||||||
for (unsigned x = 0; x < data.width(); ++x)
|
for (unsigned x = 0; x < data.width(); ++x)
|
||||||
|
@ -103,13 +103,13 @@ static void grid2utf(T const& grid_type,
|
||||||
typename T::key_type::const_iterator key_pos;
|
typename T::key_type::const_iterator key_pos;
|
||||||
typename T::feature_key_type::const_iterator feature_pos;
|
typename T::feature_key_type::const_iterator feature_pos;
|
||||||
// start counting at utf8 codepoint 32, aka space character
|
// start counting at utf8 codepoint 32, aka space character
|
||||||
uint16_t codepoint = 32;
|
boost::uint16_t codepoint = 32;
|
||||||
|
|
||||||
// TODO - use double?
|
// TODO - use double?
|
||||||
unsigned array_size = static_cast<unsigned int>(grid_type.width()/resolution);
|
unsigned array_size = static_cast<unsigned int>(grid_type.width()/resolution);
|
||||||
for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
|
for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
|
||||||
{
|
{
|
||||||
uint16_t idx = 0;
|
boost::uint16_t idx = 0;
|
||||||
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
|
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
|
||||||
mapnik::grid::value_type const* row = grid_type.getRow(y);
|
mapnik::grid::value_type const* row = grid_type.getRow(y);
|
||||||
for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
|
for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
|
||||||
|
|
|
@ -41,7 +41,7 @@ if env['HAS_CAIRO']:
|
||||||
|
|
||||||
libraries = copy(env['LIBMAPNIK_LIBS'])
|
libraries = copy(env['LIBMAPNIK_LIBS'])
|
||||||
boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']
|
boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']
|
||||||
libraries.extend([boost_program_options,'mapnik2'])
|
libraries.extend([boost_program_options,'mapnik'])
|
||||||
|
|
||||||
rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"])
|
rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"])
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -43,7 +43,7 @@ int main ( int argc , char** argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik2\n";
|
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik\n";
|
||||||
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
|
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ int main ( int argc , char** argv)
|
||||||
provpoly_style.add_rule(provpoly_rule_on);
|
provpoly_style.add_rule(provpoly_rule_on);
|
||||||
|
|
||||||
rule provpoly_rule_qc;
|
rule provpoly_rule_qc;
|
||||||
provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'"));
|
provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'"));
|
||||||
provpoly_rule_qc.append(polygon_symbolizer(color(217, 235, 203)));
|
provpoly_rule_qc.append(polygon_symbolizer(color(217, 235, 203)));
|
||||||
provpoly_style.add_rule(provpoly_rule_qc);
|
provpoly_style.add_rule(provpoly_rule_qc);
|
||||||
|
|
||||||
|
@ -253,10 +253,13 @@ int main ( int argc , char** argv)
|
||||||
save_to_file<image_data_32>(buf.data(),"demo.jpg","jpeg");
|
save_to_file<image_data_32>(buf.data(),"demo.jpg","jpeg");
|
||||||
save_to_file<image_data_32>(buf.data(),"demo.png","png");
|
save_to_file<image_data_32>(buf.data(),"demo.png","png");
|
||||||
save_to_file<image_data_32>(buf.data(),"demo256.png","png256");
|
save_to_file<image_data_32>(buf.data(),"demo256.png","png256");
|
||||||
|
save_to_file<image_data_32>(buf.data(),"demo.tif","tiff");
|
||||||
|
|
||||||
std::cout << "Three maps have been rendered using AGG in the current directory:\n"
|
std::cout << "Three maps have been rendered using AGG in the current directory:\n"
|
||||||
"- demo.jpg\n"
|
"- demo.jpg\n"
|
||||||
"- demo.png\n"
|
"- demo.png\n"
|
||||||
"- demo256.png\n"
|
"- demo256.png\n"
|
||||||
|
"- demo.tif\n"
|
||||||
"Have a look!\n";
|
"Have a look!\n";
|
||||||
|
|
||||||
#if defined(HAVE_CAIRO)
|
#if defined(HAVE_CAIRO)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import mapnik2
|
import mapnik
|
||||||
except:
|
except:
|
||||||
print '\n\nThe mapnik library and python bindings must have been compiled and \
|
print '\n\nThe mapnik library and python bindings must have been compiled and \
|
||||||
installed successfully before running this script.\n\n'
|
installed successfully before running this script.\n\n'
|
||||||
|
@ -41,11 +41,11 @@ except ImportError:
|
||||||
# Instanciate a map, giving it a width and height. Remember: the word "map" is
|
# Instanciate a map, giving it a width and height. Remember: the word "map" is
|
||||||
# reserved in Python! :)
|
# reserved in Python! :)
|
||||||
|
|
||||||
m = mapnik2.Map(800,600,"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs")
|
m = mapnik.Map(800,600,"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs")
|
||||||
|
|
||||||
# Set its background colour. More on colours later ...
|
# Set its background colour. More on colours later ...
|
||||||
|
|
||||||
m.background = mapnik2.Color('white')
|
m.background = mapnik.Color('white')
|
||||||
|
|
||||||
# Now we can start adding layers, in stacking order (i.e. bottom layer first)
|
# Now we can start adding layers, in stacking order (i.e. bottom layer first)
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ m.background = mapnik2.Color('white')
|
||||||
# password='mypassword'
|
# password='mypassword'
|
||||||
# table= TODO
|
# table= TODO
|
||||||
|
|
||||||
provpoly_lyr = mapnik2.Layer('Provinces')
|
provpoly_lyr = mapnik.Layer('Provinces')
|
||||||
provpoly_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
provpoly_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
provpoly_lyr.datasource = mapnik2.Shapefile(file='../data/boundaries', encoding='latin1')
|
provpoly_lyr.datasource = mapnik.Shapefile(file='../data/boundaries', encoding='latin1')
|
||||||
|
|
||||||
# We then define a style for the layer. A layer can have one or many styles.
|
# We then define a style for the layer. A layer can have one or many styles.
|
||||||
# Styles are named, so they can be shared across different layers.
|
# Styles are named, so they can be shared across different layers.
|
||||||
|
@ -78,18 +78,18 @@ provpoly_lyr.datasource = mapnik2.Shapefile(file='../data/boundaries', encoding=
|
||||||
# multiple styles in one layer is the same has having multiple layers.
|
# multiple styles in one layer is the same has having multiple layers.
|
||||||
# The paradigm is useful mostly as a convenience.
|
# The paradigm is useful mostly as a convenience.
|
||||||
|
|
||||||
provpoly_style = mapnik2.Style()
|
provpoly_style = mapnik.Style()
|
||||||
|
|
||||||
# A Style needs one or more rules. A rule will normally consist of a filter
|
# A Style needs one or more rules. A rule will normally consist of a filter
|
||||||
# for feature selection, and one or more symbolizers.
|
# for feature selection, and one or more symbolizers.
|
||||||
|
|
||||||
provpoly_rule_on = mapnik2.Rule()
|
provpoly_rule_on = mapnik.Rule()
|
||||||
|
|
||||||
# A Expression() allows the selection of features to which the symbology will
|
# A Expression() allows the selection of features to which the symbology will
|
||||||
# be applied. More on Mapnik expressions can be found in Tutorial #2.
|
# be applied. More on Mapnik expressions can be found in Tutorial #2.
|
||||||
# A given feature can only match one filter per rule per style.
|
# A given feature can only match one filter per rule per style.
|
||||||
|
|
||||||
provpoly_rule_on.filter = mapnik2.Expression("[NAME_EN] = 'Ontario'")
|
provpoly_rule_on.filter = mapnik.Expression("[NAME_EN] = 'Ontario'")
|
||||||
|
|
||||||
# Here a symbolizer is defined. Available are:
|
# Here a symbolizer is defined. Available are:
|
||||||
# - LineSymbolizer(Color(),<width>)
|
# - LineSymbolizer(Color(),<width>)
|
||||||
|
@ -103,12 +103,12 @@ provpoly_rule_on.filter = mapnik2.Expression("[NAME_EN] = 'Ontario'")
|
||||||
# - Color(<string>) where <string> will be something like '#00FF00'
|
# - Color(<string>) where <string> will be something like '#00FF00'
|
||||||
# or '#0f0' or 'green'
|
# or '#0f0' or 'green'
|
||||||
|
|
||||||
provpoly_rule_on.symbols.append(mapnik2.PolygonSymbolizer(mapnik2.Color(250, 190, 183)))
|
provpoly_rule_on.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color(250, 190, 183)))
|
||||||
provpoly_style.rules.append(provpoly_rule_on)
|
provpoly_style.rules.append(provpoly_rule_on)
|
||||||
|
|
||||||
provpoly_rule_qc = mapnik2.Rule()
|
provpoly_rule_qc = mapnik.Rule()
|
||||||
provpoly_rule_qc.filter = mapnik2.Expression("[NOM_FR] = 'Québec'")
|
provpoly_rule_qc.filter = mapnik.Expression("[NOM_FR] = 'Québec'")
|
||||||
provpoly_rule_qc.symbols.append(mapnik2.PolygonSymbolizer(mapnik2.Color(217, 235, 203)))
|
provpoly_rule_qc.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color(217, 235, 203)))
|
||||||
provpoly_style.rules.append(provpoly_rule_qc)
|
provpoly_style.rules.append(provpoly_rule_qc)
|
||||||
|
|
||||||
# Add the style to the map, giving it a name. This is the name that will be
|
# Add the style to the map, giving it a name. This is the name that will be
|
||||||
|
@ -131,14 +131,14 @@ m.layers.append(provpoly_lyr)
|
||||||
|
|
||||||
# A simple example ...
|
# A simple example ...
|
||||||
|
|
||||||
qcdrain_lyr = mapnik2.Layer('Quebec Hydrography')
|
qcdrain_lyr = mapnik.Layer('Quebec Hydrography')
|
||||||
qcdrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
qcdrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
qcdrain_lyr.datasource = mapnik2.Shapefile(file='../data/qcdrainage')
|
qcdrain_lyr.datasource = mapnik.Shapefile(file='../data/qcdrainage')
|
||||||
|
|
||||||
qcdrain_style = mapnik2.Style()
|
qcdrain_style = mapnik.Style()
|
||||||
qcdrain_rule = mapnik2.Rule()
|
qcdrain_rule = mapnik.Rule()
|
||||||
qcdrain_rule.filter = mapnik2.Expression('[HYC] = 8')
|
qcdrain_rule.filter = mapnik.Expression('[HYC] = 8')
|
||||||
qcdrain_rule.symbols.append(mapnik2.PolygonSymbolizer(mapnik2.Color(153, 204, 255)))
|
qcdrain_rule.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color(153, 204, 255)))
|
||||||
qcdrain_style.rules.append(qcdrain_rule)
|
qcdrain_style.rules.append(qcdrain_rule)
|
||||||
|
|
||||||
m.append_style('drainage', qcdrain_style)
|
m.append_style('drainage', qcdrain_style)
|
||||||
|
@ -149,31 +149,31 @@ m.layers.append(qcdrain_lyr)
|
||||||
# attributes, and same desired style), so we're going to
|
# attributes, and same desired style), so we're going to
|
||||||
# re-use the style defined in the above layer for the next one.
|
# re-use the style defined in the above layer for the next one.
|
||||||
|
|
||||||
ondrain_lyr = mapnik2.Layer('Ontario Hydrography')
|
ondrain_lyr = mapnik.Layer('Ontario Hydrography')
|
||||||
ondrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
ondrain_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
ondrain_lyr.datasource = mapnik2.Shapefile(file='../data/ontdrainage')
|
ondrain_lyr.datasource = mapnik.Shapefile(file='../data/ontdrainage')
|
||||||
|
|
||||||
ondrain_lyr.styles.append('drainage')
|
ondrain_lyr.styles.append('drainage')
|
||||||
m.layers.append(ondrain_lyr)
|
m.layers.append(ondrain_lyr)
|
||||||
|
|
||||||
# Provincial boundaries
|
# Provincial boundaries
|
||||||
|
|
||||||
provlines_lyr = mapnik2.Layer('Provincial borders')
|
provlines_lyr = mapnik.Layer('Provincial borders')
|
||||||
provlines_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
provlines_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
provlines_lyr.datasource = mapnik2.Shapefile(file='../data/boundaries_l')
|
provlines_lyr.datasource = mapnik.Shapefile(file='../data/boundaries_l')
|
||||||
|
|
||||||
# Here we define a "dash dot dot dash" pattern for the provincial boundaries.
|
# Here we define a "dash dot dot dash" pattern for the provincial boundaries.
|
||||||
|
|
||||||
provlines_stk = mapnik2.Stroke()
|
provlines_stk = mapnik.Stroke()
|
||||||
provlines_stk.add_dash(8, 4)
|
provlines_stk.add_dash(8, 4)
|
||||||
provlines_stk.add_dash(2, 2)
|
provlines_stk.add_dash(2, 2)
|
||||||
provlines_stk.add_dash(2, 2)
|
provlines_stk.add_dash(2, 2)
|
||||||
provlines_stk.color = mapnik2.Color('black')
|
provlines_stk.color = mapnik.Color('black')
|
||||||
provlines_stk.width = 1.0
|
provlines_stk.width = 1.0
|
||||||
|
|
||||||
provlines_style = mapnik2.Style()
|
provlines_style = mapnik.Style()
|
||||||
provlines_rule = mapnik2.Rule()
|
provlines_rule = mapnik.Rule()
|
||||||
provlines_rule.symbols.append(mapnik2.LineSymbolizer(provlines_stk))
|
provlines_rule.symbols.append(mapnik.LineSymbolizer(provlines_stk))
|
||||||
provlines_style.rules.append(provlines_rule)
|
provlines_style.rules.append(provlines_rule)
|
||||||
|
|
||||||
m.append_style('provlines', provlines_style)
|
m.append_style('provlines', provlines_style)
|
||||||
|
@ -182,22 +182,22 @@ m.layers.append(provlines_lyr)
|
||||||
|
|
||||||
# Roads 3 and 4 (The "grey" roads)
|
# Roads 3 and 4 (The "grey" roads)
|
||||||
|
|
||||||
roads34_lyr = mapnik2.Layer('Roads')
|
roads34_lyr = mapnik.Layer('Roads')
|
||||||
roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
# create roads datasource (we're going to re-use it later)
|
# create roads datasource (we're going to re-use it later)
|
||||||
|
|
||||||
roads34_lyr.datasource = mapnik2.Shapefile(file='../data/roads')
|
roads34_lyr.datasource = mapnik.Shapefile(file='../data/roads')
|
||||||
|
|
||||||
roads34_style = mapnik2.Style()
|
roads34_style = mapnik.Style()
|
||||||
roads34_rule = mapnik2.Rule()
|
roads34_rule = mapnik.Rule()
|
||||||
roads34_rule.filter = mapnik2.Expression('([CLASS] = 3) or ([CLASS] = 4)')
|
roads34_rule.filter = mapnik.Expression('([CLASS] = 3) or ([CLASS] = 4)')
|
||||||
|
|
||||||
# With lines of a certain width, you can control how the ends
|
# With lines of a certain width, you can control how the ends
|
||||||
# are closed off using line_cap as below.
|
# are closed off using line_cap as below.
|
||||||
|
|
||||||
roads34_rule_stk = mapnik2.Stroke()
|
roads34_rule_stk = mapnik.Stroke()
|
||||||
roads34_rule_stk.color = mapnik2.Color(171,158,137)
|
roads34_rule_stk.color = mapnik.Color(171,158,137)
|
||||||
roads34_rule_stk.line_cap = mapnik2.line_cap.ROUND_CAP
|
roads34_rule_stk.line_cap = mapnik.line_cap.ROUND_CAP
|
||||||
|
|
||||||
# Available options are:
|
# Available options are:
|
||||||
# line_cap: BUTT_CAP, SQUARE_CAP, ROUND_CAP
|
# line_cap: BUTT_CAP, SQUARE_CAP, ROUND_CAP
|
||||||
|
@ -207,7 +207,7 @@ roads34_rule_stk.line_cap = mapnik2.line_cap.ROUND_CAP
|
||||||
# can be set to a numerical value.
|
# can be set to a numerical value.
|
||||||
|
|
||||||
roads34_rule_stk.width = 2.0
|
roads34_rule_stk.width = 2.0
|
||||||
roads34_rule.symbols.append(mapnik2.LineSymbolizer(roads34_rule_stk))
|
roads34_rule.symbols.append(mapnik.LineSymbolizer(roads34_rule_stk))
|
||||||
roads34_style.rules.append(roads34_rule)
|
roads34_style.rules.append(roads34_rule)
|
||||||
|
|
||||||
m.append_style('smallroads', roads34_style)
|
m.append_style('smallroads', roads34_style)
|
||||||
|
@ -216,31 +216,31 @@ m.layers.append(roads34_lyr)
|
||||||
|
|
||||||
# Roads 2 (The thin yellow ones)
|
# Roads 2 (The thin yellow ones)
|
||||||
|
|
||||||
roads2_lyr = mapnik2.Layer('Roads')
|
roads2_lyr = mapnik.Layer('Roads')
|
||||||
roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
# Just get a copy from roads34_lyr
|
# Just get a copy from roads34_lyr
|
||||||
roads2_lyr.datasource = roads34_lyr.datasource
|
roads2_lyr.datasource = roads34_lyr.datasource
|
||||||
|
|
||||||
roads2_style_1 = mapnik2.Style()
|
roads2_style_1 = mapnik.Style()
|
||||||
roads2_rule_1 = mapnik2.Rule()
|
roads2_rule_1 = mapnik.Rule()
|
||||||
roads2_rule_1.filter = mapnik2.Expression('[CLASS] = 2')
|
roads2_rule_1.filter = mapnik.Expression('[CLASS] = 2')
|
||||||
roads2_rule_stk_1 = mapnik2.Stroke()
|
roads2_rule_stk_1 = mapnik.Stroke()
|
||||||
roads2_rule_stk_1.color = mapnik2.Color(171,158,137)
|
roads2_rule_stk_1.color = mapnik.Color(171,158,137)
|
||||||
roads2_rule_stk_1.line_cap = mapnik2.line_cap.ROUND_CAP
|
roads2_rule_stk_1.line_cap = mapnik.line_cap.ROUND_CAP
|
||||||
roads2_rule_stk_1.width = 4.0
|
roads2_rule_stk_1.width = 4.0
|
||||||
roads2_rule_1.symbols.append(mapnik2.LineSymbolizer(roads2_rule_stk_1))
|
roads2_rule_1.symbols.append(mapnik.LineSymbolizer(roads2_rule_stk_1))
|
||||||
roads2_style_1.rules.append(roads2_rule_1)
|
roads2_style_1.rules.append(roads2_rule_1)
|
||||||
|
|
||||||
m.append_style('road-border', roads2_style_1)
|
m.append_style('road-border', roads2_style_1)
|
||||||
|
|
||||||
roads2_style_2 = mapnik2.Style()
|
roads2_style_2 = mapnik.Style()
|
||||||
roads2_rule_2 = mapnik2.Rule()
|
roads2_rule_2 = mapnik.Rule()
|
||||||
roads2_rule_2.filter = mapnik2.Expression('[CLASS] = 2')
|
roads2_rule_2.filter = mapnik.Expression('[CLASS] = 2')
|
||||||
roads2_rule_stk_2 = mapnik2.Stroke()
|
roads2_rule_stk_2 = mapnik.Stroke()
|
||||||
roads2_rule_stk_2.color = mapnik2.Color(255,250,115)
|
roads2_rule_stk_2.color = mapnik.Color(255,250,115)
|
||||||
roads2_rule_stk_2.line_cap = mapnik2.line_cap.ROUND_CAP
|
roads2_rule_stk_2.line_cap = mapnik.line_cap.ROUND_CAP
|
||||||
roads2_rule_stk_2.width = 2.0
|
roads2_rule_stk_2.width = 2.0
|
||||||
roads2_rule_2.symbols.append(mapnik2.LineSymbolizer(roads2_rule_stk_2))
|
roads2_rule_2.symbols.append(mapnik.LineSymbolizer(roads2_rule_stk_2))
|
||||||
roads2_style_2.rules.append(roads2_rule_2)
|
roads2_style_2.rules.append(roads2_rule_2)
|
||||||
|
|
||||||
m.append_style('road-fill', roads2_style_2)
|
m.append_style('road-fill', roads2_style_2)
|
||||||
|
@ -252,29 +252,29 @@ m.layers.append(roads2_lyr)
|
||||||
|
|
||||||
# Roads 1 (The big orange ones, the highways)
|
# Roads 1 (The big orange ones, the highways)
|
||||||
|
|
||||||
roads1_lyr = mapnik2.Layer('Roads')
|
roads1_lyr = mapnik.Layer('Roads')
|
||||||
roads1_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
roads1_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
roads1_lyr.datasource = roads34_lyr.datasource
|
roads1_lyr.datasource = roads34_lyr.datasource
|
||||||
|
|
||||||
roads1_style_1 = mapnik2.Style()
|
roads1_style_1 = mapnik.Style()
|
||||||
roads1_rule_1 = mapnik2.Rule()
|
roads1_rule_1 = mapnik.Rule()
|
||||||
roads1_rule_1.filter = mapnik2.Expression('[CLASS] = 1')
|
roads1_rule_1.filter = mapnik.Expression('[CLASS] = 1')
|
||||||
roads1_rule_stk_1 = mapnik2.Stroke()
|
roads1_rule_stk_1 = mapnik.Stroke()
|
||||||
roads1_rule_stk_1.color = mapnik2.Color(188,149,28)
|
roads1_rule_stk_1.color = mapnik.Color(188,149,28)
|
||||||
roads1_rule_stk_1.line_cap = mapnik2.line_cap.ROUND_CAP
|
roads1_rule_stk_1.line_cap = mapnik.line_cap.ROUND_CAP
|
||||||
roads1_rule_stk_1.width = 7.0
|
roads1_rule_stk_1.width = 7.0
|
||||||
roads1_rule_1.symbols.append(mapnik2.LineSymbolizer(roads1_rule_stk_1))
|
roads1_rule_1.symbols.append(mapnik.LineSymbolizer(roads1_rule_stk_1))
|
||||||
roads1_style_1.rules.append(roads1_rule_1)
|
roads1_style_1.rules.append(roads1_rule_1)
|
||||||
m.append_style('highway-border', roads1_style_1)
|
m.append_style('highway-border', roads1_style_1)
|
||||||
|
|
||||||
roads1_style_2 = mapnik2.Style()
|
roads1_style_2 = mapnik.Style()
|
||||||
roads1_rule_2 = mapnik2.Rule()
|
roads1_rule_2 = mapnik.Rule()
|
||||||
roads1_rule_2.filter = mapnik2.Expression('[CLASS] = 1')
|
roads1_rule_2.filter = mapnik.Expression('[CLASS] = 1')
|
||||||
roads1_rule_stk_2 = mapnik2.Stroke()
|
roads1_rule_stk_2 = mapnik.Stroke()
|
||||||
roads1_rule_stk_2.color = mapnik2.Color(242,191,36)
|
roads1_rule_stk_2.color = mapnik.Color(242,191,36)
|
||||||
roads1_rule_stk_2.line_cap = mapnik2.line_cap.ROUND_CAP
|
roads1_rule_stk_2.line_cap = mapnik.line_cap.ROUND_CAP
|
||||||
roads1_rule_stk_2.width = 5.0
|
roads1_rule_stk_2.width = 5.0
|
||||||
roads1_rule_2.symbols.append(mapnik2.LineSymbolizer(roads1_rule_stk_2))
|
roads1_rule_2.symbols.append(mapnik.LineSymbolizer(roads1_rule_stk_2))
|
||||||
roads1_style_2.rules.append(roads1_rule_2)
|
roads1_style_2.rules.append(roads1_rule_2)
|
||||||
|
|
||||||
m.append_style('highway-fill', roads1_style_2)
|
m.append_style('highway-fill', roads1_style_2)
|
||||||
|
@ -286,25 +286,25 @@ m.layers.append(roads1_lyr)
|
||||||
|
|
||||||
# Populated Places
|
# Populated Places
|
||||||
|
|
||||||
popplaces_lyr = mapnik2.Layer('Populated Places')
|
popplaces_lyr = mapnik.Layer('Populated Places')
|
||||||
popplaces_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
popplaces_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
|
||||||
popplaces_lyr.datasource = mapnik2.Shapefile(file='../data/popplaces',encoding='latin1')
|
popplaces_lyr.datasource = mapnik.Shapefile(file='../data/popplaces',encoding='latin1')
|
||||||
|
|
||||||
popplaces_style = mapnik2.Style()
|
popplaces_style = mapnik.Style()
|
||||||
popplaces_rule = mapnik2.Rule()
|
popplaces_rule = mapnik.Rule()
|
||||||
|
|
||||||
# And here we have a TextSymbolizer, used for labeling.
|
# And here we have a TextSymbolizer, used for labeling.
|
||||||
# The first parameter is the name of the attribute to use as the source of the
|
# The first parameter is the name of the attribute to use as the source of the
|
||||||
# text to label with. Then there is font size in points (I think?), and colour.
|
# text to label with. Then there is font size in points (I think?), and colour.
|
||||||
|
|
||||||
popplaces_text_symbolizer = mapnik2.TextSymbolizer(mapnik2.Expression("[GEONAME]"),
|
popplaces_text_symbolizer = mapnik.TextSymbolizer(mapnik.Expression("[GEONAME]"),
|
||||||
'DejaVu Sans Book',
|
'DejaVu Sans Book',
|
||||||
10, mapnik2.Color('black'))
|
10, mapnik.Color('black'))
|
||||||
|
|
||||||
# We set a "halo" around the text, which looks like an outline if thin enough,
|
# We set a "halo" around the text, which looks like an outline if thin enough,
|
||||||
# or an outright background if large enough.
|
# or an outright background if large enough.
|
||||||
popplaces_text_symbolizer.label_placement= mapnik2.label_placement.POINT_PLACEMENT
|
popplaces_text_symbolizer.label_placement= mapnik.label_placement.POINT_PLACEMENT
|
||||||
popplaces_text_symbolizer.halo_fill = mapnik2.Color('white')
|
popplaces_text_symbolizer.halo_fill = mapnik.Color('white')
|
||||||
popplaces_text_symbolizer.halo_radius = 1
|
popplaces_text_symbolizer.halo_radius = 1
|
||||||
popplaces_text_symbolizer.avoid_edges = True
|
popplaces_text_symbolizer.avoid_edges = True
|
||||||
#popplaces_text_symbolizer.minimum_padding = 30
|
#popplaces_text_symbolizer.minimum_padding = 30
|
||||||
|
@ -320,11 +320,11 @@ m.layers.append(popplaces_lyr)
|
||||||
# Draw map
|
# Draw map
|
||||||
|
|
||||||
# Set the initial extent of the map in 'master' spherical Mercator projection
|
# Set the initial extent of the map in 'master' spherical Mercator projection
|
||||||
m.zoom_to_box(mapnik2.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
|
m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
|
||||||
|
|
||||||
# Render two maps, two PNGs, one JPEG.
|
# Render map
|
||||||
im = mapnik2.Image(m.width,m.height)
|
im = mapnik.Image(m.width,m.height)
|
||||||
mapnik2.render(m, im)
|
mapnik.render(m, im)
|
||||||
|
|
||||||
# Save image to files
|
# Save image to files
|
||||||
images_ = []
|
images_ = []
|
||||||
|
@ -347,38 +347,41 @@ images_.append('demo_high.jpg')
|
||||||
im.save('demo_low.jpg', 'jpeg50')
|
im.save('demo_low.jpg', 'jpeg50')
|
||||||
images_.append('demo_low.jpg')
|
images_.append('demo_low.jpg')
|
||||||
|
|
||||||
|
im.save('demo.tif', 'tiff')
|
||||||
|
images_.append('demo.tif')
|
||||||
|
|
||||||
# Render cairo examples
|
# Render cairo examples
|
||||||
if HAS_PYCAIRO_MODULE and mapnik2.has_pycairo():
|
if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
|
||||||
|
|
||||||
svg_surface = cairo.SVGSurface('demo.svg', m.width,m.height)
|
svg_surface = cairo.SVGSurface('demo.svg', m.width,m.height)
|
||||||
mapnik2.render(m, svg_surface)
|
mapnik.render(m, svg_surface)
|
||||||
svg_surface.finish()
|
svg_surface.finish()
|
||||||
images_.append('demo.svg')
|
images_.append('demo.svg')
|
||||||
|
|
||||||
pdf_surface = cairo.PDFSurface('demo.pdf', m.width,m.height)
|
pdf_surface = cairo.PDFSurface('demo.pdf', m.width,m.height)
|
||||||
mapnik2.render(m, pdf_surface)
|
mapnik.render(m, pdf_surface)
|
||||||
images_.append('demo.pdf')
|
images_.append('demo.pdf')
|
||||||
pdf_surface.finish()
|
pdf_surface.finish()
|
||||||
|
|
||||||
postscript_surface = cairo.PSSurface('demo.ps', m.width,m.height)
|
postscript_surface = cairo.PSSurface('demo.ps', m.width,m.height)
|
||||||
mapnik2.render(m, postscript_surface)
|
mapnik.render(m, postscript_surface)
|
||||||
images_.append('demo.ps')
|
images_.append('demo.ps')
|
||||||
postscript_surface.finish()
|
postscript_surface.finish()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print '\n\nPycairo not available...',
|
print '\n\nPycairo not available...',
|
||||||
if mapnik2.has_cairo():
|
if mapnik.has_cairo():
|
||||||
print ' will render Cairo formats using alternative method'
|
print ' will render Cairo formats using alternative method'
|
||||||
|
|
||||||
mapnik2.render_to_file(m,'demo.pdf')
|
mapnik.render_to_file(m,'demo.pdf')
|
||||||
images_.append('demo.pdf')
|
images_.append('demo.pdf')
|
||||||
mapnik2.render_to_file(m,'demo.ps')
|
mapnik.render_to_file(m,'demo.ps')
|
||||||
images_.append('demo.ps')
|
images_.append('demo.ps')
|
||||||
mapnik2.render_to_file(m,'demo.svg')
|
mapnik.render_to_file(m,'demo.svg')
|
||||||
images_.append('demo.svg')
|
images_.append('demo.svg')
|
||||||
mapnik2.render_to_file(m,'demo_cairo_rgb.png','RGB24')
|
mapnik.render_to_file(m,'demo_cairo_rgb.png','RGB24')
|
||||||
images_.append('demo_cairo_rgb.png')
|
images_.append('demo_cairo_rgb.png')
|
||||||
mapnik2.render_to_file(m,'demo_cairo_argb.png','ARGB32')
|
mapnik.render_to_file(m,'demo_cairo_argb.png','ARGB32')
|
||||||
images_.append('demo_cairo_argb.png')
|
images_.append('demo_cairo_argb.png')
|
||||||
|
|
||||||
print "\n\n", len(images_), "maps have been rendered in the current directory:"
|
print "\n\n", len(images_), "maps have been rendered in the current directory:"
|
||||||
|
@ -388,4 +391,4 @@ for im_ in images_:
|
||||||
|
|
||||||
print "\n\nHave a look!\n\n"
|
print "\n\nHave a look!\n\n"
|
||||||
|
|
||||||
mapnik2.save_map(m,"map.xml")
|
mapnik.save_map(m,"map.xml")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -23,7 +23,7 @@ Import ('env')
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
lib_dir = os.path.normpath(env['DESTDIR'] + '/' + env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/mapnik2')
|
lib_dir = os.path.normpath(env['DESTDIR'] + '/' + env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/mapnik')
|
||||||
|
|
||||||
fonts = 1
|
fonts = 1
|
||||||
ini_template = '''
|
ini_template = '''
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -43,7 +44,7 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
// register input plug-ins
|
// register input plug-ins
|
||||||
QString plugins_dir = settings.value("mapnik/plugins_dir",
|
QString plugins_dir = settings.value("mapnik/plugins_dir",
|
||||||
QVariant("/usr/local/lib/mapnik2/input/")).toString();
|
QVariant("/usr/local/lib/mapnik/input/")).toString();
|
||||||
datasource_cache::instance()->register_datasources(plugins_dir.toStdString());
|
datasource_cache::instance()->register_datasources(plugins_dir.toStdString());
|
||||||
// register fonts
|
// register fonts
|
||||||
int count = settings.beginReadArray("mapnik/fonts");
|
int count = settings.beginReadArray("mapnik/fonts");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
*
|
||||||
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -11,7 +11,7 @@ INCLUDEPATH += /usr/X11/include/freetype2
|
||||||
INCLUDEPATH += .
|
INCLUDEPATH += .
|
||||||
|
|
||||||
QMAKE_CXXFLAGS +=' -DDARWIN -Wno-missing-field-initializers -ansi'
|
QMAKE_CXXFLAGS +=' -DDARWIN -Wno-missing-field-initializers -ansi'
|
||||||
unix:LIBS = -L/usr/local/lib -L/usr/X11/lib -lmapnik2 -lfreetype
|
unix:LIBS = -L/usr/local/lib -L/usr/X11/lib -lmapnik -lfreetype
|
||||||
unix:LIBS += -lboost_system -licuuc -lboost_filesystem -lboost_regex
|
unix:LIBS += -lboost_system -licuuc -lboost_filesystem -lboost_regex
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
|
|
2
deps/agg/include/agg_path_storage.h
vendored
2
deps/agg/include/agg_path_storage.h
vendored
|
@ -736,7 +736,7 @@ namespace agg
|
||||||
template<class VertexSource>
|
template<class VertexSource>
|
||||||
void join_path(VertexSource& vs, unsigned path_id = 0)
|
void join_path(VertexSource& vs, unsigned path_id = 0)
|
||||||
{
|
{
|
||||||
double x, y;
|
double x=0.0, y=0.0;
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
vs.rewind(path_id);
|
vs.rewind(path_id);
|
||||||
cmd = vs.vertex(&x, &y);
|
cmd = vs.vertex(&x, &y);
|
||||||
|
|
5
deps/agg/include/agg_rasterizer_outline_aa.h
vendored
5
deps/agg/include/agg_rasterizer_outline_aa.h
vendored
|
@ -323,9 +323,7 @@ namespace agg
|
||||||
int y2;
|
int y2;
|
||||||
int lprev;
|
int lprev;
|
||||||
|
|
||||||
if(close_polygon)
|
if(close_polygon && (m_src_vertices.size() >= 3))
|
||||||
{
|
|
||||||
if(m_src_vertices.size() >= 3)
|
|
||||||
{
|
{
|
||||||
dv.idx = 2;
|
dv.idx = 2;
|
||||||
|
|
||||||
|
@ -385,7 +383,6 @@ namespace agg
|
||||||
}
|
}
|
||||||
draw(dv, 0, m_src_vertices.size());
|
draw(dv, 0, m_src_vertices.size());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(m_src_vertices.size())
|
switch(m_src_vertices.size())
|
||||||
|
|
4
deps/agg/src/agg_rounded_rect.cpp
vendored
4
deps/agg/src/agg_rounded_rect.cpp
vendored
|
@ -78,8 +78,8 @@ namespace agg
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void rounded_rect::normalize_radius()
|
void rounded_rect::normalize_radius()
|
||||||
{
|
{
|
||||||
double dx = fabs(m_y2 - m_y1);
|
double dx = fabs(m_x2 - m_x1);
|
||||||
double dy = fabs(m_x2 - m_x1);
|
double dy = fabs(m_y2 - m_y1);
|
||||||
|
|
||||||
double k = 1.0;
|
double k = 1.0;
|
||||||
double t;
|
double t;
|
||||||
|
|
|
@ -15,11 +15,33 @@ Look through the code to get an idea, and do not hesitate to ask questions.
|
||||||
|
|
||||||
Also read the design philosophy page for the motivations that lead to code decisions.
|
Also read the design philosophy page for the motivations that lead to code decisions.
|
||||||
|
|
||||||
|
Templates are good, within reason. We seek to use templates were possible for flexible code, but not in cases where functional
|
||||||
|
patterns would be just as concise and clear.
|
||||||
|
|
||||||
In general we use Boost, it makes more possible in C++. It is a big build time dependency (as in time to compile against and # of headers) but ultimately compiles to small object code and is very fast (particularly spirit). It also has no dependencies itself (it's really an extension to the C++ language) so requiring it is much easier than requiring a hard dependency that itself has other dependencies. This is a big reason that we prefer AGG to Cairo as our primary renderer. Also AGG, besides producing the best visual output, strikes an excellent balance between speed and thread safety by using very lightweight objects. Cairo not so much.
|
In general we use Boost, it makes more possible in C++. It is a big build time dependency (as in time to compile against and # of headers) but ultimately compiles to small object code and is very fast (particularly spirit). It also has no dependencies itself (it's really an extension to the C++ language) so requiring it is much easier than requiring a hard dependency that itself has other dependencies. This is a big reason that we prefer AGG to Cairo as our primary renderer. Also AGG, besides producing the best visual output, strikes an excellent balance between speed and thread safety by using very lightweight objects. Cairo not so much.
|
||||||
|
|
||||||
You will also notice that we don't use many of the standard geo libraries when we could. For instance we don't use GDAL, OGR, or GEOS anywhere in core, and only leverage them in optional plugins. We feel we can often write code that is faster and more thread safe than these libraries but that still does the job. If this ever changes we can adapt and start using these libraries or others as dependencies - nothing is nicer than standing on the shoulders of giants when it makes sense.
|
You will also notice that we don't use many of the standard geo libraries when we could. For instance we don't use GDAL, OGR, or GEOS anywhere in core, and only leverage them in optional plugins. We feel we can often write code that is faster and more thread safe than these libraries but that still does the job. If this ever changes we can adapt and start using these libraries or others as dependencies - nothing is nicer than standing on the shoulders of giants when it makes sense.
|
||||||
|
|
||||||
|
|
||||||
|
## Code commits best practices.
|
||||||
|
|
||||||
|
#### Big changes - awesome as pull requests
|
||||||
|
|
||||||
|
We love big, aggressive refactoring - but ideally in branches. Even if the changes should go directly into the mainline code and are stable, very big changes are useful to see as a group and branches are cheap. So, branch and commit then create a pull request against master so that other developers can take a quick look. This is a great way for informal code review when a full issue is not warrented.
|
||||||
|
|
||||||
|
#### Commits that fix issues should note the issue #
|
||||||
|
|
||||||
|
git commit plugins/input/ogr/ -m "implemented sql query in OGR plugin (closes #472)"
|
||||||
|
|
||||||
|
#### Commits that relate to issues should reference them:
|
||||||
|
|
||||||
|
git commit tests/python_tests/sqlite_test.py -m "more robust sqlite tests - refs #928"
|
||||||
|
|
||||||
|
#### Commits that add a new feature or fix should be added to the CHANGELOG
|
||||||
|
|
||||||
|
Ideally the CHANGELOG can be a very concise place to look for the most important recent development and should not read like a full commit log. So, some developers may prefer to weekly or monthly look back over their commits and summarize all at once with additions to the CHANGELOG. Other developers may prefer to add as they go.
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Mapnik is licensed LGPL, which means that you are a free to use the code in any of your applications whether they be open source or not. It also means that if you contribute code to Mapnik that others are free to continue using Mapnik in the same way, even with your new additions. If you choose to redistribute an application using Mapnik just make sure to provide any source code modifications you make back to the community. For the actual details see the full LGPL license in the COPYING doc.
|
Mapnik is licensed LGPL, which means that you are a free to use the code in any of your applications whether they be open source or not. It also means that if you contribute code to Mapnik that others are free to continue using Mapnik in the same way, even with your new additions. If you choose to redistribute an application using Mapnik just make sure to provide any source code modifications you make back to the community. For the actual details see the full LGPL license in the COPYING doc.
|
||||||
|
@ -67,13 +89,19 @@ If you see bits of code around that do not follow these please don't hesitate to
|
||||||
|
|
||||||
#### Indentation is four spaces
|
#### Indentation is four spaces
|
||||||
|
|
||||||
|
#### Use C++ style casts
|
||||||
|
|
||||||
|
static_cast<int>(value); // yes
|
||||||
|
|
||||||
|
(int)value; // no
|
||||||
|
|
||||||
#### Shared pointers should be created with [boost::make_shared](http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/make_shared.html) where possible
|
#### Shared pointers should be created with [boost::make_shared](http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/make_shared.html) where possible
|
||||||
|
|
||||||
#### Function definitions should not be separated from their arguments:
|
#### Function definitions should not be separated from their arguments:
|
||||||
|
|
||||||
void foo(int a) { ... } // please
|
void foo(int a) // please
|
||||||
|
|
||||||
void foo (int a) { ... } // no
|
void foo (int a) // no
|
||||||
|
|
||||||
#### Separate arguments by a single space:
|
#### Separate arguments by a single space:
|
||||||
|
|
||||||
|
@ -87,7 +115,18 @@ If you see bits of code around that do not follow these please don't hesitate to
|
||||||
|
|
||||||
if(a==b) // no
|
if(a==b) // no
|
||||||
|
|
||||||
#### Braces should ideally be on a separate line:
|
#### Braces should always be used:
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
throw mapnik::datasource_exception("not found"); // please
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
throw mapnik::datasource_exception("not found"); // no
|
||||||
|
|
||||||
|
|
||||||
|
#### Braces should be on a separate line:
|
||||||
|
|
||||||
if (a == b)
|
if (a == b)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,15 +19,16 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_AGG_PATTERN_SOURCE_HPP
|
#ifndef MAPNIK_AGG_PATTERN_SOURCE_HPP
|
||||||
#define MAPNIK_AGG_PATTERN_SOURCE_HPP
|
#define MAPNIK_AGG_PATTERN_SOURCE_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/image_data.hpp>
|
#include <mapnik/image_data.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg_color_rgba.h"
|
#include "agg_color_rgba.h"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,12 +19,14 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_AGG_RASTERIZER_HPP
|
#ifndef MAPNIK_AGG_RASTERIZER_HPP
|
||||||
#define MAPNIK_AGG_RASTERIZER_HPP
|
#define MAPNIK_AGG_RASTERIZER_HPP
|
||||||
|
|
||||||
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
|
// agg
|
||||||
#include "agg_rasterizer_scanline_aa.h"
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_AGG_RENDERER_HPP
|
||||||
|
#define MAPNIK_AGG_RENDERER_HPP
|
||||||
#ifndef AGG_RENDERER_HPP
|
|
||||||
#define AGG_RENDERER_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
|
@ -40,6 +38,7 @@
|
||||||
// boost
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// forward declare so that
|
// forward declare so that
|
||||||
|
@ -61,7 +60,11 @@ class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// create with default, empty placement detector
|
||||||
agg_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
agg_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||||
|
// create with external placement detector, possibly non-empty
|
||||||
|
agg_renderer(Map const &m, T & pixmap, boost::shared_ptr<label_collision_detector4> detector,
|
||||||
|
double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||||
~agg_renderer();
|
~agg_renderer();
|
||||||
void start_map_processing(Map const& map);
|
void start_map_processing(Map const& map);
|
||||||
void end_map_processing(Map const& map);
|
void end_map_processing(Map const& map);
|
||||||
|
@ -122,9 +125,11 @@ private:
|
||||||
CoordTransform t_;
|
CoordTransform t_;
|
||||||
freetype_engine font_engine_;
|
freetype_engine font_engine_;
|
||||||
face_manager<freetype_engine> font_manager_;
|
face_manager<freetype_engine> font_manager_;
|
||||||
label_collision_detector4 detector_;
|
boost::shared_ptr<label_collision_detector4> detector_;
|
||||||
boost::scoped_ptr<rasterizer> ras_ptr;
|
boost::scoped_ptr<rasterizer> ras_ptr;
|
||||||
|
|
||||||
|
void setup(Map const &m);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //AGG_RENDERER_HPP
|
#endif // MAPNIK_AGG_RENDERER_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_ARROW_HPP
|
||||||
|
#define MAPNIK_ARROW_HPP
|
||||||
#ifndef ARROW_HPP
|
|
||||||
#define ARROW_HPP
|
|
||||||
|
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
|
|
||||||
|
@ -44,4 +42,4 @@ private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ARROW_HPP
|
#endif // MAPNIK_ARROW_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,15 +20,18 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_ATTRIBUTE_HPP
|
#ifndef MAPNIK_ATTRIBUTE_HPP
|
||||||
#define MAPNIK_ATTRIBUTE_HPP
|
#define MAPNIK_ATTRIBUTE_HPP
|
||||||
|
|
||||||
|
// mapnik
|
||||||
|
#include <mapnik/value.hpp>
|
||||||
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
|
static mapnik::value _null_value;
|
||||||
|
|
||||||
struct attribute
|
struct attribute
|
||||||
{
|
{
|
||||||
std::string name_;
|
std::string name_;
|
||||||
|
@ -38,7 +41,13 @@ struct attribute
|
||||||
template <typename V ,typename F>
|
template <typename V ,typename F>
|
||||||
V value(F const& f) const
|
V value(F const& f) const
|
||||||
{
|
{
|
||||||
return f[name_];
|
typedef typename F::const_iterator const_iterator;
|
||||||
|
const_iterator itr = f.find(name_);
|
||||||
|
if (itr != f.end())
|
||||||
|
{
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
return _null_value;
|
||||||
}
|
}
|
||||||
std::string const& name() const { return name_;}
|
std::string const& name() const { return name_;}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,20 +20,20 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_ATTRIBUTE_COLLECTOR_HPP
|
||||||
|
#define MAPNIK_ATTRIBUTE_COLLECTOR_HPP
|
||||||
#ifndef ATTRIBUTE_COLLECTOR_HPP
|
|
||||||
#define ATTRIBUTE_COLLECTOR_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/rule.hpp>
|
#include <mapnik/rule.hpp>
|
||||||
#include <mapnik/path_expression_grammar.hpp>
|
#include <mapnik/path_expression_grammar.hpp>
|
||||||
#include <mapnik/parse_path.hpp>
|
#include <mapnik/parse_path.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -271,4 +271,4 @@ private:
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
#endif //ATTRIBUTE_COLLECTOR_HPP
|
#endif // MAPNIK_ATTRIBUTE_COLLECTOR_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||||
|
#define MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||||
#ifndef ATTRIBUTE_DESCRIPTOR
|
|
||||||
#define ATTRIBUTE_DESCRIPTOR
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -118,4 +116,4 @@ operator << (std::basic_ostream<charT,traits>& out,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ATTRIBUTE_DESCRIPTOR_HPP
|
#endif // MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,16 +20,16 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: box2d.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
|
||||||
|
|
||||||
#ifndef MAPNIK_BOX2D_HPP
|
#ifndef MAPNIK_BOX2D_HPP
|
||||||
#define MAPNIK_BOX2D_HPP
|
#define MAPNIK_BOX2D_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
@ -41,9 +41,8 @@ namespace mapnik {
|
||||||
template <typename T> class MAPNIK_DECL box2d
|
template <typename T> class MAPNIK_DECL box2d
|
||||||
: boost::equality_comparable<box2d<T> ,
|
: boost::equality_comparable<box2d<T> ,
|
||||||
boost::addable<box2d<T>,
|
boost::addable<box2d<T>,
|
||||||
boost::subtractable<box2d<T>,
|
|
||||||
boost::dividable2<box2d<T>, T,
|
boost::dividable2<box2d<T>, T,
|
||||||
boost::multipliable2<box2d<T>, T > > > > >
|
boost::multipliable2<box2d<T>, T > > > >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef box2d<T> box2d_type;
|
typedef box2d<T> box2d_type;
|
||||||
|
@ -86,7 +85,6 @@ public:
|
||||||
|
|
||||||
// define some operators
|
// define some operators
|
||||||
box2d_type& operator+=(box2d_type const& other);
|
box2d_type& operator+=(box2d_type const& other);
|
||||||
box2d_type& operator-=(box2d_type const& other);
|
|
||||||
box2d_type& operator*=(T);
|
box2d_type& operator*=(T);
|
||||||
box2d_type& operator/=(T);
|
box2d_type& operator/=(T);
|
||||||
T operator[](int index) const;
|
T operator[](int index) const;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Tom Hughes
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,10 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#if defined(HAVE_CAIRO)
|
#if defined(HAVE_CAIRO)
|
||||||
|
|
||||||
#ifndef CAIRO_RENDERER_HPP
|
#ifndef MAPNIK_CAIRO_RENDERER_HPP
|
||||||
#define CAIRO_RENDERER_HPP
|
#define MAPNIK_CAIRO_RENDERER_HPP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
|
@ -152,6 +148,6 @@ public:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // MAPNIK_CAIRO_RENDERER_HPP
|
||||||
|
|
||||||
#endif //CAIRO_RENDERER_HPP
|
#endif
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: color.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_COLOR_HPP
|
||||||
|
#define MAPNIK_COLOR_HPP
|
||||||
#ifndef COLOR_HPP
|
|
||||||
#define COLOR_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
|
@ -32,6 +30,7 @@
|
||||||
//boost
|
//boost
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -141,4 +140,4 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //COLOR_HPP
|
#endif // MAPNIK_COLOR_HPP
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_COLOR_FACTORY_HPP
|
#ifndef MAPNIK_COLOR_FACTORY_HPP
|
||||||
#define MAPNIK_COLOR_FACTORY_HPP
|
#define MAPNIK_COLOR_FACTORY_HPP
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_HPP
|
#ifndef MAPNIK_CONFIG_HPP
|
||||||
#define CONFIG_HPP
|
#define MAPNIK_CONFIG_HPP
|
||||||
|
|
||||||
// Windows DLL support
|
// Windows DLL support
|
||||||
|
|
||||||
|
@ -47,4 +47,5 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PROJ_ENVELOPE_POINTS 20
|
#define PROJ_ENVELOPE_POINTS 20
|
||||||
#endif // CONFIG_HPP
|
|
||||||
|
#endif // MAPNIK_CONFIG_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef MAPNIK_CONFIG_ERROR_INCLUDED
|
#ifndef MAPNIK_CONFIG_ERROR_HPP
|
||||||
#define MAPNIK_CONFIG_ERROR_INCLUDED
|
#define MAPNIK_CONFIG_ERROR_HPP
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -54,4 +54,4 @@ protected:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MAPNIK_CONFIG_ERROR_INCLUDED
|
#endif // MAPNIK_CONFIG_ERROR_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,12 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: coord.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_COORD_HPP
|
||||||
|
#define MAPNIK_COORD_HPP
|
||||||
#ifndef COORD_HPP
|
|
||||||
#define COORD_HPP
|
|
||||||
|
|
||||||
|
// boost
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
|
// stl
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -187,4 +188,4 @@ operator << (std::basic_ostream<charT,traits>& out,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // COORD_HPP
|
#endif // MAPNIK_COORD_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,13 +20,12 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: coord_array.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_COORD_ARRAY_HPP
|
||||||
|
#define MAPNIK_COORD_ARRAY_HPP
|
||||||
#ifndef COORD_ARRAY_HPP
|
|
||||||
#define COORD_ARRAY_HPP
|
|
||||||
|
|
||||||
//mapnik
|
//mapnik
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -89,4 +88,4 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //COORD_ARRAY_HPP
|
#endif // MAPNIK_COORD_ARRAY_HPP
|
||||||
|
|
|
@ -20,22 +20,23 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
||||||
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/color.hpp>
|
#include <mapnik/color.hpp>
|
||||||
|
|
||||||
// spirit2
|
// spirit2
|
||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
#include <boost/spirit/include/qi_action.hpp>
|
#include <boost/spirit/include/qi_action.hpp>
|
||||||
|
|
||||||
// phoenix
|
// phoenix
|
||||||
#include <boost/spirit/include/phoenix_core.hpp>
|
#include <boost/spirit/include/phoenix_core.hpp>
|
||||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
#include <boost/spirit/include/phoenix_fusion.hpp>
|
||||||
#include <boost/spirit/include/phoenix_function.hpp>
|
#include <boost/spirit/include/phoenix_function.hpp>
|
||||||
|
|
||||||
// fusion
|
// fusion
|
||||||
#include <boost/fusion/include/adapt_struct.hpp>
|
#include <boost/fusion/include/adapt_struct.hpp>
|
||||||
#include <boost/fusion/include/adapt_adt.hpp>
|
#include <boost/fusion/include/adapt_adt.hpp>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,22 +20,23 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP
|
||||||
|
#define MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP
|
||||||
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
|
||||||
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/color.hpp>
|
#include <mapnik/color.hpp>
|
||||||
|
|
||||||
// spirit2
|
// spirit2
|
||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
#include <boost/spirit/include/qi_action.hpp>
|
#include <boost/spirit/include/qi_action.hpp>
|
||||||
|
|
||||||
// phoenix
|
// phoenix
|
||||||
#include <boost/spirit/include/phoenix_core.hpp>
|
#include <boost/spirit/include/phoenix_core.hpp>
|
||||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
#include <boost/spirit/include/phoenix_fusion.hpp>
|
||||||
#include <boost/spirit/include/phoenix_function.hpp>
|
#include <boost/spirit/include/phoenix_function.hpp>
|
||||||
|
|
||||||
// fusion
|
// fusion
|
||||||
#include <boost/fusion/include/adapt_struct.hpp>
|
#include <boost/fusion/include/adapt_struct.hpp>
|
||||||
|
|
||||||
|
@ -45,7 +46,6 @@
|
||||||
// stl
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
//BOOST_FUSION_ADAPT_CLASS(
|
//BOOST_FUSION_ADAPT_CLASS(
|
||||||
// mapnik::color,
|
// mapnik::color,
|
||||||
// (unsigned, unsigned, obj.red(), obj.set_red(val))
|
// (unsigned, unsigned, obj.red(), obj.set_red(val))
|
||||||
|
@ -417,4 +417,4 @@ struct css_color_grammar : qi::grammar<Iterator, css(), ascii_space_type>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //MAPNIK_CSS_COLOR_GRAMMAR_HPP
|
#endif // MAPNIK_CSS_COLOR_GRAMMAR_DEPRECATED_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,21 +20,30 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: ctrans.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_CTRANS_HPP
|
||||||
|
#define MAPNIK_CTRANS_HPP
|
||||||
#ifndef CTRANS_HPP
|
|
||||||
#define CTRANS_HPP
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
|
// mapnik
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
#include <mapnik/vertex.hpp>
|
#include <mapnik/vertex.hpp>
|
||||||
#include <mapnik/coord_array.hpp>
|
#include <mapnik/coord_array.hpp>
|
||||||
#include <mapnik/proj_transform.hpp>
|
#include <mapnik/proj_transform.hpp>
|
||||||
|
|
||||||
namespace mapnik {
|
// boost
|
||||||
|
#include <boost/math/constants/constants.hpp>
|
||||||
|
|
||||||
|
// stl
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
const double pi = boost::math::constants::pi<double>();
|
||||||
|
const double pi_by_2 = pi/2.0;
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
@ -58,6 +67,7 @@ private:
|
||||||
Geometry& geom_;
|
Geometry& geom_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Transform, typename Geometry>
|
template <typename Transform, typename Geometry>
|
||||||
struct MAPNIK_DECL coord_transform2
|
struct MAPNIK_DECL coord_transform2
|
||||||
{
|
{
|
||||||
|
@ -73,18 +83,17 @@ struct MAPNIK_DECL coord_transform2
|
||||||
|
|
||||||
unsigned vertex(double *x, double *y) const
|
unsigned vertex(double *x, double *y) const
|
||||||
{
|
{
|
||||||
unsigned command(SEG_MOVETO);
|
unsigned command = SEG_MOVETO;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
bool skipped_points = false;
|
bool skipped_points = false;
|
||||||
while (!ok)
|
double z = 0;
|
||||||
|
while (!ok && command != SEG_END)
|
||||||
{
|
{
|
||||||
command = geom_.vertex(x, y);
|
command = geom_.vertex(x, y);
|
||||||
double z=0;
|
|
||||||
ok = prj_trans_.backward(*x, *y, z);
|
ok = prj_trans_.backward(*x, *y, z);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
skipped_points = true;
|
skipped_points = true;
|
||||||
}
|
}
|
||||||
ok = ok || (command == SEG_END);
|
|
||||||
}
|
}
|
||||||
if (skipped_points && (command == SEG_LINETO))
|
if (skipped_points && (command == SEG_LINETO))
|
||||||
{
|
{
|
||||||
|
@ -94,15 +103,6 @@ struct MAPNIK_DECL coord_transform2
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*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);
|
|
||||||
return command;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void rewind(unsigned pos)
|
void rewind(unsigned pos)
|
||||||
{
|
{
|
||||||
geom_.rewind(pos);
|
geom_.rewind(pos);
|
||||||
|
@ -156,6 +156,225 @@ private:
|
||||||
int dy_;
|
int dy_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// TODO - expose this and make chainable
|
||||||
|
template <typename Transform,typename Geometry>
|
||||||
|
struct MAPNIK_DECL coord_transform_parallel
|
||||||
|
{
|
||||||
|
typedef std::size_t size_type;
|
||||||
|
typedef typename Geometry::value_type value_type;
|
||||||
|
|
||||||
|
coord_transform_parallel(Transform const& t,
|
||||||
|
Geometry const& geom,
|
||||||
|
proj_transform const& prj_trans )
|
||||||
|
: t_(t),
|
||||||
|
geom_(geom),
|
||||||
|
prj_trans_(prj_trans),
|
||||||
|
offset_(0.0),
|
||||||
|
threshold_(10),
|
||||||
|
m_status(initial) {}
|
||||||
|
|
||||||
|
enum status
|
||||||
|
{
|
||||||
|
initial,
|
||||||
|
start,
|
||||||
|
first,
|
||||||
|
process,
|
||||||
|
last_vertex,
|
||||||
|
angle_joint,
|
||||||
|
end
|
||||||
|
};
|
||||||
|
|
||||||
|
double get_offset() const
|
||||||
|
{
|
||||||
|
return offset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_offset(double offset)
|
||||||
|
{
|
||||||
|
offset_ = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int get_threshold() const
|
||||||
|
{
|
||||||
|
return threshold_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_threshold(unsigned int t)
|
||||||
|
{
|
||||||
|
threshold_ = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned vertex(double * x , double * y)
|
||||||
|
{
|
||||||
|
double z=0;
|
||||||
|
|
||||||
|
if (offset_==0.0)
|
||||||
|
{
|
||||||
|
unsigned command = geom_.vertex(x,y);
|
||||||
|
prj_trans_.backward(*x,*y,z);
|
||||||
|
t_.forward(x,y);
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(true){
|
||||||
|
switch(m_status)
|
||||||
|
{
|
||||||
|
case end:
|
||||||
|
return SEG_END;
|
||||||
|
break;
|
||||||
|
case initial:
|
||||||
|
m_pre_cmd = geom_.vertex(x,y);
|
||||||
|
prj_trans_.backward(*x,*y,z);
|
||||||
|
t_.forward(x,y);
|
||||||
|
m_pre_x = *x;
|
||||||
|
m_pre_y = *y;
|
||||||
|
//m_status = (m_pre_cmd!=SEG_END)?start:end; //
|
||||||
|
case start:
|
||||||
|
m_cur_cmd = geom_.vertex(&m_cur_x, &m_cur_y);
|
||||||
|
prj_trans_.backward(m_cur_x,m_cur_y,z);
|
||||||
|
t_.forward(&m_cur_x,&m_cur_y);
|
||||||
|
case first:
|
||||||
|
angle_a = atan2((m_pre_y-m_cur_y),(m_pre_x-m_cur_x));
|
||||||
|
dx_pre = cos(angle_a + pi_by_2);
|
||||||
|
dy_pre = sin(angle_a + pi_by_2);
|
||||||
|
#ifdef MAPNIK_DEBUG
|
||||||
|
std::clog << "offsetting line by: " << offset_ << "\n";
|
||||||
|
std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n";
|
||||||
|
#endif
|
||||||
|
*x = m_pre_x + (dx_pre * offset_);
|
||||||
|
*y = m_pre_y + (dy_pre * offset_);
|
||||||
|
m_status = process;
|
||||||
|
return SEG_MOVETO;
|
||||||
|
case process:
|
||||||
|
switch(m_cur_cmd)
|
||||||
|
{
|
||||||
|
case SEG_LINETO:
|
||||||
|
m_next_cmd = geom_.vertex(&m_next_x, &m_next_y);
|
||||||
|
prj_trans_.backward(m_next_x,m_next_y,z);
|
||||||
|
t_.forward(&m_next_x,&m_next_y);
|
||||||
|
switch(m_next_cmd)
|
||||||
|
{
|
||||||
|
case SEG_LINETO:
|
||||||
|
m_status = angle_joint;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_status = last_vertex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SEG_END:
|
||||||
|
m_status = end;
|
||||||
|
return SEG_END;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case last_vertex:
|
||||||
|
dx_curr = cos(angle_a + pi_by_2);
|
||||||
|
dy_curr = sin(angle_a + pi_by_2);
|
||||||
|
*x = m_cur_x + (dx_curr * offset_);
|
||||||
|
*y = m_cur_y + (dy_curr * offset_);
|
||||||
|
m_status = end;
|
||||||
|
return m_cur_cmd;
|
||||||
|
case angle_joint:
|
||||||
|
angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x));
|
||||||
|
h = tan((angle_b - angle_a)/2.0);
|
||||||
|
|
||||||
|
if (fabs(h) < threshold_)
|
||||||
|
{
|
||||||
|
dx_curr = cos(angle_a + pi_by_2);
|
||||||
|
dy_curr = sin(angle_a + pi_by_2);
|
||||||
|
*x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_);
|
||||||
|
*y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_);
|
||||||
|
}
|
||||||
|
else // skip sharp spikes
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef MAPNIK_DEBUG
|
||||||
|
dx_curr = cos(angle_a + pi_by_2);
|
||||||
|
dy_curr = sin(angle_a + pi_by_2);
|
||||||
|
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
|
||||||
|
std::clog << "angle a: " << angle_a << "\n";
|
||||||
|
std::clog << "angle b: " << angle_b << "\n";
|
||||||
|
std::clog << "h: " << h << "\n";
|
||||||
|
std::clog << "sin_curve: " << sin_curve << "\n";
|
||||||
|
#endif
|
||||||
|
m_status = process;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// alternate sharp spike fix, but suboptimal...
|
||||||
|
|
||||||
|
/*
|
||||||
|
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
|
||||||
|
cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr;
|
||||||
|
|
||||||
|
#ifdef MAPNIK_DEBUG
|
||||||
|
std::clog << "sin_curve value: " << sin_curve << "\n";
|
||||||
|
#endif
|
||||||
|
if(sin_curve > -0.3 && sin_curve < 0.3) {
|
||||||
|
angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x));
|
||||||
|
h = tan((angle_b - angle_a)/2.0);
|
||||||
|
*x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_);
|
||||||
|
*y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_);
|
||||||
|
} else {
|
||||||
|
if (angle_b - angle_a > 0)
|
||||||
|
h = -1.0*(1.0+cos_curve)/sin_curve;
|
||||||
|
else
|
||||||
|
h = (1.0+cos_curve)/sin_curve;
|
||||||
|
*x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_;
|
||||||
|
*y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
m_pre_x = *x;
|
||||||
|
m_pre_x = *y;
|
||||||
|
m_cur_x = m_next_x;
|
||||||
|
m_cur_y = m_next_y;
|
||||||
|
angle_a = angle_b;
|
||||||
|
m_pre_cmd = m_cur_cmd;
|
||||||
|
m_cur_cmd = m_next_cmd;
|
||||||
|
m_status = process;
|
||||||
|
return m_pre_cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rewind (unsigned pos)
|
||||||
|
{
|
||||||
|
geom_.rewind(pos);
|
||||||
|
m_status = initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Transform const& t_;
|
||||||
|
Geometry const& geom_;
|
||||||
|
proj_transform const& prj_trans_;
|
||||||
|
int offset_;
|
||||||
|
unsigned int threshold_;
|
||||||
|
status m_status;
|
||||||
|
double dx_pre;
|
||||||
|
double dy_pre;
|
||||||
|
double dx_curr;
|
||||||
|
double dy_curr;
|
||||||
|
double sin_curve;
|
||||||
|
double cos_curve;
|
||||||
|
double angle_a;
|
||||||
|
double angle_b;
|
||||||
|
double h;
|
||||||
|
unsigned m_pre_cmd;
|
||||||
|
double m_pre_x;
|
||||||
|
double m_pre_y;
|
||||||
|
unsigned m_cur_cmd;
|
||||||
|
double m_cur_x;
|
||||||
|
double m_cur_y;
|
||||||
|
unsigned m_next_cmd;
|
||||||
|
double m_next_x;
|
||||||
|
double m_next_y;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CoordTransform
|
class CoordTransform
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -166,13 +385,15 @@ private:
|
||||||
box2d<double> extent_;
|
box2d<double> extent_;
|
||||||
double offset_x_;
|
double offset_x_;
|
||||||
double offset_y_;
|
double offset_y_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CoordTransform(int width, int height, const box2d<double>& extent,
|
CoordTransform(int width, int height, const box2d<double>& extent,
|
||||||
double offset_x = 0, double offset_y = 0)
|
double offset_x = 0, double offset_y = 0)
|
||||||
:width_(width),height_(height),extent_(extent),offset_x_(offset_x),offset_y_(offset_y)
|
: width_(width), height_(height), extent_(extent),
|
||||||
|
offset_x_(offset_x), offset_y_(offset_y)
|
||||||
{
|
{
|
||||||
sx_ = (double(width_))/extent_.width();
|
sx_ = static_cast<double>(width_) / extent_.width();
|
||||||
sy_ = (double(height_))/extent_.height();
|
sy_ = static_cast<double>(height_) / extent_.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int width() const
|
inline int width() const
|
||||||
|
@ -219,7 +440,8 @@ public:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline box2d<double> forward(const box2d<double>& e,proj_transform const& prj_trans) const
|
inline box2d<double> forward(const box2d<double>& e,
|
||||||
|
proj_transform const& prj_trans) const
|
||||||
{
|
{
|
||||||
double x0 = e.minx();
|
double x0 = e.minx();
|
||||||
double y0 = e.miny();
|
double y0 = e.miny();
|
||||||
|
@ -244,7 +466,8 @@ public:
|
||||||
return box2d<double>(x0, y0, x1, y1);
|
return box2d<double>(x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline box2d<double> backward(const box2d<double>& e,proj_transform const& prj_trans) const
|
inline box2d<double> backward(const box2d<double>& e,
|
||||||
|
proj_transform const& prj_trans) const
|
||||||
{
|
{
|
||||||
double x0 = e.minx();
|
double x0 = e.minx();
|
||||||
double y0 = e.miny();
|
double y0 = e.miny();
|
||||||
|
@ -286,6 +509,7 @@ public:
|
||||||
}
|
}
|
||||||
return coords;
|
return coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline box2d<double> const& extent() const
|
inline box2d<double> const& extent() const
|
||||||
{
|
{
|
||||||
return extent_;
|
return extent_;
|
||||||
|
@ -293,4 +517,4 @@ public:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //CTRANS_HPP
|
#endif // MAPNIK_CTRANS_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,9 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: datasource.hpp 43 2005-04-22 18:52:47Z pavlenko $
|
#ifndef MAPNIK_DATASOURCE_HPP
|
||||||
|
#define MAPNIK_DATASOURCE_HPP
|
||||||
|
|
||||||
#ifndef DATASOURCE_HPP
|
|
||||||
#define DATASOURCE_HPP
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/ctrans.hpp>
|
#include <mapnik/ctrans.hpp>
|
||||||
|
@ -31,9 +30,11 @@
|
||||||
#include <mapnik/feature.hpp>
|
#include <mapnik/feature.hpp>
|
||||||
#include <mapnik/query.hpp>
|
#include <mapnik/query.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -142,6 +143,7 @@ typedef boost::shared_ptr<datasource> datasource_ptr;
|
||||||
delete ds; \
|
delete ds; \
|
||||||
} \
|
} \
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //DATASOURCE_HPP
|
#endif // MAPNIK_DATASOURCE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,24 +20,26 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: datasource_cache.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_DATASOURCE_CACHE_HPP
|
||||||
|
#define MAPNIK_DATASOURCE_CACHE_HPP
|
||||||
#ifndef DATASOURCE_CACHE_HPP
|
|
||||||
#define DATASOURCE_CACHE_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/utils.hpp>
|
#include <mapnik/utils.hpp>
|
||||||
#include <mapnik/params.hpp>
|
#include <mapnik/params.hpp>
|
||||||
#include <mapnik/plugin.hpp>
|
#include <mapnik/plugin.hpp>
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
|
#include <boost/utility.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
class MAPNIK_DECL datasource_cache :
|
class MAPNIK_DECL datasource_cache :
|
||||||
public singleton <datasource_cache,CreateStatic>
|
public singleton <datasource_cache,CreateStatic>,
|
||||||
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
friend class CreateStatic<datasource_cache>;
|
friend class CreateStatic<datasource_cache>;
|
||||||
private:
|
private:
|
||||||
|
@ -57,4 +59,4 @@ public:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //DATASOURCE_CACHE_HPP
|
#endif // MAPNIK_DATASOURCE_CACHE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_DISTANCE_HPP
|
||||||
|
#define MAPNIK_DISTANCE_HPP
|
||||||
#ifndef DISTANCE_HPP
|
|
||||||
#define DISTANCE_HPP
|
|
||||||
|
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
|
|
||||||
|
@ -52,4 +50,4 @@ public:
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GEO_UTILS_HPP
|
#endif // MAPNIK_DISTANCE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_ELLIPSOID_HPP
|
#ifndef MAPNIK_ELLIPSOID_HPP
|
||||||
#define MAPNIK_ELLIPSOID_HPP
|
#define MAPNIK_ELLIPSOID_HPP
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,11 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef MAPNIK_ENUMERATION_INCLUDED
|
#ifndef MAPNIK_ENUMERATION_HPP
|
||||||
#define MAPNIK_ENUMERATION_INCLUDED
|
#define MAPNIK_ENUMERATION_HPP
|
||||||
|
|
||||||
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
|
|
||||||
|
// stl
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -325,4 +327,4 @@ operator>>(std::istream & is, mapnik::enumeration<ENUM, THE_MAX> & e)
|
||||||
template <> std::string name ::our_name_ = #name; \
|
template <> std::string name ::our_name_ = #name; \
|
||||||
template <> bool name ::our_verified_flag_( name ::verify(__FILE__, __LINE__));
|
template <> bool name ::our_verified_flag_( name ::verify(__FILE__, __LINE__));
|
||||||
|
|
||||||
#endif // MAPNIK_ENUMERATION_INCLUDED
|
#endif // MAPNIK_ENUMERATION_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,11 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_EXPRESSION_EVALUATOR_HPP
|
#ifndef MAPNIK_EXPRESSION_EVALUATOR_HPP
|
||||||
#define MAPNIK_EXPRESSION_EVALUATOR_HPP
|
#define MAPNIK_EXPRESSION_EVALUATOR_HPP
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
//#include <boost/regex/config.hpp>
|
|
||||||
#if defined(BOOST_REGEX_HAS_ICU)
|
#if defined(BOOST_REGEX_HAS_ICU)
|
||||||
#include <boost/regex/icu.hpp>
|
#include <boost/regex/icu.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,7 +40,11 @@ struct evaluate : boost::static_visitor<T1>
|
||||||
explicit evaluate(feature_type const& f)
|
explicit evaluate(feature_type const& f)
|
||||||
: feature_(f) {}
|
: feature_(f) {}
|
||||||
|
|
||||||
value_type operator() (value_type x) const { return x; }
|
value_type operator() (value_type x) const
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
value_type operator() (attribute const& attr) const
|
value_type operator() (attribute const& attr) const
|
||||||
{
|
{
|
||||||
return attr.value<value_type,feature_type>(feature_);
|
return attr.value<value_type,feature_type>(feature_);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP
|
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP
|
||||||
#define MAPNIK_EXPRESSIONS_GRAMMAR_HPP
|
#define MAPNIK_EXPRESSIONS_GRAMMAR_HPP
|
||||||
|
|
||||||
|
@ -34,11 +32,14 @@
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
|
|
||||||
// spirit2
|
// spirit2
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
#include <boost/spirit/include/qi_action.hpp>
|
#include <boost/spirit/include/qi_action.hpp>
|
||||||
|
|
||||||
// fusion
|
// fusion
|
||||||
#include <boost/fusion/include/adapt_struct.hpp>
|
#include <boost/fusion/include/adapt_struct.hpp>
|
||||||
|
|
||||||
// phoenix
|
// phoenix
|
||||||
#include <boost/spirit/include/phoenix_core.hpp>
|
#include <boost/spirit/include/phoenix_core.hpp>
|
||||||
#include <boost/spirit/include/phoenix_object.hpp>
|
#include <boost/spirit/include/phoenix_object.hpp>
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using namespace boost;
|
||||||
namespace qi = boost::spirit::qi;
|
namespace qi = boost::spirit::qi;
|
||||||
namespace standard_wide = boost::spirit::standard_wide;
|
namespace standard_wide = boost::spirit::standard_wide;
|
||||||
using standard_wide::space_type;
|
using standard_wide::space_type;
|
||||||
|
@ -217,15 +219,17 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
||||||
| lit("false") [_val = false]
|
| lit("false") [_val = false]
|
||||||
| lit("null") [_val = value_null() ]
|
| lit("null") [_val = value_null() ]
|
||||||
| ustring [_val = unicode_(_1) ]
|
| ustring [_val = unicode_(_1) ]
|
||||||
| attr [_val = construct<attribute>( _1 ) ]
|
| attr [_val = construct<mapnik::attribute>( _1 ) ]
|
||||||
| '(' >> expr [_val = _1 ] >> ')'
|
| '(' >> expr [_val = _1 ] >> ')'
|
||||||
;
|
;
|
||||||
|
|
||||||
attr %= '[' >> +(char_ - ']') >> ']';
|
|
||||||
#if BOOST_VERSION > 104200
|
#if BOOST_VERSION > 104200
|
||||||
ustring %= '\'' >> no_skip[*~char_('\'')] >> '\'';
|
ustring %= '\'' >> no_skip[*~char_('\'')] >> '\'';
|
||||||
|
attr %= '[' >> no_skip[+~char_(']')] >> ']';
|
||||||
#else
|
#else
|
||||||
ustring %= '\'' >> lexeme[*(char_-'\'')] >> '\'';
|
ustring %= '\'' >> lexeme[*(char_-'\'')] >> '\'';
|
||||||
|
attr %= '[' >> lexeme[+(char_ - ']')] >> ']';
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/value.hpp>
|
#include <mapnik/value.hpp>
|
||||||
#include <mapnik/attribute.hpp>
|
#include <mapnik/attribute.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_EXPRESSION_STRING_HPP
|
#ifndef MAPNIK_EXPRESSION_STRING_HPP
|
||||||
#define MAPNIK_EXPRESSION_STRING_HPP
|
#define MAPNIK_EXPRESSION_STRING_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/expression_node.hpp>
|
#include <mapnik/expression_node.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,13 +20,12 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: factory.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
#ifndef MAPNIK_FACTORY_HPP
|
||||||
|
#define MAPNIK_FACTORY_HPP
|
||||||
#ifndef FACTORY_HPP
|
|
||||||
#define FACTORY_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/utils.hpp>
|
#include <mapnik/utils.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -89,4 +88,4 @@ public:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FACTORY_HPP
|
#endif // MAPNIK_FACTORY_HPP
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef FASTMATH_HPP
|
#ifndef MAPNIK_FASTMATH_HPP
|
||||||
#define FASTMATH_HPP
|
#define MAPNIK_FASTMATH_HPP
|
||||||
|
|
||||||
/* Timings:
|
/* Timings:
|
||||||
* fast_sin(not inlined) 8.95s
|
* fast_sin(not inlined) 8.95s
|
||||||
|
@ -109,4 +109,4 @@ static inline double fast_atan2(double y, double x)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FASTMATH_HPP
|
#endif // MAPNIK_FASTMATH_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,9 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: feature.hpp 40 2005-04-13 20:20:46Z pavlenko $
|
#ifndef MAPNIK_FEATURE_HPP
|
||||||
|
#define MAPNIK_FEATURE_HPP
|
||||||
|
|
||||||
#ifndef FEATURE_HPP
|
|
||||||
#define FEATURE_HPP
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/value.hpp>
|
#include <mapnik/value.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
|
@ -36,9 +35,9 @@
|
||||||
#else
|
#else
|
||||||
#include <boost/property_map.hpp>
|
#include <boost/property_map.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -66,6 +65,7 @@ private:
|
||||||
std::map<std::string,value> props_;
|
std::map<std::string,value> props_;
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string,value>::iterator iterator;
|
typedef std::map<std::string,value>::iterator iterator;
|
||||||
|
typedef std::map<std::string,value>::const_iterator const_iterator;
|
||||||
explicit feature(int id)
|
explicit feature(int id)
|
||||||
: properties(props_),
|
: properties(props_),
|
||||||
id_(id),
|
id_(id),
|
||||||
|
@ -157,11 +157,26 @@ public:
|
||||||
return props_.end();
|
return props_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const_iterator begin() const
|
||||||
|
{
|
||||||
|
return props_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator end() const
|
||||||
|
{
|
||||||
|
return props_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator find(std::string const& key) const
|
||||||
|
{
|
||||||
|
return props_.find(key);
|
||||||
|
}
|
||||||
|
|
||||||
std::string to_string() const
|
std::string to_string() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "feature (" << std::endl;
|
ss << "feature "
|
||||||
ss << " id:" << id_ << std::endl;
|
<< id_ << " (" << std::endl;
|
||||||
for (std::map<std::string,value>::const_iterator itr=props_.begin();
|
for (std::map<std::string,value>::const_iterator itr=props_.begin();
|
||||||
itr != props_.end();++itr)
|
itr != props_.end();++itr)
|
||||||
{
|
{
|
||||||
|
@ -181,4 +196,4 @@ inline std::ostream& operator<< (std::ostream & out,Feature const& f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FEATURE_HPP
|
#endif // MAPNIK_FEATURE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,12 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FEATURE_FACTORY_HPP
|
||||||
|
#define MAPNIK_FEATURE_FACTORY_HPP
|
||||||
#ifndef FEATURE_FACTORY_HPP
|
|
||||||
#define FEATURE_FACTORY_HPP
|
|
||||||
|
|
||||||
|
// mapnik
|
||||||
#include <mapnik/feature.hpp>
|
#include <mapnik/feature.hpp>
|
||||||
|
|
||||||
|
// boost
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
//#include <boost/pool/pool_alloc.hpp>
|
//#include <boost/pool/pool_alloc.hpp>
|
||||||
|
|
||||||
|
@ -39,8 +40,7 @@ struct feature_factory
|
||||||
//return boost::allocate_shared<Feature>(boost::fast_pool_allocator<Feature>(),fid);
|
//return boost::allocate_shared<Feature>(boost::fast_pool_allocator<Feature>(),fid);
|
||||||
return boost::make_shared<Feature>(fid);
|
return boost::make_shared<Feature>(fid);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FEATURE_FACTORY_HPP
|
#endif // MAPNIK_FEATURE_FACTORY_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FEATURE_LAYER_DESC_HPP
|
||||||
|
#define MAPNIK_FEATURE_LAYER_DESC_HPP
|
||||||
#ifndef FEATURE_LAYER_DESC_HPP
|
|
||||||
#define FEATURE_LAYER_DESC_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/attribute_descriptor.hpp>
|
#include <mapnik/attribute_descriptor.hpp>
|
||||||
|
|
||||||
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -106,4 +105,4 @@ operator << (std::basic_ostream<charT,traits>& out,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FEATURE_LAYER_DESC_HPP
|
#endif // MAPNIK_FEATURE_LAYER_DESC_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,8 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FEATURE_STYLE_PROCESSOR_HPP
|
||||||
|
#define MAPNIK_FEATURE_STYLE_PROCESSOR_HPP
|
||||||
#ifndef FEATURE_STYLE_PROCESSOR_HPP
|
|
||||||
#define FEATURE_STYLE_PROCESSOR_HPP
|
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/map.hpp>
|
#include <mapnik/map.hpp>
|
||||||
|
@ -94,4 +92,4 @@ private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FEATURE_STYLE_PROCESSOR_HPP
|
#endif // MAPNIK_FEATURE_STYLE_PROCESSOR_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,14 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FEATURE_TYPE_STYLE_HPP
|
||||||
|
#define MAPNIK_FEATURE_TYPE_STYLE_HPP
|
||||||
|
|
||||||
#ifndef FEATURE_TYPE_STYLE_HPP
|
|
||||||
#define FEATURE_TYPE_STYLE_HPP
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/rule.hpp>
|
#include <mapnik/rule.hpp>
|
||||||
#include <mapnik/feature.hpp>
|
#include <mapnik/feature.hpp>
|
||||||
#include <mapnik/enumeration.hpp>
|
#include <mapnik/enumeration.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -44,7 +44,8 @@ DEFINE_ENUM( filter_mode_e, filter_mode_enum );
|
||||||
|
|
||||||
typedef std::vector<rule> rules;
|
typedef std::vector<rule> rules;
|
||||||
typedef std::vector<rule*> rule_ptrs;
|
typedef std::vector<rule*> rule_ptrs;
|
||||||
class feature_type_style
|
|
||||||
|
class MAPNIK_DECL feature_type_style
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
rules rules_;
|
rules rules_;
|
||||||
|
@ -58,7 +59,7 @@ private:
|
||||||
public:
|
public:
|
||||||
feature_type_style();
|
feature_type_style();
|
||||||
|
|
||||||
feature_type_style(feature_type_style const& rhs);
|
feature_type_style(feature_type_style const& rhs, bool deep_copy = false);
|
||||||
|
|
||||||
feature_type_style& operator=(feature_type_style const& rhs);
|
feature_type_style& operator=(feature_type_style const& rhs);
|
||||||
|
|
||||||
|
@ -82,4 +83,4 @@ private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FEATURE_TYPE_STYLE_HPP
|
#endif // MAPNIK_FEATURE_TYPE_STYLE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,17 +20,16 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FILL_HPP
|
||||||
|
#define MAPNIK_FILL_HPP
|
||||||
#ifndef FILL_HPP
|
|
||||||
#define FILL_HPP
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
class fill
|
class fill
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //FILL_HPP
|
#endif // MAPNIK_FILL_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2009 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,14 +20,13 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_FILTER_FACTORY_HPP
|
#ifndef MAPNIK_FILTER_FACTORY_HPP
|
||||||
#define MAPNIK_FILTER_FACTORY_HPP
|
#define MAPNIK_FILTER_FACTORY_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/expression_node.hpp>
|
#include <mapnik/expression_node.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,11 +20,10 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
|
||||||
|
|
||||||
#ifndef MAPNIK_FILTER_FEATURESET_HPP
|
#ifndef MAPNIK_FILTER_FEATURESET_HPP
|
||||||
#define MAPNIK_FILTER_FEATURESET_HPP
|
#define MAPNIK_FILTER_FEATURESET_HPP
|
||||||
|
|
||||||
|
// mapnik
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,10 +20,9 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id$
|
#ifndef MAPNIK_FONT_ENGINE_FREETYPE_HPP
|
||||||
|
#define MAPNIK_FONT_ENGINE_FREETYPE_HPP
|
||||||
|
|
||||||
#ifndef FONT_ENGINE_FREETYPE_HPP
|
|
||||||
#define FONT_ENGINE_FREETYPE_HPP
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/color.hpp>
|
#include <mapnik/color.hpp>
|
||||||
#include <mapnik/utils.hpp>
|
#include <mapnik/utils.hpp>
|
||||||
|
@ -50,7 +49,6 @@ extern "C"
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -121,7 +119,13 @@ public:
|
||||||
{
|
{
|
||||||
if (! FT_Set_Pixel_Sizes( face_, 0, size ))
|
if (! FT_Set_Pixel_Sizes( face_, 0, size ))
|
||||||
return true;
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool set_character_sizes(float size)
|
||||||
|
{
|
||||||
|
if ( !FT_Set_Char_Size(face_,0,(FT_F26Dot6)(size * (1<<6)),0,0))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +190,14 @@ public:
|
||||||
(*face)->set_pixel_sizes(size);
|
(*face)->set_pixel_sizes(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_character_sizes(float size)
|
||||||
|
{
|
||||||
|
for (std::vector<face_ptr>::iterator face = faces_.begin(); face != faces_.end(); ++face)
|
||||||
|
{
|
||||||
|
(*face)->set_character_sizes(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::vector<face_ptr> faces_;
|
std::vector<face_ptr> faces_;
|
||||||
std::map<unsigned, dimension_t> dimension_cache_;
|
std::map<unsigned, dimension_t> dimension_cache_;
|
||||||
|
@ -200,7 +212,7 @@ public:
|
||||||
|
|
||||||
void init(double radius)
|
void init(double radius)
|
||||||
{
|
{
|
||||||
FT_Stroker_Set(s_,radius * (1<<6),
|
FT_Stroker_Set(s_, (FT_Fixed) (radius * (1<<6)),
|
||||||
FT_STROKER_LINECAP_ROUND,
|
FT_STROKER_LINECAP_ROUND,
|
||||||
FT_STROKER_LINEJOIN_ROUND,
|
FT_STROKER_LINEJOIN_ROUND,
|
||||||
0);
|
0);
|
||||||
|
@ -334,11 +346,17 @@ struct text_renderer : private boost::noncopyable
|
||||||
halo_radius_(0.0),
|
halo_radius_(0.0),
|
||||||
opacity_(1.0) {}
|
opacity_(1.0) {}
|
||||||
|
|
||||||
|
|
||||||
void set_pixel_size(unsigned size)
|
void set_pixel_size(unsigned size)
|
||||||
{
|
{
|
||||||
faces_->set_pixel_sizes(size);
|
faces_->set_pixel_sizes(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_character_size(float size)
|
||||||
|
{
|
||||||
|
faces_->set_character_sizes(size);
|
||||||
|
}
|
||||||
|
|
||||||
void set_fill(mapnik::color const& fill)
|
void set_fill(mapnik::color const& fill)
|
||||||
{
|
{
|
||||||
fill_=fill;
|
fill_=fill;
|
||||||
|
@ -602,4 +620,4 @@ private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FONT_ENGINE_FREETYPE_HPP
|
#endif // MAPNIK_FONT_ENGINE_FREETYPE_HPP
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue