switch back from mapnik2 to mapnik

add mapnik2 module which redirects to mapnik and issues DeprecationWarning
This commit is contained in:
Artem Pavlenko 2011-11-23 11:33:58 +00:00
parent e940fb374d
commit 14700dba16
72 changed files with 697 additions and 666 deletions

View file

@ -377,7 +377,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'),
@ -1024,9 +1024,9 @@ 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'])
@ -1752,7 +1752,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

View file

@ -40,9 +40,9 @@ 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')
@ -151,7 +151,11 @@ 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:
targetp = os.path.join(target_path,'paths.py') targetp = os.path.join(target_path,'paths.py')
@ -194,7 +198,7 @@ if env['SVN_REVISION']:
env2.Append(CXXFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION']) env2.Append(CXXFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION'])
sources.insert(0,env2.SharedObject('mapnik_python.cpp')) sources.insert(0,env2.SharedObject('mapnik_python.cpp'))
_mapnik = py_env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) _mapnik = py_env.LoadableModule('mapnik/_mapnik', 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']))
@ -213,4 +217,4 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
env['create_uninstall_target'](env, target_path) env['create_uninstall_target'](env, target_path)

View file

@ -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

View file

@ -25,7 +25,7 @@ from common import Version, copy_style, copy_layer
from exceptions import OGCException, ServerConfigurationError from exceptions import OGCException, ServerConfigurationError
from wms111 import ServiceHandler as ServiceHandler111 from wms111 import ServiceHandler as ServiceHandler111
from wms130 import ServiceHandler as ServiceHandler130 from wms130 import ServiceHandler as ServiceHandler130
from mapnik2 import Style, Map, load_map from mapnik import Style, Map, load_map
import re import re
import sys import sys
@ -122,4 +122,4 @@ class BaseWMSFactory:
for layer in self.layers.values(): for layer in self.layers.values():
for style in list(layer.styles) + list(layer.wmsextrastyles): for style in list(layer.styles) + list(layer.wmsextrastyles):
if style not in self.styles.keys() + self.aggregatestyles.keys(): if style not in self.styles.keys() + self.aggregatestyles.keys():
raise ServerConfigurationError('Layer "%s" refers to undefined style "%s".' % (layer.name, style)) raise ServerConfigurationError('Layer "%s" refers to undefined style "%s".' % (layer.name, style))

View file

@ -74,7 +74,7 @@ class Handler(cgi.DebugHandler):
if reqparams.has_key('service'): if reqparams.has_key('service'):
del reqparams['service'] del reqparams['service']
try: try:
mapnikmodule = __import__('mapnik2.ogcserver.' + service) mapnikmodule = __import__('mapnik.ogcserver.' + service)
except: except:
raise OGCException('Unsupported service "%s".' % service) raise OGCException('Unsupported service "%s".' % service)
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory
@ -113,4 +113,4 @@ def lowerparams(params):
reqparams = {} reqparams = {}
for key, value in params.items(): for key, value in params.items():
reqparams[key.lower()] = value reqparams[key.lower()] = value
return reqparams return reqparams

View file

@ -22,7 +22,7 @@
"""Core OGCServer classes and functions.""" """Core OGCServer classes and functions."""
from exceptions import OGCException, ServerConfigurationError from exceptions import OGCException, ServerConfigurationError
from mapnik2 import Map, Color, Box2d, render, Image, Layer, Style, Projection as MapnikProjection, Coord from mapnik import Map, Color, Box2d, render, Image, Layer, Style, Projection as MapnikProjection, Coord
from PIL.Image import new from PIL.Image import new
from PIL.ImageDraw import Draw from PIL.ImageDraw import Draw
from StringIO import StringIO from StringIO import StringIO

View file

@ -78,7 +78,7 @@ class ModHandler(object):
if reqparams.has_key('service'): if reqparams.has_key('service'):
del reqparams['service'] del reqparams['service']
try: try:
mapnikmodule = __import__('mapnik2.ogcserver.' + service) mapnikmodule = __import__('mapnik.ogcserver.' + service)
except: except:
raise OGCException('Unsupported service "%s".' % service) raise OGCException('Unsupported service "%s".' % service)
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory

View file

@ -25,7 +25,7 @@ from common import ParameterDefinition, Response, Version, ListFactory, \
ColorFactory, CRSFactory, WMSBaseServiceHandler, CRS, \ ColorFactory, CRSFactory, WMSBaseServiceHandler, CRS, \
BaseExceptionHandler, Projection BaseExceptionHandler, Projection
from exceptions import OGCException, ServerConfigurationError from exceptions import OGCException, ServerConfigurationError
from mapnik2 import Coord from mapnik import Coord
try: try:
from lxml import etree as ElementTree from lxml import etree as ElementTree

View file

@ -25,7 +25,7 @@ from common import ParameterDefinition, Response, Version, ListFactory, \
ColorFactory, CRSFactory, CRS, WMSBaseServiceHandler, \ ColorFactory, CRSFactory, CRS, WMSBaseServiceHandler, \
BaseExceptionHandler, Projection, Box2d BaseExceptionHandler, Projection, Box2d
from exceptions import OGCException, ServerConfigurationError from exceptions import OGCException, ServerConfigurationError
from mapnik2 import Coord from mapnik import Coord
try: try:
from lxml import etree as ElementTree from lxml import etree as ElementTree

View file

@ -72,7 +72,7 @@ class WSGIApp:
if reqparams.has_key('service'): if reqparams.has_key('service'):
del reqparams['service'] del reqparams['service']
try: try:
mapnikmodule = __import__('mapnik2.ogcserver.' + service) mapnikmodule = __import__('mapnik.ogcserver.' + service)
except: except:
raise OGCException('Unsupported service "%s".' % service) raise OGCException('Unsupported service "%s".' % service)
ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory ServiceHandlerFactory = getattr(mapnikmodule.ogcserver, service).ServiceHandlerFactory
@ -103,4 +103,4 @@ class WSGIApp:
response_headers.append(('Cache-Control', max_age)) response_headers.append(('Cache-Control', max_age))
start_response('200 OK', response_headers) start_response('200 OK', response_headers)
yield response.content yield response.content

View file

@ -4,15 +4,15 @@
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 __future__ import absolute_import

View 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)

View file

@ -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"
) )
; ;
} }

View file

@ -399,7 +399,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string
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_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;

View file

@ -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"
) )

View file

@ -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,

View file

@ -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"])
@ -50,4 +50,4 @@ Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
# we don't install this app because the datasource paths are relative # we don't install this app because the datasource paths are relative
# and we're not going to install the sample data. # and we're not going to install the sample data.
#env.Install(install_prefix + '/bin', rundemo) #env.Install(install_prefix + '/bin', rundemo)
#env.Alias('install', install_prefix + '/bin') #env.Alias('install', install_prefix + '/bin')

View file

@ -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;
} }

View file

@ -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 two maps, two PNGs, one JPEG.
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_ = []
@ -348,37 +348,37 @@ im.save('demo_low.jpg', 'jpeg50')
images_.append('demo_low.jpg') images_.append('demo_low.jpg')
# 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 +388,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")

View file

@ -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 = '''

View file

@ -44,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");

View file

@ -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

View file

@ -16,7 +16,7 @@ plugin_sources = Split(
) )
libraries = [] libraries = []
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
TARGET = plugin_env.SharedLibrary( TARGET = plugin_env.SharedLibrary(
@ -28,7 +28,7 @@ TARGET = plugin_env.SharedLibrary(
LINKFLAGS=env.get('CUSTOM_LDFLAGS') LINKFLAGS=env.get('CUSTOM_LDFLAGS')
) )
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -37,7 +37,7 @@ gdal_src = Split(
plugin_env['LIBS'] = [env['PLUGINS']['gdal']['lib']] plugin_env['LIBS'] = [env['PLUGINS']['gdal']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
plugin_env['LIBS'].append('mapnik2') plugin_env['LIBS'].append('mapnik')
plugin_env['LIBS'].append(env['ICU_LIB_NAME']) plugin_env['LIBS'].append(env['ICU_LIB_NAME'])
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
@ -47,7 +47,7 @@ if env['RUNTIME_LINK'] == 'static':
input_plugin = plugin_env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -37,14 +37,14 @@ geos_src = Split(
libraries = [env['PLUGINS']['geos']['lib']] libraries = [env['PLUGINS']['geos']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../geos', source=geos_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../geos', source=geos_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -35,14 +35,14 @@ kismet_src = Split(
libraries = [] libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
libraries.append('boost_thread%s' % env['BOOST_APPEND']) libraries.append('boost_thread%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -37,12 +37,12 @@ occi_src = Split(
) )
libraries = [ 'occi', 'ociei' ] libraries = [ 'occi', 'ociei' ]
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
input_plugin = plugin_env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -39,7 +39,7 @@ ogr_src = Split(
plugin_env['LIBS'] = [env['PLUGINS']['ogr']['lib']] plugin_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
plugin_env['LIBS'].append('mapnik2') plugin_env['LIBS'].append('mapnik')
plugin_env['LIBS'].append(env['ICU_LIB_NAME']) plugin_env['LIBS'].append(env['ICU_LIB_NAME'])
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND'])
plugin_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND']) plugin_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND'])
@ -51,7 +51,7 @@ if env['RUNTIME_LINK'] == 'static':
input_plugin = plugin_env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -39,12 +39,12 @@ osm_src = Split(
libraries = [ 'xml2' ] libraries = [ 'xml2' ]
libraries.append('curl') libraries.append('curl')
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -36,14 +36,14 @@ postgis_src = Split(
libraries = ['pq'] libraries = ['pq']
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
libraries.append('boost_thread%s' % env['BOOST_APPEND']) libraries.append('boost_thread%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -36,14 +36,14 @@ raster_src = Split(
libraries = [] libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -36,14 +36,14 @@ rasterlite_src = Split(
libraries = [env['PLUGINS']['rasterlite']['lib']] libraries = [env['PLUGINS']['rasterlite']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -40,7 +40,7 @@ shape_src = Split(
libraries = [] libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
@ -50,7 +50,7 @@ if env['SHAPE_MEMORY_MAPPED_FILE']:
input_plugin = plugin_env.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -36,7 +36,7 @@ sqlite_src = Split(
libraries = [ 'sqlite3' ] libraries = [ 'sqlite3' ]
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik2') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
@ -47,7 +47,7 @@ if env['SQLITE_LINKFLAGS']:
input_plugin = plugin_env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=linkflags) input_plugin = plugin_env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=linkflags)
# if the plugin links to libmapnik2 ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -23,7 +23,7 @@ Import ('env')
# main SConstruct file where configuration happens # main SConstruct file where configuration happens
# plugins can go anywhere, and be registered in custom locations by Mapnik # plugins can go anywhere, and be registered in custom locations by Mapnik
# but the standard location is '/usr/local/lib/mapnik2/input' # but the standard location is '/usr/local/lib/mapnik/input'
install_dest = env['MAPNIK_INPUT_PLUGINS_DEST'] install_dest = env['MAPNIK_INPUT_PLUGINS_DEST']
# clone the environment here # clone the environment here
@ -43,7 +43,7 @@ plugin_sources = Split(
# directly link to # directly link to
libraries = [ '' ] # eg 'libfoo' libraries = [ '' ] # eg 'libfoo'
libraries.append('mapnik2') libraries.append('mapnik')
# link libicuuc, but ICU_LIB_NAME is used custom builds of icu can # link libicuuc, but ICU_LIB_NAME is used custom builds of icu can
# have different library names like osx which offers /usr/lib/libicucore.dylib # have different library names like osx which offers /usr/lib/libicucore.dylib
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])

View file

@ -81,9 +81,9 @@ else:
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
mapnik_libname = 'libmapnik2.dylib' mapnik_libname = 'libmapnik.dylib'
else: else:
mapnik_libname = 'libmapnik2.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1])) mapnik_libname = 'libmapnik.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1]))
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
if env['FULL_LIB_PATH']: if env['FULL_LIB_PATH']:
@ -295,9 +295,9 @@ else:
linkflags = mapnik_lib_link_flag linkflags = mapnik_lib_link_flag
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
mapnik = lib_env.StaticLibrary('mapnik2', source, LINKFLAGS=linkflags) mapnik = lib_env.StaticLibrary('mapnik', source, LINKFLAGS=linkflags)
else: else:
mapnik = lib_env.SharedLibrary('mapnik2', source, LINKFLAGS=linkflags) mapnik = lib_env.SharedLibrary('mapnik', source, LINKFLAGS=linkflags)
# cache library values for other builds to use # cache library values for other builds to use
env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS']) env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS'])

View file

@ -9,7 +9,7 @@ test_env = env.Clone()
headers = env['CPPPATH'] headers = env['CPPPATH']
libraries = copy(env['LIBMAPNIK_LIBS']) libraries = copy(env['LIBMAPNIK_LIBS'])
libraries.append('mapnik2') libraries.append('mapnik')
for cpp_test in glob.glob('*_test.cpp'): for cpp_test in glob.glob('*_test.cpp'):
test_program = test_env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) test_program = test_env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])

View file

@ -11,8 +11,8 @@ system = 'boost_system%s' % env['BOOST_APPEND']
regex = 'boost_regex%s' % env['BOOST_APPEND'] regex = 'boost_regex%s' % env['BOOST_APPEND']
libraries = copy(env['LIBMAPNIK_LIBS']) libraries = copy(env['LIBMAPNIK_LIBS'])
libraries.append('mapnik2') libraries.append('mapnik')
for cpp_test in glob.glob('*_test.cpp'): for cpp_test in glob.glob('*_test.cpp'):
test_program = env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) test_program = env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
Depends(test_program, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(test_program, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -26,7 +26,7 @@ using namespace mapnik;
void prepare_map(Map& m) void prepare_map(Map& m)
{ {
const std::string mapnik_dir("/usr/local/lib/mapnik2/"); const std::string mapnik_dir("/usr/local/lib/mapnik/");
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "input/" << "\n"; std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "input/" << "\n";
datasource_cache::instance()->register_datasources(mapnik_dir + "input/"); datasource_cache::instance()->register_datasources(mapnik_dir + "input/");

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import mapnik2 import mapnik
from nose.tools import * from nose.tools import *
from utilities import execution_path,Todo from utilities import execution_path,Todo
@ -11,13 +11,13 @@ def setup():
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
def _pycairo_surface(type,sym): def _pycairo_surface(type,sym):
if mapnik2.has_pycairo(): if mapnik.has_pycairo():
import cairo import cairo
test_cairo_file = 'test.%s' % type test_cairo_file = 'test.%s' % type
m = mapnik2.Map(256,256) m = mapnik.Map(256,256)
mapnik2.load_map(m,'../data/good_maps/%s_symbolizer.xml' % sym) mapnik.load_map(m,'../data/good_maps/%s_symbolizer.xml' % sym)
surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height) surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height)
mapnik2.render(m, surface) mapnik.render(m, surface)
surface.finish() surface.finish()
if os.path.exists(test_cairo_file): if os.path.exists(test_cairo_file):

View file

@ -5,7 +5,7 @@ import glob
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import os, mapnik2 import os, mapnik
def setup(): def setup():
@ -13,10 +13,10 @@ def setup():
# from another directory we need to chdir() # from another directory we need to chdir()
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
if 'csv' in mapnik2.DatasourceCache.instance().plugin_names(): if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
def get_csv_ds(filename): def get_csv_ds(filename):
return mapnik2.Datasource(type='csv',file=os.path.join('../data/csv/',filename),quiet=True) return mapnik.Datasource(type='csv',file=os.path.join('../data/csv/',filename),quiet=True)
def test_broken_files(visual=False): def test_broken_files(visual=False):
broken = glob.glob("../data/csv/fails/*.*") broken = glob.glob("../data/csv/fails/*.*")
@ -29,7 +29,7 @@ if 'csv' in mapnik2.DatasourceCache.instance().plugin_names():
throws = False throws = False
if visual: if visual:
try: try:
ds = mapnik2.Datasource(type='csv',file=csv,strict=True,quiet=True) ds = mapnik.Datasource(type='csv',file=csv,strict=True,quiet=True)
print '\x1b[33mfailed\x1b[0m',csv print '\x1b[33mfailed\x1b[0m',csv
except Exception: except Exception:
print '\x1b[1;32m✓ \x1b[0m', csv print '\x1b[1;32m✓ \x1b[0m', csv
@ -41,7 +41,7 @@ if 'csv' in mapnik2.DatasourceCache.instance().plugin_names():
for csv in good_files: for csv in good_files:
if visual: if visual:
try: try:
ds = mapnik2.Datasource(type='csv',file=csv,quiet=True) ds = mapnik.Datasource(type='csv',file=csv,quiet=True)
print '\x1b[1;32m✓ \x1b[0m', csv print '\x1b[1;32m✓ \x1b[0m', csv
except Exception: except Exception:
print '\x1b[33mfailed\x1b[0m',csv print '\x1b[33mfailed\x1b[0m',csv
@ -92,24 +92,24 @@ if 'csv' in mapnik2.DatasourceCache.instance().plugin_names():
fs = ds.all_features() fs = ds.all_features()
#import pdb;pdb.set_trace() #import pdb;pdb.set_trace()
eq_(len(fs[0].geometries()),1) eq_(len(fs[0].geometries()),1)
eq_(fs[0].geometries()[0].type(),mapnik2.GeometryType.Point) eq_(fs[0].geometries()[0].type(),mapnik.GeometryType.Point)
eq_(len(fs[1].geometries()),1) eq_(len(fs[1].geometries()),1)
eq_(fs[1].geometries()[0].type(),mapnik2.GeometryType.LineString) eq_(fs[1].geometries()[0].type(),mapnik.GeometryType.LineString)
eq_(len(fs[2].geometries()),1) eq_(len(fs[2].geometries()),1)
eq_(fs[2].geometries()[0].type(),mapnik2.GeometryType.Polygon) eq_(fs[2].geometries()[0].type(),mapnik.GeometryType.Polygon)
eq_(len(fs[3].geometries()),1) # one geometry, two parts eq_(len(fs[3].geometries()),1) # one geometry, two parts
eq_(fs[3].geometries()[0].type(),mapnik2.GeometryType.Polygon) eq_(fs[3].geometries()[0].type(),mapnik.GeometryType.Polygon)
# tests assuming we want to flatten geometries # tests assuming we want to flatten geometries
# ideally we should not have to: # ideally we should not have to:
# https://github.com/mapnik/mapnik/issues?labels=multigeom+robustness&sort=created&direction=desc&state=open&page=1 # https://github.com/mapnik/mapnik/issues?labels=multigeom+robustness&sort=created&direction=desc&state=open&page=1
eq_(len(fs[4].geometries()),4) eq_(len(fs[4].geometries()),4)
eq_(fs[4].geometries()[0].type(),mapnik2.GeometryType.Point) eq_(fs[4].geometries()[0].type(),mapnik.GeometryType.Point)
eq_(len(fs[5].geometries()),2) eq_(len(fs[5].geometries()),2)
eq_(fs[5].geometries()[0].type(),mapnik2.GeometryType.LineString) eq_(fs[5].geometries()[0].type(),mapnik.GeometryType.LineString)
eq_(len(fs[6].geometries()),2) eq_(len(fs[6].geometries()),2)
eq_(fs[6].geometries()[0].type(),mapnik2.GeometryType.Polygon) eq_(fs[6].geometries()[0].type(),mapnik.GeometryType.Polygon)
eq_(len(fs[7].geometries()),2) eq_(len(fs[7].geometries()),2)
eq_(fs[7].geometries()[0].type(),mapnik2.GeometryType.Polygon) eq_(fs[7].geometries()[0].type(),mapnik.GeometryType.Polygon)
def test_handling_of_missing_header(**kwargs): def test_handling_of_missing_header(**kwargs):
@ -132,7 +132,7 @@ if 'csv' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feat['1991'],2) eq_(feat['1991'],2)
eq_(feat['1992'],3) eq_(feat['1992'],3)
eq_(mapnik2.Expression("[1991]=2").evaluate(feat),True) eq_(mapnik.Expression("[1991]=2").evaluate(feat),True)
def test_quoted_numbers(**kwargs): def test_quoted_numbers(**kwargs):
ds = get_csv_ds('points.csv') ds = get_csv_ds('points.csv')

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import os, mapnik2 import os, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -11,45 +11,45 @@ def setup():
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
def test_that_datasources_exist(): def test_that_datasources_exist():
if len(mapnik2.DatasourceCache.instance().plugin_names()) == 0: if len(mapnik.DatasourceCache.instance().plugin_names()) == 0:
print '***NOTICE*** - no datasource plugins have been loaded' print '***NOTICE*** - no datasource plugins have been loaded'
def test_field_listing(): def test_field_listing():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'shape' in mapnik2.DatasourceCache.instance().plugin_names(): if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Shapefile(file='../data/shp/poly.shp') lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
fields = lyr.datasource.fields() fields = lyr.datasource.fields()
eq_(fields, ['AREA', 'EAS_ID', 'PRFEDEA']) eq_(fields, ['AREA', 'EAS_ID', 'PRFEDEA'])
def test_total_feature_count_shp(): def test_total_feature_count_shp():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'shape' in mapnik2.DatasourceCache.instance().plugin_names(): if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Shapefile(file='../data/shp/poly.shp') lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
num_feats = len(features) num_feats = len(features)
eq_(num_feats, 10) eq_(num_feats, 10)
def test_total_feature_count_json(): def test_total_feature_count_json():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'ogr' in mapnik2.DatasourceCache.instance().plugin_names(): if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Ogr(file='../data/json/points.json',layer_by_index=0) lyr.datasource = mapnik.Ogr(file='../data/json/points.json',layer_by_index=0)
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
num_feats = len(features) num_feats = len(features)
eq_(num_feats, 5) eq_(num_feats, 5)
def test_reading_json_from_string(): def test_reading_json_from_string():
json = open('../data/json/points.json','r').read() json = open('../data/json/points.json','r').read()
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'ogr' in mapnik2.DatasourceCache.instance().plugin_names(): if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Ogr(file=json,layer_by_index=0) lyr.datasource = mapnik.Ogr(file=json,layer_by_index=0)
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
num_feats = len(features) num_feats = len(features)
eq_(num_feats, 5) eq_(num_feats, 5)
def test_feature_envelope(): def test_feature_envelope():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'shape' in mapnik2.DatasourceCache.instance().plugin_names(): if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Shapefile(file='../data/shp/poly.shp') lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
for feat in features: for feat in features:
env = feat.envelope() env = feat.envelope()
@ -59,9 +59,9 @@ def test_feature_envelope():
eq_(intersects, True) eq_(intersects, True)
def test_feature_attributes(): def test_feature_attributes():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'shape' in mapnik2.DatasourceCache.instance().plugin_names(): if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Shapefile(file='../data/shp/poly.shp') lyr.datasource = mapnik.Shapefile(file='../data/shp/poly.shp')
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
feat = features[0] feat = features[0]
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266} attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
@ -70,9 +70,9 @@ def test_feature_attributes():
eq_(lyr.datasource.field_types(),['float','int','str']) eq_(lyr.datasource.field_types(),['float','int','str'])
def test_ogr_layer_by_sql(): def test_ogr_layer_by_sql():
lyr = mapnik2.Layer('test') lyr = mapnik.Layer('test')
if 'ogr' in mapnik2.DatasourceCache.instance().plugin_names(): if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Ogr(file='../data/shp/poly.shp', layer_by_sql='SELECT * FROM poly WHERE EAS_ID = 168') lyr.datasource = mapnik.Ogr(file='../data/shp/poly.shp', layer_by_sql='SELECT * FROM poly WHERE EAS_ID = 168')
features = lyr.datasource.all_features() features = lyr.datasource.all_features()
num_feats = len(features) num_feats = len(features)
eq_(num_feats, 1) eq_(num_feats, 1)
@ -85,9 +85,9 @@ def test_hit_grid():
""" encode a list of strings with run-length compression """ """ encode a list of strings with run-length compression """
return ["%d:%s" % (len(list(group)), name) for name, group in groupby(l)] return ["%d:%s" % (len(list(group)), name) for name, group in groupby(l)]
m = mapnik2.Map(256,256); m = mapnik.Map(256,256);
try: try:
mapnik2.load_map(m,'../data/good_maps/agg_poly_gamma_map.xml'); mapnik.load_map(m,'../data/good_maps/agg_poly_gamma_map.xml');
m.zoom_all() m.zoom_all()
join_field = 'NAME' join_field = 'NAME'
fg = [] # feature grid fg = [] # feature grid

View file

@ -4,7 +4,7 @@ from nose.tools import *
from utilities import execution_path, Todo from utilities import execution_path, Todo
import os, sys, glob, mapnik2 import os, sys, glob, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -12,10 +12,10 @@ def setup():
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
def compare_shape_between_mapnik_and_ogr(shapefile,query=None): def compare_shape_between_mapnik_and_ogr(shapefile,query=None):
plugins = mapnik2.DatasourceCache.instance().plugin_names() plugins = mapnik.DatasourceCache.instance().plugin_names()
if 'shape' in plugins and 'ogr' in plugins: if 'shape' in plugins and 'ogr' in plugins:
ds1 = mapnik2.Ogr(file=shapefile,layer_by_index=0) ds1 = mapnik.Ogr(file=shapefile,layer_by_index=0)
ds2 = mapnik2.Shapefile(file=shapefile) ds2 = mapnik.Shapefile(file=shapefile)
if query: if query:
fs1 = ds1.features(query) fs1 = ds1.features(query)
fs2 = ds2.features(query) fs2 = ds2.features(query)
@ -46,9 +46,9 @@ def test_shapefile_polygon_featureset_id():
def test_shapefile_polygon_feature_query_id(): def test_shapefile_polygon_feature_query_id():
bbox = (15523428.2632, 4110477.6323, -11218494.8310, 7495720.7404) bbox = (15523428.2632, 4110477.6323, -11218494.8310, 7495720.7404)
query = mapnik2.Query(mapnik2.Box2d(*bbox)) query = mapnik.Query(mapnik.Box2d(*bbox))
if 'ogr' in mapnik2.DatasourceCache.instance().plugin_names(): if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
ds = mapnik2.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0) ds = mapnik.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0)
for fld in ds.fields(): for fld in ds.fields():
query.add_property_name(fld) query.add_property_name(fld)
compare_shape_between_mapnik_and_ogr('../data/shp/world_merc.shp',query) compare_shape_between_mapnik_and_ogr('../data/shp/world_merc.shp',query)
@ -58,12 +58,12 @@ def test_feature_hit_count():
# results in different results between shp and ogr! # results in different results between shp and ogr!
#bbox = (-14284551.8434, 2074195.1992, -7474929.8687, 8140237.7628) #bbox = (-14284551.8434, 2074195.1992, -7474929.8687, 8140237.7628)
bbox = (1113194.91,4512803.085,2226389.82,6739192.905) bbox = (1113194.91,4512803.085,2226389.82,6739192.905)
query = mapnik2.Query(mapnik2.Box2d(*bbox)) query = mapnik.Query(mapnik.Box2d(*bbox))
if 'ogr' in mapnik2.DatasourceCache.instance().plugin_names(): if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
ds1 = mapnik2.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0) ds1 = mapnik.Ogr(file='../data/shp/world_merc.shp',layer_by_index=0)
for fld in ds1.fields(): for fld in ds1.fields():
query.add_property_name(fld) query.add_property_name(fld)
ds2 = mapnik2.Shapefile(file='../data/shp/world_merc.shp') ds2 = mapnik.Shapefile(file='../data/shp/world_merc.shp')
count1 = len(ds1.features(query).features) count1 = len(ds1.features(query).features)
count2 = len(ds2.features(query).features) count2 = len(ds2.features(query).features)
eq_(count1,count2,"Feature count differs between OGR driver (%s features) and Shapefile Driver (%s features) when querying the same bbox" % (count1,count2)) eq_(count1,count2,"Feature count differs between OGR driver (%s features) and Shapefile Driver (%s features) when querying the same bbox" % (count1,count2))

View file

@ -3,13 +3,13 @@ import itertools
import unittest import unittest
from nose.tools import * from nose.tools import *
import mapnik2 import mapnik
from binascii import unhexlify from binascii import unhexlify
from utilities import Todo from utilities import Todo
class FeatureTest(unittest.TestCase): class FeatureTest(unittest.TestCase):
def makeOne(self, *args, **kw): def makeOne(self, *args, **kw):
return mapnik2.Feature(*args, **kw) return mapnik.Feature(*args, **kw)
def test_default_constructor(self): def test_default_constructor(self):
f = self.makeOne(1) f = self.makeOne(1)
@ -18,7 +18,7 @@ class FeatureTest(unittest.TestCase):
def test_python_extended_constructor(self): def test_python_extended_constructor(self):
f = self.makeOne(1, 'POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10),(20 30, 35 35, 30 20, 20 30))', foo="bar") f = self.makeOne(1, 'POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10),(20 30, 35 35, 30 20, 20 30))', foo="bar")
self.failUnlessEqual(f['foo'], 'bar') self.failUnlessEqual(f['foo'], 'bar')
self.failUnlessEqual(f.envelope(),mapnik2.Box2d(10.0,10.0,45.0,45.0)) self.failUnlessEqual(f.envelope(),mapnik.Box2d(10.0,10.0,45.0,45.0))
def test_set_get_properties(self): def test_set_get_properties(self):
f = self.makeOne(1) f = self.makeOne(1)
@ -39,7 +39,7 @@ class FeatureTest(unittest.TestCase):
self.failUnlessEqual(len(f.geometries()), 0) self.failUnlessEqual(len(f.geometries()), 0)
f.add_geometries_from_wkt(wkt) f.add_geometries_from_wkt(wkt)
self.failUnlessEqual(len(f.geometries()), 3) self.failUnlessEqual(len(f.geometries()), 3)
e = mapnik2.Box2d() e = mapnik.Box2d()
self.failUnlessEqual(e.valid(), False) self.failUnlessEqual(e.valid(), False)
for g in f.geometries(): for g in f.geometries():
if not e.valid(): if not e.valid():
@ -54,7 +54,7 @@ class FeatureTest(unittest.TestCase):
self.failUnlessEqual(len(f.geometries()), 0) self.failUnlessEqual(len(f.geometries()), 0)
f.add_geometries_from_wkb(unhexlify(wkb)) f.add_geometries_from_wkb(unhexlify(wkb))
self.failUnlessEqual(len(f.geometries()), 1) self.failUnlessEqual(len(f.geometries()), 1)
e = mapnik2.Box2d() e = mapnik.Box2d()
self.failUnlessEqual(e.valid(), False) self.failUnlessEqual(e.valid(), False)
for g in f.geometries(): for g in f.geometries():
if not e.valid(): if not e.valid():
@ -71,10 +71,10 @@ class FeatureTest(unittest.TestCase):
def test_feature_expression_evaluation(): def test_feature_expression_evaluation():
f = mapnik2.Feature(1) f = mapnik.Feature(1)
f['name'] = 'a' f['name'] = 'a'
eq_(f['name'],u'a') eq_(f['name'],u'a')
expr = mapnik2.Expression("[name]='a'") expr = mapnik.Expression("[name]='a'")
evaluated = expr.evaluate(f) evaluated = expr.evaluate(f)
eq_(evaluated,True) eq_(evaluated,True)
num_attributes = len(f) num_attributes = len(f)
@ -83,10 +83,10 @@ def test_feature_expression_evaluation():
# https://github.com/mapnik/mapnik/issues/933 # https://github.com/mapnik/mapnik/issues/933
def test_feature_expression_evaluation_missing_attr(): def test_feature_expression_evaluation_missing_attr():
f = mapnik2.Feature(1) f = mapnik.Feature(1)
f['name'] = u'a' f['name'] = u'a'
eq_(f['name'],u'a') eq_(f['name'],u'a')
expr = mapnik2.Expression("[fielddoesnotexist]='a'") expr = mapnik.Expression("[fielddoesnotexist]='a'")
evaluated = expr.evaluate(f) evaluated = expr.evaluate(f)
eq_(evaluated,False) eq_(evaluated,False)
num_attributes = len(f) num_attributes = len(f)
@ -95,10 +95,10 @@ def test_feature_expression_evaluation_missing_attr():
# https://github.com/mapnik/mapnik/issues/934 # https://github.com/mapnik/mapnik/issues/934
def test_feature_expression_evaluation_attr_with_spaces(): def test_feature_expression_evaluation_attr_with_spaces():
f = mapnik2.Feature(1) f = mapnik.Feature(1)
f['name with space'] = u'a' f['name with space'] = u'a'
eq_(f['name with space'],u'a') eq_(f['name with space'],u'a')
expr = mapnik2.Expression("[name with space]='a'") expr = mapnik.Expression("[name with space]='a'")
eq_(str(expr),"([name with space]='a')") eq_(str(expr),"([name with space]='a')")
eq_(expr.evaluate(f),True) eq_(expr.evaluate(f),True)

View file

@ -4,10 +4,10 @@
from nose.tools import * from nose.tools import *
from utilities import Todo from utilities import Todo
import mapnik2 import mapnik
if hasattr(mapnik2,'Expression'): if hasattr(mapnik,'Expression'):
mapnik2.Filter = mapnik2.Expression mapnik.Filter = mapnik.Expression
map_ = '''<Map> map_ = '''<Map>
<Style name="s"> <Style name="s">
@ -52,25 +52,25 @@ map_ = '''<Map>
</Map>''' </Map>'''
def test_filter_init(): def test_filter_init():
m = mapnik2.Map(1,1) m = mapnik.Map(1,1)
mapnik2.load_map_from_string(m,map_) mapnik.load_map_from_string(m,map_)
filters = [] filters = []
filters.append(mapnik2.Filter("([region]>=0) and ([region]<=50)")) filters.append(mapnik.Filter("([region]>=0) and ([region]<=50)"))
filters.append(mapnik2.Filter("(([region]>=0) and ([region]<=50))")) filters.append(mapnik.Filter("(([region]>=0) and ([region]<=50))"))
filters.append(mapnik2.Filter("((([region]>=0) and ([region]<=50)))")) filters.append(mapnik.Filter("((([region]>=0) and ([region]<=50)))"))
filters.append(mapnik2.Filter('((([region]>=0) and ([region]<=50)))')) filters.append(mapnik.Filter('((([region]>=0) and ([region]<=50)))'))
filters.append(mapnik2.Filter('''((([region]>=0) and ([region]<=50)))''')) filters.append(mapnik.Filter('''((([region]>=0) and ([region]<=50)))'''))
filters.append(mapnik2.Filter(''' filters.append(mapnik.Filter('''
((([region]>=0) ((([region]>=0)
and and
([region]<=50))) ([region]<=50)))
''')) '''))
filters.append(mapnik2.Filter(''' filters.append(mapnik.Filter('''
([region]>=0) ([region]>=0)
and and
([region]<=50) ([region]<=50)
''')) '''))
filters.append(mapnik2.Filter(''' filters.append(mapnik.Filter('''
([region] ([region]
>= >=
0) 0)
@ -91,31 +91,31 @@ def test_filter_init():
s = m.find_style('s2') s = m.find_style('s2')
eq_(s.filter_mode,mapnik2.filter_mode.FIRST) eq_(s.filter_mode,mapnik.filter_mode.FIRST)
def test_regex_match(): def test_regex_match():
f = mapnik2.Feature(0) f = mapnik.Feature(0)
f["name"] = 'test' f["name"] = 'test'
expr = mapnik2.Expression("[name].match('test')") expr = mapnik.Expression("[name].match('test')")
eq_(expr.evaluate(f),True) # 1 == True eq_(expr.evaluate(f),True) # 1 == True
def test_unicode_regex_match(): def test_unicode_regex_match():
f = mapnik2.Feature(0) f = mapnik.Feature(0)
f["name"] = 'Québec' f["name"] = 'Québec'
expr = mapnik2.Expression("[name].match('Québec')") expr = mapnik.Expression("[name].match('Québec')")
eq_(expr.evaluate(f),True) # 1 == True eq_(expr.evaluate(f),True) # 1 == True
def test_regex_replace(): def test_regex_replace():
f = mapnik2.Feature(0) f = mapnik.Feature(0)
f["name"] = 'test' f["name"] = 'test'
expr = mapnik2.Expression("[name].replace('(\B)|( )','$1 ')") expr = mapnik.Expression("[name].replace('(\B)|( )','$1 ')")
eq_(expr.evaluate(f),'t e s t') eq_(expr.evaluate(f),'t e s t')
def test_unicode_regex_replace(): def test_unicode_regex_replace():
f = mapnik2.Feature(0) f = mapnik.Feature(0)
f["name"] = 'Québec' f["name"] = 'Québec'
expr = mapnik2.Expression("[name].replace('(\B)|( )','$1 ')") expr = mapnik.Expression("[name].replace('(\B)|( )','$1 ')")
eq_(expr.evaluate(f), u'Q u é b e c') eq_(expr.evaluate(f), u'Q u é b e c')
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -2,7 +2,7 @@
from nose.tools import * from nose.tools import *
import mapnik2, pickle import mapnik, pickle
# Tests that exercise fonts. # Tests that exercise fonts.
@ -10,7 +10,7 @@ import mapnik2, pickle
# Todo: Add logic to use this TextSymbolizer in a rendering # Todo: Add logic to use this TextSymbolizer in a rendering
#@raises(UserWarning) #@raises(UserWarning)
#def test_invalid_font(): #def test_invalid_font():
# ts = mapnik2.TextSymbolizer('Name', 'Invalid Font Name', int(8), mapnik2.Color('black')) # ts = mapnik.TextSymbolizer('Name', 'Invalid Font Name', int(8), mapnik.Color('black'))
if __name__ == "__main__": if __name__ == "__main__":
[eval(run)() for run in dir() if 'test_' in run] [eval(run)() for run in dir() if 'test_' in run]

View file

@ -5,55 +5,55 @@ from nose.tools import *
from utilities import execution_path, save_data, contains_word from utilities import execution_path, save_data, contains_word
import os, mapnik2 import os, mapnik
def test_renders_with_agg(): def test_renders_with_agg():
sym = mapnik2.GlyphSymbolizer("DejaVu Sans Condensed", sym = mapnik.GlyphSymbolizer("DejaVu Sans Condensed",
mapnik2.Expression("'í'")) mapnik.Expression("'í'"))
sym.allow_overlap = True sym.allow_overlap = True
sym.angle = mapnik2.Expression("[azimuth]+90") #+90 so the top of the glyph points upwards sym.angle = mapnik.Expression("[azimuth]+90") #+90 so the top of the glyph points upwards
sym.size = mapnik2.Expression("[value]") sym.size = mapnik.Expression("[value]")
sym.color = mapnik2.Expression("'#ff0000'") sym.color = mapnik.Expression("'#ff0000'")
_map = create_map_and_append_symbolyzer(sym) _map = create_map_and_append_symbolyzer(sym)
if _map: if _map:
im = mapnik2.Image(_map.width,_map.height) im = mapnik.Image(_map.width,_map.height)
mapnik2.render(_map, im) mapnik.render(_map, im)
save_data('agg_glyph_symbolizer.png', im.tostring('png')) save_data('agg_glyph_symbolizer.png', im.tostring('png'))
assert contains_word('\xff\x00\x00\xff', im.tostring()) assert contains_word('\xff\x00\x00\xff', im.tostring())
def test_renders_with_cairo(): def test_renders_with_cairo():
if not mapnik2.has_pycairo(): if not mapnik.has_pycairo():
return return
sym = mapnik2.GlyphSymbolizer("DejaVu Sans Condensed", sym = mapnik.GlyphSymbolizer("DejaVu Sans Condensed",
mapnik2.Expression("'í'")) mapnik.Expression("'í'"))
sym.allow_overlap = True sym.allow_overlap = True
sym.angle = mapnik2.Expression("[azimuth]+90") #+90 so the top of the glyph points upwards sym.angle = mapnik.Expression("[azimuth]+90") #+90 so the top of the glyph points upwards
sym.size = mapnik2.Expression("[value]") sym.size = mapnik.Expression("[value]")
sym.color = mapnik2.Expression("'#ff0000'") sym.color = mapnik.Expression("'#ff0000'")
_map = create_map_and_append_symbolyzer(sym) _map = create_map_and_append_symbolyzer(sym)
if _map: if _map:
from cStringIO import StringIO from cStringIO import StringIO
import cairo import cairo
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256)
mapnik2.render(_map, surface) mapnik.render(_map, surface)
im = mapnik2.Image.from_cairo(surface) im = mapnik.Image.from_cairo(surface)
save_data('cairo_glyph_symbolizer.png', im.tostring('png')) save_data('cairo_glyph_symbolizer.png', im.tostring('png'))
assert contains_word('\xff\x00\x00\xff', im.tostring()) assert contains_word('\xff\x00\x00\xff', im.tostring())
def test_load_save_load_map(): def test_load_save_load_map():
map = mapnik2.Map(256,256) map = mapnik.Map(256,256)
in_map = "../data/good_maps/glyph_symbolizer.xml" in_map = "../data/good_maps/glyph_symbolizer.xml"
try: try:
mapnik2.load_map(map, in_map) mapnik.load_map(map, in_map)
style = map.find_style('arrows') style = map.find_style('arrows')
sym = style.rules[0].symbols[0] sym = style.rules[0].symbols[0]
assert isinstance(sym, mapnik2.GlyphSymbolizer) assert isinstance(sym, mapnik.GlyphSymbolizer)
assert sym.angle_mode == mapnik2.angle_mode.AZIMUTH assert sym.angle_mode == mapnik.angle_mode.AZIMUTH
out_map = mapnik2.save_map_to_string(map).decode('utf8') out_map = mapnik.save_map_to_string(map).decode('utf8')
map = mapnik2.Map(256,256) map = mapnik.Map(256,256)
mapnik2.load_map_from_string(map, out_map.encode('utf8')) mapnik.load_map_from_string(map, out_map.encode('utf8'))
assert 'GlyphSymbolizer' in out_map assert 'GlyphSymbolizer' in out_map
# make sure non-ascii characters are well supported since most interesting # make sure non-ascii characters are well supported since most interesting
# glyphs for symbology are usually in that range # glyphs for symbology are usually in that range
@ -74,22 +74,22 @@ def setup():
def create_map_and_append_symbolyzer(sym): def create_map_and_append_symbolyzer(sym):
srs = '+init=epsg:32630' srs = '+init=epsg:32630'
lyr = mapnik2.Layer('arrows') lyr = mapnik.Layer('arrows')
try: try:
lyr.datasource = mapnik2.Shapefile( lyr.datasource = mapnik.Shapefile(
file = '../data/shp/arrows.shp', file = '../data/shp/arrows.shp',
) )
lyr.srs = srs lyr.srs = srs
_map = mapnik2.Map(256,256, srs) _map = mapnik.Map(256,256, srs)
style = mapnik2.Style() style = mapnik.Style()
rule = mapnik2.Rule() rule = mapnik.Rule()
rule.symbols.append(sym) rule.symbols.append(sym)
# put a test symbolizer to see what is the azimuth being read # put a test symbolizer to see what is the azimuth being read
ts = mapnik2.TextSymbolizer(mapnik2.Expression('[azimuth]'), ts = mapnik.TextSymbolizer(mapnik.Expression('[azimuth]'),
"DejaVu Sans Book", "DejaVu Sans Book",
10, 10,
mapnik2.Color("black")) mapnik.Color("black"))
ts.allow_overlap = True ts.allow_overlap = True
rule.symbols.append(ts) rule.symbols.append(ts)
@ -97,7 +97,7 @@ def create_map_and_append_symbolyzer(sym):
_map.append_style('foo', style) _map.append_style('foo', style)
lyr.styles.append('foo') lyr.styles.append('foo')
_map.layers.append(lyr) _map.layers.append(lyr)
_map.zoom_to_box(mapnik2.Box2d(0,0,8,8)) _map.zoom_to_box(mapnik.Box2d(0,0,8,8))
return _map return _map
except RuntimeError, e: except RuntimeError, e:
# only test datasources that we have installed # only test datasources that we have installed

View file

@ -5,7 +5,7 @@ from nose.tools import *
from utilities import execution_path from utilities import execution_path
from utilities import Todo from utilities import Todo
import mapnik2 import mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -14,7 +14,7 @@ def setup():
def test_introspect_symbolizers(): def test_introspect_symbolizers():
# create a symbolizer # create a symbolizer
p = mapnik2.PointSymbolizer(mapnik2.PathExpression("../data/images/dummy.png")) p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
p.allow_overlap = True p.allow_overlap = True
p.opacity = 0.5 p.opacity = 0.5
@ -29,11 +29,11 @@ def test_introspect_symbolizers():
eq_(p.filename,'../data/images/dummy.png') eq_(p.filename,'../data/images/dummy.png')
# contruct objects to hold it # contruct objects to hold it
r = mapnik2.Rule() r = mapnik.Rule()
r.symbols.append(p) r.symbols.append(p)
s = mapnik2.Style() s = mapnik.Style()
s.rules.append(r) s.rules.append(r)
m = mapnik2.Map(0,0) m = mapnik.Map(0,0)
m.append_style('s',s) m.append_style('s',s)
# try to figure out what is # try to figure out what is
@ -51,7 +51,7 @@ def test_introspect_symbolizers():
sym = syms[0] sym = syms[0]
# this is hackish at best # this is hackish at best
p2 = sym.symbol() p2 = sym.symbol()
assert isinstance(p2,mapnik2.PointSymbolizer) assert isinstance(p2,mapnik.PointSymbolizer)
eq_(p2.allow_overlap, True) eq_(p2.allow_overlap, True)
eq_(p2.opacity, 0.5) eq_(p2.opacity, 0.5)
@ -60,7 +60,7 @@ def test_introspect_symbolizers():
## but we need to be able to do: ## but we need to be able to do:
p2 = syms[0] # get the actual symbolizer, not the variant object p2 = syms[0] # get the actual symbolizer, not the variant object
# this will throw for now... # this will throw for now...
assert isinstance(p2,mapnik2.PointSymbolizer) assert isinstance(p2,mapnik.PointSymbolizer)
eq_(p2.allow_overlap, True) eq_(p2.allow_overlap, True)
eq_(p2.opacity, 0.5) eq_(p2.opacity, 0.5)

View file

@ -5,7 +5,7 @@ from nose.tools import *
import os import os
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import mapnik2 import mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -30,10 +30,10 @@ def test_adding_datasource_to_layer():
</Map> </Map>
''' '''
m = mapnik2.Map(256, 256) m = mapnik.Map(256, 256)
try: try:
mapnik2.load_map_from_string(m, map_string) mapnik.load_map_from_string(m, map_string)
# validate it loaded fine # validate it loaded fine
eq_(m.layers[0].styles[0],'world_borders_style') eq_(m.layers[0].styles[0],'world_borders_style')
@ -54,7 +54,7 @@ def test_adding_datasource_to_layer():
eq_(lyr.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') eq_(lyr.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
# now add a datasource one... # now add a datasource one...
ds = mapnik2.Shapefile(file='../data/shp/world_merc.shp') ds = mapnik.Shapefile(file='../data/shp/world_merc.shp')
m.layers[0].datasource = ds m.layers[0].datasource = ds
# now ensure it is attached # now ensure it is attached
@ -76,4 +76,4 @@ if __name__ == "__main__":
setup() setup()
[eval(run)() for run in dir() if 'test_' in run] [eval(run)() for run in dir() if 'test_' in run]

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import os, sys, glob, mapnik2 import os, sys, glob, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -13,16 +13,16 @@ def setup():
# We expect these files to not raise any # We expect these files to not raise any
# exceptions at all # exceptions at all
def assert_loads_successfully(file): def assert_loads_successfully(file):
m = mapnik2.Map(512, 512) m = mapnik.Map(512, 512)
try: try:
strict = True strict = True
mapnik2.load_map(m, file, strict) mapnik.load_map(m, file, strict)
# libxml2 is not smart about paths, and clips the last directory off # libxml2 is not smart about paths, and clips the last directory off
# of a path if it does not end in a trailing slash # of a path if it does not end in a trailing slash
base_path = os.path.dirname(file) + '/' base_path = os.path.dirname(file) + '/'
mapnik2.load_map_from_string(m,open(file,'rb').read(),strict,base_path) mapnik.load_map_from_string(m,open(file,'rb').read(),strict,base_path)
except RuntimeError, e: except RuntimeError, e:
# only test datasources that we have installed # only test datasources that we have installed
if not 'Could not create datasource' in str(e): if not 'Could not create datasource' in str(e):
@ -34,10 +34,10 @@ def assert_loads_successfully(file):
# of exception) # of exception)
@raises(RuntimeError) @raises(RuntimeError)
def assert_raises_runtime_error(file): def assert_raises_runtime_error(file):
m = mapnik2.Map(512, 512) m = mapnik.Map(512, 512)
strict = True strict = True
mapnik2.load_map(m, file, strict) mapnik.load_map(m, file, strict)
def test_broken_files(): def test_broken_files():
broken_files = glob.glob("../data/broken_maps/*.xml") broken_files = glob.glob("../data/broken_maps/*.xml")

View file

@ -4,7 +4,7 @@ from nose.tools import *
from subprocess import call from subprocess import call
import os import os
#import os, sys, glob, mapnik2 #import os, sys, glob, mapnik
#def test(): #def test():
# # mapnik-config program # # mapnik-config program

View file

@ -8,11 +8,11 @@ class MemoryDatasource(unittest.TestCase):
ids = itertools.count(0) ids = itertools.count(0)
def makeOne(self, *args, **kw): def makeOne(self, *args, **kw):
from mapnik2 import MemoryDatasource from mapnik import MemoryDatasource
return MemoryDatasource(*args, **kw) return MemoryDatasource(*args, **kw)
def makeFeature(self, wkt, **properties): def makeFeature(self, wkt, **properties):
from mapnik2 import Feature from mapnik import Feature
f = Feature(self.ids.next()) f = Feature(self.ids.next())
f.add_geometries_from_wkt(wkt) f.add_geometries_from_wkt(wkt)
for k,v in properties.iteritems(): for k,v in properties.iteritems():
@ -29,7 +29,7 @@ class MemoryDatasource(unittest.TestCase):
md.add_feature(self.makeFeature('Point(2 3)', foo='bar')) md.add_feature(self.makeFeature('Point(2 3)', foo='bar'))
self.failUnlessEqual(md.num_features(), 1) self.failUnlessEqual(md.num_features(), 1)
from mapnik2 import Coord from mapnik import Coord
retrieved = md.features_at_point(Coord(2,3)).features retrieved = md.features_at_point(Coord(2,3)).features
self.failUnlessEqual(len(retrieved), 1) self.failUnlessEqual(len(retrieved), 1)
f = retrieved[0] f = retrieved[0]

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path, save_data, contains_word from utilities import execution_path, save_data, contains_word
import os, mapnik2 import os, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -12,9 +12,9 @@ def setup():
def test_multi_tile_policy(): def test_multi_tile_policy():
srs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' srs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
lyr = mapnik2.Layer('raster') lyr = mapnik.Layer('raster')
if 'raster' in mapnik2.DatasourceCache.instance().plugin_names(): if 'raster' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Raster( lyr.datasource = mapnik.Raster(
file = '../data/raster_tiles/${x}/${y}.tif', file = '../data/raster_tiles/${x}/${y}.tif',
lox = -180, lox = -180,
loy = -90, loy = -90,
@ -26,10 +26,10 @@ def test_multi_tile_policy():
y_width = 2 y_width = 2
) )
lyr.srs = srs lyr.srs = srs
_map = mapnik2.Map(256, 256, srs) _map = mapnik.Map(256, 256, srs)
style = mapnik2.Style() style = mapnik.Style()
rule = mapnik2.Rule() rule = mapnik.Rule()
sym = mapnik2.RasterSymbolizer() sym = mapnik.RasterSymbolizer()
rule.symbols.append(sym) rule.symbols.append(sym)
style.rules.append(rule) style.rules.append(rule)
_map.append_style('foo', style) _map.append_style('foo', style)
@ -37,8 +37,8 @@ def test_multi_tile_policy():
_map.layers.append(lyr) _map.layers.append(lyr)
_map.zoom_to_box(lyr.envelope()) _map.zoom_to_box(lyr.envelope())
im = mapnik2.Image(_map.width, _map.height) im = mapnik.Image(_map.width, _map.height)
mapnik2.render(_map, im) mapnik.render(_map, im)
save_data('test_multi_tile_policy.png', im.tostring('png')) save_data('test_multi_tile_policy.png', im.tostring('png'))

View file

@ -6,7 +6,7 @@ from nose.tools import *
from utilities import execution_path from utilities import execution_path
from utilities import Todo from utilities import Todo
import mapnik2, pickle import mapnik, pickle
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -17,44 +17,44 @@ def setup():
# LineSymbolizer initialization # LineSymbolizer initialization
def test_line_symbolizer_init(): def test_line_symbolizer_init():
s = mapnik2.LineSymbolizer() s = mapnik.LineSymbolizer()
eq_(s.rasterizer, mapnik2.line_rasterizer.FULL) eq_(s.rasterizer, mapnik.line_rasterizer.FULL)
# ShieldSymbolizer initialization # ShieldSymbolizer initialization
def test_shieldsymbolizer_init(): def test_shieldsymbolizer_init():
s = mapnik2.ShieldSymbolizer(mapnik2.Expression('[Field Name]'), 'DejaVu Sans Bold', 6, mapnik2.Color('#000000'), mapnik2.PathExpression('../data/images/dummy.png')) s = mapnik.ShieldSymbolizer(mapnik.Expression('[Field Name]'), 'DejaVu Sans Bold', 6, mapnik.Color('#000000'), mapnik.PathExpression('../data/images/dummy.png'))
eq_(s.anchor, (0.0,0.5,)) eq_(s.anchor, (0.0,0.5,))
eq_(s.displacement, (0.0,0.0)) eq_(s.displacement, (0.0,0.0))
eq_(s.allow_overlap, False) eq_(s.allow_overlap, False)
eq_(s.avoid_edges, False) eq_(s.avoid_edges, False)
eq_(s.character_spacing,0) eq_(s.character_spacing,0)
eq_(str(s.name), str(mapnik2.Expression('[Field Name]'))) eq_(str(s.name), str(mapnik.Expression('[Field Name]')))
eq_(s.face_name, 'DejaVu Sans Bold') eq_(s.face_name, 'DejaVu Sans Bold')
eq_(s.allow_overlap, False) eq_(s.allow_overlap, False)
eq_(s.fill, mapnik2.Color('#000000')) eq_(s.fill, mapnik.Color('#000000'))
eq_(s.force_odd_labels, False) eq_(s.force_odd_labels, False)
eq_(s.halo_fill, mapnik2.Color('rgb(255,255,255)')) eq_(s.halo_fill, mapnik.Color('rgb(255,255,255)'))
eq_(s.halo_radius, 0) eq_(s.halo_radius, 0)
eq_(s.label_placement, mapnik2.label_placement.POINT_PLACEMENT) eq_(s.label_placement, mapnik.label_placement.POINT_PLACEMENT)
eq_(s.minimum_distance, 0.0) eq_(s.minimum_distance, 0.0)
eq_(s.text_ratio, 0) eq_(s.text_ratio, 0)
eq_(s.text_size, 6) eq_(s.text_size, 6)
eq_(s.wrap_width, 0) eq_(s.wrap_width, 0)
eq_(s.vertical_alignment, mapnik2.vertical_alignment.MIDDLE) eq_(s.vertical_alignment, mapnik.vertical_alignment.MIDDLE)
eq_(s.label_spacing, 0) eq_(s.label_spacing, 0)
eq_(s.label_position_tolerance, 0) eq_(s.label_position_tolerance, 0)
# 22.5 * M_PI/180.0 initialized by default # 22.5 * M_PI/180.0 initialized by default
assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414) assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414)
eq_(s.wrap_character, ' ') eq_(s.wrap_character, ' ')
eq_(s.text_transform, mapnik2.text_transform.NONE) eq_(s.text_transform, mapnik.text_transform.NONE)
eq_(s.line_spacing, 0) eq_(s.line_spacing, 0)
eq_(s.character_spacing, 0) eq_(s.character_spacing, 0)
# r1341 # r1341
eq_(s.wrap_before, False) eq_(s.wrap_before, False)
eq_(s.horizontal_alignment, mapnik2.horizontal_alignment.MIDDLE) eq_(s.horizontal_alignment, mapnik.horizontal_alignment.MIDDLE)
eq_(s.justify_alignment, mapnik2.justify_alignment.MIDDLE) eq_(s.justify_alignment, mapnik.justify_alignment.MIDDLE)
eq_(s.opacity, 1.0) eq_(s.opacity, 1.0)
# r2300 # r2300
@ -70,7 +70,7 @@ def test_shieldsymbolizer_init():
eq_(s.transform, 'matrix(1, 0, 0, 1, 0, 0)') eq_(s.transform, 'matrix(1, 0, 0, 1, 0, 0)')
raise Todo("FontSet pickling support needed: http://trac.mapnik2.org/ticket/348") raise Todo("FontSet pickling support needed: http://trac.mapnik.org/ticket/348")
eq_(s.fontset, '') eq_(s.fontset, '')
@ -79,53 +79,53 @@ def test_shieldsymbolizer_init():
# so it does not make sense to throw... # so it does not make sense to throw...
#@raises(RuntimeError) #@raises(RuntimeError)
#def test_shieldsymbolizer_missing_image(): #def test_shieldsymbolizer_missing_image():
# s = mapnik2.ShieldSymbolizer(mapnik2.Expression('[Field Name]'), 'DejaVu Sans Bold', 6, mapnik2.Color('#000000'), mapnik2.PathExpression('../#data/images/broken.png')) # s = mapnik.ShieldSymbolizer(mapnik.Expression('[Field Name]'), 'DejaVu Sans Bold', 6, mapnik.Color('#000000'), mapnik.PathExpression('../#data/images/broken.png'))
def test_polygonsymbolizer_init(): def test_polygonsymbolizer_init():
p = mapnik2.PolygonSymbolizer() p = mapnik.PolygonSymbolizer()
eq_(p.fill, mapnik2.Color('gray')) eq_(p.fill, mapnik.Color('gray'))
eq_(p.fill_opacity, 1) eq_(p.fill_opacity, 1)
eq_(p.placement, mapnik2.point_placement.CENTROID) eq_(p.placement, mapnik.point_placement.CENTROID)
p = mapnik2.PolygonSymbolizer(mapnik2.Color('blue')) p = mapnik.PolygonSymbolizer(mapnik.Color('blue'))
p.placement = mapnik2.point_placement.INTERIOR p.placement = mapnik.point_placement.INTERIOR
eq_(p.fill, mapnik2.Color('blue')) eq_(p.fill, mapnik.Color('blue'))
eq_(p.fill_opacity, 1) eq_(p.fill_opacity, 1)
eq_(p.placement, mapnik2.point_placement.INTERIOR) eq_(p.placement, mapnik.point_placement.INTERIOR)
# PointSymbolizer initialization # PointSymbolizer initialization
def test_pointsymbolizer_init(): def test_pointsymbolizer_init():
p = mapnik2.PointSymbolizer() p = mapnik.PointSymbolizer()
eq_(p.allow_overlap, False) eq_(p.allow_overlap, False)
eq_(p.opacity,1) eq_(p.opacity,1)
eq_(p.filename,'') eq_(p.filename,'')
eq_(p.ignore_placement,False) eq_(p.ignore_placement,False)
eq_(p.placement, mapnik2.point_placement.CENTROID) eq_(p.placement, mapnik.point_placement.CENTROID)
p = mapnik2.PointSymbolizer(mapnik2.PathExpression("../data/images/dummy.png")) p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
p.allow_overlap = True p.allow_overlap = True
p.opacity = 0.5 p.opacity = 0.5
p.ignore_placement = True p.ignore_placement = True
p.placement = mapnik2.point_placement.INTERIOR p.placement = mapnik.point_placement.INTERIOR
eq_(p.allow_overlap, True) eq_(p.allow_overlap, True)
eq_(p.opacity, 0.5) eq_(p.opacity, 0.5)
eq_(p.filename,'../data/images/dummy.png') eq_(p.filename,'../data/images/dummy.png')
eq_(p.ignore_placement,True) eq_(p.ignore_placement,True)
eq_(p.placement, mapnik2.point_placement.INTERIOR) eq_(p.placement, mapnik.point_placement.INTERIOR)
# PointSymbolizer missing image file # PointSymbolizer missing image file
# images paths are now PathExpressions are evaluated at runtime # images paths are now PathExpressions are evaluated at runtime
# so it does not make sense to throw... # so it does not make sense to throw...
#@raises(RuntimeError) #@raises(RuntimeError)
#def test_pointsymbolizer_missing_image(): #def test_pointsymbolizer_missing_image():
# p = mapnik2.PointSymbolizer(mapnik2.PathExpression("../data/images/broken.png")) # p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/broken.png"))
# PointSymbolizer pickling # PointSymbolizer pickling
def test_pointsymbolizer_pickle(): def test_pointsymbolizer_pickle():
raise Todo("point_symbolizer pickling currently disabled") raise Todo("point_symbolizer pickling currently disabled")
p = mapnik2.PointSymbolizer(mapnik2.PathExpression("../data/images/dummy.png")) p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
p2 = pickle.loads(pickle.dumps(p,pickle.HIGHEST_PROTOCOL)) p2 = pickle.loads(pickle.dumps(p,pickle.HIGHEST_PROTOCOL))
# image type, width, and height only used in contructor... # image type, width, and height only used in contructor...
eq_(p.filename, p2.filename) eq_(p.filename, p2.filename)
@ -136,19 +136,19 @@ def test_pointsymbolizer_pickle():
# PolygonSymbolizer initialization # PolygonSymbolizer initialization
def test_polygonsymbolizer_init(): def test_polygonsymbolizer_init():
p = mapnik2.PolygonSymbolizer() p = mapnik.PolygonSymbolizer()
eq_(p.fill, mapnik2.Color('gray')) eq_(p.fill, mapnik.Color('gray'))
eq_(p.fill_opacity, 1) eq_(p.fill_opacity, 1)
p = mapnik2.PolygonSymbolizer(mapnik2.Color('blue')) p = mapnik.PolygonSymbolizer(mapnik.Color('blue'))
eq_(p.fill, mapnik2.Color('blue')) eq_(p.fill, mapnik.Color('blue'))
eq_(p.fill_opacity, 1) eq_(p.fill_opacity, 1)
# PolygonSymbolizer pickling # PolygonSymbolizer pickling
def test_polygonsymbolizer_pickle(): def test_polygonsymbolizer_pickle():
p = mapnik2.PolygonSymbolizer(mapnik2.Color('black')) p = mapnik.PolygonSymbolizer(mapnik.Color('black'))
p.fill_opacity = .5 p.fill_opacity = .5
# does not work for some reason... # does not work for some reason...
#eq_(pickle.loads(pickle.dumps(p)), p) #eq_(pickle.loads(pickle.dumps(p)), p)
@ -159,28 +159,28 @@ def test_polygonsymbolizer_pickle():
# Stroke initialization # Stroke initialization
def test_stroke_init(): def test_stroke_init():
s = mapnik2.Stroke() s = mapnik.Stroke()
eq_(s.width, 1) eq_(s.width, 1)
eq_(s.opacity, 1) eq_(s.opacity, 1)
eq_(s.color, mapnik2.Color('black')) eq_(s.color, mapnik.Color('black'))
eq_(s.line_cap, mapnik2.line_cap.BUTT_CAP) eq_(s.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(s.line_join, mapnik2.line_join.MITER_JOIN) eq_(s.line_join, mapnik.line_join.MITER_JOIN)
eq_(s.gamma,1.0) eq_(s.gamma,1.0)
s = mapnik2.Stroke(mapnik2.Color('blue'), 5.0) s = mapnik.Stroke(mapnik.Color('blue'), 5.0)
s.gamma = .5 s.gamma = .5
eq_(s.width, 5) eq_(s.width, 5)
eq_(s.opacity, 1) eq_(s.opacity, 1)
eq_(s.color, mapnik2.Color('blue')) eq_(s.color, mapnik.Color('blue'))
eq_(s.gamma, .5) eq_(s.gamma, .5)
eq_(s.line_cap, mapnik2.line_cap.BUTT_CAP) eq_(s.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(s.line_join, mapnik2.line_join.MITER_JOIN) eq_(s.line_join, mapnik.line_join.MITER_JOIN)
# Stroke dashes # Stroke dashes
def test_stroke_dash_arrays(): def test_stroke_dash_arrays():
s = mapnik2.Stroke() s = mapnik.Stroke()
s.add_dash(1,2) s.add_dash(1,2)
s.add_dash(3,4) s.add_dash(3,4)
s.add_dash(5,6) s.add_dash(5,6)
@ -189,10 +189,10 @@ def test_stroke_dash_arrays():
# Stroke pickling # Stroke pickling
def test_stroke_pickle(): def test_stroke_pickle():
s = mapnik2.Stroke(mapnik2.Color('black'),4.5) s = mapnik.Stroke(mapnik.Color('black'),4.5)
eq_(s.width, 4.5) eq_(s.width, 4.5)
eq_(s.color, mapnik2.Color('black')) eq_(s.color, mapnik.Color('black'))
s.add_dash(1,2) s.add_dash(1,2)
s.add_dash(3,4) s.add_dash(3,4)
@ -209,34 +209,34 @@ def test_stroke_pickle():
# LineSymbolizer initialization # LineSymbolizer initialization
def test_linesymbolizer_init(): def test_linesymbolizer_init():
l = mapnik2.LineSymbolizer() l = mapnik.LineSymbolizer()
eq_(l.stroke.width, 1) eq_(l.stroke.width, 1)
eq_(l.stroke.opacity, 1) eq_(l.stroke.opacity, 1)
eq_(l.stroke.color, mapnik2.Color('black')) eq_(l.stroke.color, mapnik.Color('black'))
eq_(l.stroke.line_cap, mapnik2.line_cap.BUTT_CAP) eq_(l.stroke.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(l.stroke.line_join, mapnik2.line_join.MITER_JOIN) eq_(l.stroke.line_join, mapnik.line_join.MITER_JOIN)
l = mapnik2.LineSymbolizer(mapnik2.Color('blue'), 5.0) l = mapnik.LineSymbolizer(mapnik.Color('blue'), 5.0)
eq_(l.stroke.width, 5) eq_(l.stroke.width, 5)
eq_(l.stroke.opacity, 1) eq_(l.stroke.opacity, 1)
eq_(l.stroke.color, mapnik2.Color('blue')) eq_(l.stroke.color, mapnik.Color('blue'))
eq_(l.stroke.line_cap, mapnik2.line_cap.BUTT_CAP) eq_(l.stroke.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(l.stroke.line_join, mapnik2.line_join.MITER_JOIN) eq_(l.stroke.line_join, mapnik.line_join.MITER_JOIN)
s = mapnik2.Stroke(mapnik2.Color('blue'), 5.0) s = mapnik.Stroke(mapnik.Color('blue'), 5.0)
l = mapnik2.LineSymbolizer(s) l = mapnik.LineSymbolizer(s)
eq_(l.stroke.width, 5) eq_(l.stroke.width, 5)
eq_(l.stroke.opacity, 1) eq_(l.stroke.opacity, 1)
eq_(l.stroke.color, mapnik2.Color('blue')) eq_(l.stroke.color, mapnik.Color('blue'))
eq_(l.stroke.line_cap, mapnik2.line_cap.BUTT_CAP) eq_(l.stroke.line_cap, mapnik.line_cap.BUTT_CAP)
eq_(l.stroke.line_join, mapnik2.line_join.MITER_JOIN) eq_(l.stroke.line_join, mapnik.line_join.MITER_JOIN)
# LineSymbolizer pickling # LineSymbolizer pickling
def test_linesymbolizer_pickle(): def test_linesymbolizer_pickle():
p = mapnik2.LineSymbolizer() p = mapnik.LineSymbolizer()
p2 = pickle.loads(pickle.dumps(p,pickle.HIGHEST_PROTOCOL)) p2 = pickle.loads(pickle.dumps(p,pickle.HIGHEST_PROTOCOL))
# line and stroke eq fails, so we compare attributes for now.. # line and stroke eq fails, so we compare attributes for now..
s,s2 = p.stroke, p2.stroke s,s2 = p.stroke, p2.stroke
@ -250,22 +250,22 @@ def test_linesymbolizer_pickle():
# TextSymbolizer initialization # TextSymbolizer initialization
def test_textsymbolizer_init(): def test_textsymbolizer_init():
ts = mapnik2.TextSymbolizer(mapnik2.Expression('[Field_Name]'), 'Font Name', 8, mapnik2.Color('black')) ts = mapnik.TextSymbolizer(mapnik.Expression('[Field_Name]'), 'Font Name', 8, mapnik.Color('black'))
eq_(str(ts.name), str(mapnik2.Expression('[Field_Name]'))) eq_(str(ts.name), str(mapnik.Expression('[Field_Name]')))
eq_(ts.face_name, 'Font Name') eq_(ts.face_name, 'Font Name')
eq_(ts.text_size, 8) eq_(ts.text_size, 8)
eq_(ts.fill, mapnik2.Color('black')) eq_(ts.fill, mapnik.Color('black'))
eq_(ts.label_placement, mapnik2.label_placement.POINT_PLACEMENT) eq_(ts.label_placement, mapnik.label_placement.POINT_PLACEMENT)
# TextSymbolizer pickling # TextSymbolizer pickling
def test_textsymbolizer_pickle(): def test_textsymbolizer_pickle():
ts = mapnik2.TextSymbolizer(mapnik2.Expression('[Field_Name]'), 'Font Name', 8, mapnik2.Color('black')) ts = mapnik.TextSymbolizer(mapnik.Expression('[Field_Name]'), 'Font Name', 8, mapnik.Color('black'))
eq_(str(ts.name), str(mapnik2.Expression('[Field_Name]'))) eq_(str(ts.name), str(mapnik.Expression('[Field_Name]')))
eq_(ts.face_name, 'Font Name') eq_(ts.face_name, 'Font Name')
eq_(ts.text_size, 8) eq_(ts.text_size, 8)
eq_(ts.fill, mapnik2.Color('black')) eq_(ts.fill, mapnik.Color('black'))
raise Todo("text_symbolizer pickling currently disabled") raise Todo("text_symbolizer pickling currently disabled")
@ -304,15 +304,15 @@ def test_textsymbolizer_pickle():
# r2300 # r2300
eq_(s.minimum_padding, 0.0) eq_(s.minimum_padding, 0.0)
raise Todo("FontSet pickling support needed: http://trac.mapnik2.org/ticket/348") raise Todo("FontSet pickling support needed: http://trac.mapnik.org/ticket/348")
eq_(ts.fontset, ts2.fontset) eq_(ts.fontset, ts2.fontset)
# Map initialization # Map initialization
def test_layer_init(): def test_layer_init():
l = mapnik2.Layer('test') l = mapnik.Layer('test')
eq_(l.name,'test') eq_(l.name,'test')
eq_(l.envelope(),mapnik2.Box2d()) eq_(l.envelope(),mapnik.Box2d())
eq_(l.clear_label_cache,False) eq_(l.clear_label_cache,False)
eq_(l.cache_features,False) eq_(l.cache_features,False)
eq_(l.visible(1),True) eq_(l.visible(1),True)
@ -325,14 +325,14 @@ def test_layer_init():
# Map initialization # Map initialization
def test_map_init(): def test_map_init():
m = mapnik2.Map(256, 256) m = mapnik.Map(256, 256)
eq_(m.width, 256) eq_(m.width, 256)
eq_(m.height, 256) eq_(m.height, 256)
eq_(m.srs, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') eq_(m.srs, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
eq_(m.base, '') eq_(m.base, '')
m = mapnik2.Map(256, 256, '+proj=latlong') m = mapnik.Map(256, 256, '+proj=latlong')
eq_(m.srs, '+proj=latlong') eq_(m.srs, '+proj=latlong')
# Map initialization from string # Map initialization from string
@ -358,20 +358,20 @@ def test_map_init_from_string():
</Layer> </Layer>
</Map>''' </Map>'''
m = mapnik2.Map(600, 300) m = mapnik.Map(600, 300)
eq_(m.base, '') eq_(m.base, '')
try: try:
mapnik2.load_map_from_string(m, map_string) mapnik.load_map_from_string(m, map_string)
eq_(m.base, './') eq_(m.base, './')
mapnik2.load_map_from_string(m, map_string, False, "") # this "" will have no effect mapnik.load_map_from_string(m, map_string, False, "") # this "" will have no effect
eq_(m.base, './') eq_(m.base, './')
try: try:
mapnik2.load_map_from_string(m, map_string, False, "/tmp") mapnik.load_map_from_string(m, map_string, False, "/tmp")
except RuntimeError: except RuntimeError:
pass # runtime error expected because shapefile path should be wrong and datasource will throw pass # runtime error expected because shapefile path should be wrong and datasource will throw
eq_(m.base, '/tmp') # /tmp will be set despite the exception because load_map mostly worked eq_(m.base, '/tmp') # /tmp will be set despite the exception because load_map mostly worked
m.base = 'foo' m.base = 'foo'
mapnik2.load_map_from_string(m, map_string, True, ".") mapnik.load_map_from_string(m, map_string, True, ".")
eq_(m.base, '.') eq_(m.base, '.')
raise(Todo("Need to write more map property tests in 'object_test.py'...")) raise(Todo("Need to write more map property tests in 'object_test.py'..."))
except RuntimeError, e: except RuntimeError, e:
@ -384,11 +384,11 @@ def test_map_pickle():
# Fails due to scale() not matching, possibly other things # Fails due to scale() not matching, possibly other things
raise(Todo("Map does not support pickling yet (Tickets #345).")) raise(Todo("Map does not support pickling yet (Tickets #345)."))
m = mapnik2.Map(256, 256) m = mapnik.Map(256, 256)
eq_(pickle.loads(pickle.dumps(m)), m) eq_(pickle.loads(pickle.dumps(m)), m)
m = mapnik2.Map(256, 256, '+proj=latlong') m = mapnik.Map(256, 256, '+proj=latlong')
eq_(pickle.loads(pickle.dumps(m)), m) eq_(pickle.loads(pickle.dumps(m)), m)
@ -396,14 +396,14 @@ def test_map_pickle():
@raises(Exception) # Boost.Python.ArgumentError @raises(Exception) # Boost.Python.ArgumentError
def test_color_init_errors(): def test_color_init_errors():
c = mapnik2.Color() c = mapnik.Color()
@raises(RuntimeError) @raises(RuntimeError)
def test_color_init_errors(): def test_color_init_errors():
c = mapnik2.Color('foo') # mapnik config c = mapnik.Color('foo') # mapnik config
def test_color_init(): def test_color_init():
c = mapnik2.Color('blue') c = mapnik.Color('blue')
eq_(c.a, 255) eq_(c.a, 255)
eq_(c.r, 0) eq_(c.r, 0)
@ -412,7 +412,7 @@ def test_color_init():
eq_(c.to_hex_string(), '#0000ff') eq_(c.to_hex_string(), '#0000ff')
c = mapnik2.Color('#f2eff9') c = mapnik.Color('#f2eff9')
eq_(c.a, 255) eq_(c.a, 255)
eq_(c.r, 242) eq_(c.r, 242)
@ -421,7 +421,7 @@ def test_color_init():
eq_(c.to_hex_string(), '#f2eff9') eq_(c.to_hex_string(), '#f2eff9')
c = mapnik2.Color('rgb(50%,50%,50%)') c = mapnik.Color('rgb(50%,50%,50%)')
eq_(c.a, 255) eq_(c.a, 255)
eq_(c.r, 128) eq_(c.r, 128)
@ -430,7 +430,7 @@ def test_color_init():
eq_(c.to_hex_string(), '#808080') eq_(c.to_hex_string(), '#808080')
c = mapnik2.Color(0, 64, 128) c = mapnik.Color(0, 64, 128)
eq_(c.a, 255) eq_(c.a, 255)
eq_(c.r, 0) eq_(c.r, 0)
@ -439,7 +439,7 @@ def test_color_init():
eq_(c.to_hex_string(), '#004080') eq_(c.to_hex_string(), '#004080')
c = mapnik2.Color(0, 64, 128, 192) c = mapnik.Color(0, 64, 128, 192)
eq_(c.a, 192) eq_(c.a, 192)
eq_(c.r, 0) eq_(c.r, 0)
@ -451,9 +451,9 @@ def test_color_init():
# Color equality # Color equality
def test_color_equality(): def test_color_equality():
c1 = mapnik2.Color('blue') c1 = mapnik.Color('blue')
c2 = mapnik2.Color(0,0,255) c2 = mapnik.Color(0,0,255)
c3 = mapnik2.Color('black') c3 = mapnik.Color('black')
c3.r = 0 c3.r = 0
@ -464,9 +464,9 @@ def test_color_equality():
eq_(c1, c2) eq_(c1, c2)
eq_(c1, c3) eq_(c1, c3)
c1 = mapnik2.Color(0, 64, 128) c1 = mapnik.Color(0, 64, 128)
c2 = mapnik2.Color(0, 64, 128) c2 = mapnik.Color(0, 64, 128)
c3 = mapnik2.Color(0, 0, 0) c3 = mapnik.Color(0, 0, 0)
c3.r = 0 c3.r = 0
c3.g = 64 c3.g = 64
@ -475,9 +475,9 @@ def test_color_equality():
eq_(c1, c2) eq_(c1, c2)
eq_(c1, c3) eq_(c1, c3)
c1 = mapnik2.Color(0, 64, 128, 192) c1 = mapnik.Color(0, 64, 128, 192)
c2 = mapnik2.Color(0, 64, 128, 192) c2 = mapnik.Color(0, 64, 128, 192)
c3 = mapnik2.Color(0, 0, 0, 255) c3 = mapnik.Color(0, 0, 0, 255)
c3.r = 0 c3.r = 0
c3.g = 64 c3.g = 64
@ -487,35 +487,35 @@ def test_color_equality():
eq_(c1, c2) eq_(c1, c2)
eq_(c1, c3) eq_(c1, c3)
c1 = mapnik2.Color('rgb(50%,50%,50%)') c1 = mapnik.Color('rgb(50%,50%,50%)')
c2 = mapnik2.Color(128, 128, 128, 255) c2 = mapnik.Color(128, 128, 128, 255)
c3 = mapnik2.Color('#808080') c3 = mapnik.Color('#808080')
c4 = mapnik2.Color('gray') c4 = mapnik.Color('gray')
eq_(c1, c2) eq_(c1, c2)
eq_(c1, c3) eq_(c1, c3)
eq_(c1, c4) eq_(c1, c4)
c1 = mapnik2.Color('hsl(0, 100%, 50%)') # red c1 = mapnik.Color('hsl(0, 100%, 50%)') # red
c2 = mapnik2.Color('hsl(120, 100%, 50%)') # lime c2 = mapnik.Color('hsl(120, 100%, 50%)') # lime
c3 = mapnik2.Color('hsla(240, 100%, 50%, 0.5)') # semi-transparent solid blue c3 = mapnik.Color('hsla(240, 100%, 50%, 0.5)') # semi-transparent solid blue
eq_(c1, mapnik2.Color('red')) eq_(c1, mapnik.Color('red'))
eq_(c2, mapnik2.Color('lime')) eq_(c2, mapnik.Color('lime'))
eq_(c3, mapnik2.Color(0,0,255,128)) eq_(c3, mapnik.Color(0,0,255,128))
# Color pickling # Color pickling
def test_color_pickle(): def test_color_pickle():
c = mapnik2.Color('blue') c = mapnik.Color('blue')
eq_(pickle.loads(pickle.dumps(c)), c) eq_(pickle.loads(pickle.dumps(c)), c)
c = mapnik2.Color(0, 64, 128) c = mapnik.Color(0, 64, 128)
eq_(pickle.loads(pickle.dumps(c)), c) eq_(pickle.loads(pickle.dumps(c)), c)
c = mapnik2.Color(0, 64, 128, 192) c = mapnik.Color(0, 64, 128, 192)
eq_(pickle.loads(pickle.dumps(c)), c) eq_(pickle.loads(pickle.dumps(c)), c)
@ -524,7 +524,7 @@ def test_rule_init():
min_scale = 5 min_scale = 5
max_scale = 10 max_scale = 10
r = mapnik2.Rule() r = mapnik.Rule()
eq_(r.name, '') eq_(r.name, '')
eq_(r.title, '') eq_(r.title, '')
@ -533,19 +533,19 @@ def test_rule_init():
eq_(r.has_else(), False) eq_(r.has_else(), False)
eq_(r.has_also(), False) eq_(r.has_also(), False)
r = mapnik2.Rule() r = mapnik.Rule()
r.set_else(True) r.set_else(True)
eq_(r.has_else(), True) eq_(r.has_else(), True)
eq_(r.has_also(), False) eq_(r.has_also(), False)
r = mapnik2.Rule() r = mapnik.Rule()
r.set_also(True) r.set_also(True)
eq_(r.has_else(), False) eq_(r.has_else(), False)
eq_(r.has_also(), True) eq_(r.has_also(), True)
r = mapnik2.Rule("Name") r = mapnik.Rule("Name")
eq_(r.name, 'Name') eq_(r.name, 'Name')
eq_(r.title, '') eq_(r.title, '')
@ -554,7 +554,7 @@ def test_rule_init():
eq_(r.has_else(), False) eq_(r.has_else(), False)
eq_(r.has_also(), False) eq_(r.has_also(), False)
r = mapnik2.Rule("Name", "Title") r = mapnik.Rule("Name", "Title")
eq_(r.name, 'Name') eq_(r.name, 'Name')
eq_(r.title, 'Title') eq_(r.title, 'Title')
@ -563,7 +563,7 @@ def test_rule_init():
eq_(r.has_else(), False) eq_(r.has_else(), False)
eq_(r.has_also(), False) eq_(r.has_also(), False)
r = mapnik2.Rule("Name", "Title", min_scale) r = mapnik.Rule("Name", "Title", min_scale)
eq_(r.name, 'Name') eq_(r.name, 'Name')
eq_(r.title, 'Title') eq_(r.title, 'Title')
@ -572,7 +572,7 @@ def test_rule_init():
eq_(r.has_else(), False) eq_(r.has_else(), False)
eq_(r.has_also(), False) eq_(r.has_also(), False)
r = mapnik2.Rule("Name", "Title", min_scale, max_scale) r = mapnik.Rule("Name", "Title", min_scale, max_scale)
eq_(r.name, 'Name') eq_(r.name, 'Name')
eq_(r.title, 'Title') eq_(r.title, 'Title')
@ -583,14 +583,14 @@ def test_rule_init():
# Coordinate initialization # Coordinate initialization
def test_coord_init(): def test_coord_init():
c = mapnik2.Coord(100, 100) c = mapnik.Coord(100, 100)
eq_(c.x, 100) eq_(c.x, 100)
eq_(c.y, 100) eq_(c.y, 100)
# Coordinate multiplication # Coordinate multiplication
def test_coord_multiplication(): def test_coord_multiplication():
c = mapnik2.Coord(100, 100) c = mapnik.Coord(100, 100)
c *= 2 c *= 2
eq_(c.x, 200) eq_(c.x, 200)
@ -598,7 +598,7 @@ def test_coord_multiplication():
# Box2d initialization # Box2d initialization
def test_envelope_init(): def test_envelope_init():
e = mapnik2.Box2d(100, 100, 200, 200) e = mapnik.Box2d(100, 100, 200, 200)
assert_true(e.contains(100, 100)) assert_true(e.contains(100, 100))
assert_true(e.contains(100, 200)) assert_true(e.contains(100, 200))
@ -637,9 +637,9 @@ def test_envelope_init():
# Box2d static initialization # Box2d static initialization
def test_envelope_static_init(): def test_envelope_static_init():
e = mapnik2.Box2d.from_string('100 100 200 200') e = mapnik.Box2d.from_string('100 100 200 200')
e2 = mapnik2.Box2d.from_string('100,100,200,200') e2 = mapnik.Box2d.from_string('100,100,200,200')
e3 = mapnik2.Box2d.from_string('100 , 100 , 200 , 200') e3 = mapnik.Box2d.from_string('100 , 100 , 200 , 200')
eq_(e,e2) eq_(e,e2)
eq_(e,e3) eq_(e,e3)
@ -680,13 +680,13 @@ def test_envelope_static_init():
# Box2d pickling # Box2d pickling
def test_envelope_pickle(): def test_envelope_pickle():
e = mapnik2.Box2d(100, 100, 200, 200) e = mapnik.Box2d(100, 100, 200, 200)
eq_(pickle.loads(pickle.dumps(e)), e) eq_(pickle.loads(pickle.dumps(e)), e)
# Box2d multiplication # Box2d multiplication
def test_envelope_multiplication(): def test_envelope_multiplication():
e = mapnik2.Box2d(100, 100, 200, 200) e = mapnik.Box2d(100, 100, 200, 200)
e *= 2 e *= 2
assert_true(e.contains(50, 50)) assert_true(e.contains(50, 50))
@ -717,20 +717,20 @@ def test_envelope_multiplication():
# Box2d clipping # Box2d clipping
def test_envelope_pickle(): def test_envelope_pickle():
e1 = mapnik2.Box2d(-180,-90,180,90) e1 = mapnik.Box2d(-180,-90,180,90)
e2 = mapnik2.Box2d(-120,40,-110,48) e2 = mapnik.Box2d(-120,40,-110,48)
e1.clip(e2) e1.clip(e2)
eq_(e1,e2) eq_(e1,e2)
# madagascar in merc # madagascar in merc
e1 = mapnik2.Box2d(4772116.5490, -2744395.0631, 5765186.4203, -1609458.0673) e1 = mapnik.Box2d(4772116.5490, -2744395.0631, 5765186.4203, -1609458.0673)
e2 = mapnik2.Box2d(5124338.3753, -2240522.1727, 5207501.8621, -2130452.8520) e2 = mapnik.Box2d(5124338.3753, -2240522.1727, 5207501.8621, -2130452.8520)
e1.clip(e2) e1.clip(e2)
eq_(e1,e2) eq_(e1,e2)
# nz in lon/lat # nz in lon/lat
e1 = mapnik2.Box2d(163.8062, -47.1897, 179.3628, -33.9069) e1 = mapnik.Box2d(163.8062, -47.1897, 179.3628, -33.9069)
e2 = mapnik2.Box2d(173.7378, -39.6395, 174.4849, -38.9252) e2 = mapnik.Box2d(173.7378, -39.6395, 174.4849, -38.9252)
e1.clip(e2) e1.clip(e2)
eq_(e1,e2) eq_(e1,e2)

View file

@ -5,7 +5,7 @@ import atexit
import time import time
from utilities import execution_path from utilities import execution_path
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import os, mapnik2 import os, mapnik
MAPNIK_TEST_DBNAME = 'mapnik-tmp-postgis-test-db' MAPNIK_TEST_DBNAME = 'mapnik-tmp-postgis-test-db'
POSTGIS_TEMPLATE_DBNAME = 'template_postgis' POSTGIS_TEMPLATE_DBNAME = 'template_postgis'
@ -74,7 +74,7 @@ def postgis_takedown():
# fails as the db is in use: https://github.com/mapnik/mapnik/issues/960 # fails as the db is in use: https://github.com/mapnik/mapnik/issues/960
#call('dropdb %s' % MAPNIK_TEST_DBNAME) #call('dropdb %s' % MAPNIK_TEST_DBNAME)
if 'postgis' in mapnik2.DatasourceCache.instance().plugin_names() \ if 'postgis' in mapnik.DatasourceCache.instance().plugin_names() \
and createdb_and_dropdb_on_path() \ and createdb_and_dropdb_on_path() \
and psql_can_connect() \ and psql_can_connect() \
and shp2pgsql_on_path(): and shp2pgsql_on_path():
@ -83,7 +83,7 @@ if 'postgis' in mapnik2.DatasourceCache.instance().plugin_names() \
postgis_setup() postgis_setup()
def test_feature(): def test_feature():
ds = mapnik2.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='world_merc') ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='world_merc')
fs = ds.featureset() fs = ds.featureset()
feature = fs.next() feature = fs.next()
eq_(feature['gid'],1) eq_(feature['gid'],1)
@ -100,7 +100,7 @@ if 'postgis' in mapnik2.DatasourceCache.instance().plugin_names() \
eq_(feature['lat'],17.078) eq_(feature['lat'],17.078)
def test_subquery(): def test_subquery():
ds = mapnik2.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='(select * from world_merc) as w') ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='(select * from world_merc) as w')
fs = ds.featureset() fs = ds.featureset()
feature = fs.next() feature = fs.next()
eq_(feature['gid'],1) eq_(feature['gid'],1)
@ -116,7 +116,7 @@ if 'postgis' in mapnik2.DatasourceCache.instance().plugin_names() \
eq_(feature['lon'],-61.783) eq_(feature['lon'],-61.783)
eq_(feature['lat'],17.078) eq_(feature['lat'],17.078)
ds = mapnik2.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='(select gid,geom,fips as _fips from world_merc) as w') ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='(select gid,geom,fips as _fips from world_merc) as w')
fs = ds.featureset() fs = ds.featureset()
feature = fs.next() feature = fs.next()
eq_(feature['gid'],1) eq_(feature['gid'],1)
@ -124,7 +124,7 @@ if 'postgis' in mapnik2.DatasourceCache.instance().plugin_names() \
eq_(len(feature),2) eq_(len(feature),2)
def test_empty_db(): def test_empty_db():
ds = mapnik2.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='empty') ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='empty')
fs = ds.featureset() fs = ds.featureset()
feature = fs.next() feature = fs.next()
eq_(feature,None) eq_(feature,None)

View file

@ -2,22 +2,22 @@
from nose.tools import * from nose.tools import *
import mapnik2, pickle import mapnik, pickle
# Tests that exercise map projections. # Tests that exercise map projections.
def test_normalizing_definition(): def test_normalizing_definition():
p = mapnik2.Projection('+init=epsg:4326') p = mapnik.Projection('+init=epsg:4326')
expanded = p.expanded() expanded = p.expanded()
eq_('+proj=longlat' in expanded,True) eq_('+proj=longlat' in expanded,True)
# Trac Ticket #128 # Trac Ticket #128
def test_wgs84_inverse_forward(): def test_wgs84_inverse_forward():
p = mapnik2.Projection('+init=epsg:4326') p = mapnik.Projection('+init=epsg:4326')
c = mapnik2.Coord(3.01331418311, 43.3333092669) c = mapnik.Coord(3.01331418311, 43.3333092669)
e = mapnik2.Box2d(-122.54345245, 45.12312553, 68.2335581353, 48.231231233) e = mapnik.Box2d(-122.54345245, 45.12312553, 68.2335581353, 48.231231233)
# It appears that the y component changes very slightly, is this OK? # It appears that the y component changes very slightly, is this OK?
# so we test for 'almost equal float values' # so we test for 'almost equal float values'

View file

@ -1,6 +1,6 @@
#coding=utf8 #coding=utf8
import os import os
import mapnik2 import mapnik
from utilities import execution_path from utilities import execution_path
from nose.tools import * from nose.tools import *
@ -14,12 +14,12 @@ def test_gen_map():
mapxmloutputfile = 'raster_colorizer_test_save.xml' mapxmloutputfile = 'raster_colorizer_test_save.xml'
outputfile = 'raster_colorizer_test.png' outputfile = 'raster_colorizer_test.png'
m = mapnik2.Map(800, 600) m = mapnik.Map(800, 600)
try: try:
mapnik2.load_map(m, mapxmlfile) mapnik.load_map(m, mapxmlfile)
mapnik2.save_map(m, mapxmloutputfile) mapnik.save_map(m, mapxmloutputfile)
m.zoom_all() m.zoom_all()
mapnik2.render_to_file(m, outputfile) mapnik.render_to_file(m, outputfile)
except RuntimeError,e: except RuntimeError,e:
# only test datasources that we have installed # only test datasources that we have installed
if not 'Could not create datasource' in str(e): if not 'Could not create datasource' in str(e):
@ -28,47 +28,47 @@ def test_gen_map():
#test discrete colorizer mode #test discrete colorizer mode
def test_get_color_discrete(): def test_get_color_discrete():
#setup #setup
colorizer = mapnik2.RasterColorizer(); colorizer = mapnik.RasterColorizer();
colorizer.default_color = mapnik2.Color(0,0,0,0); colorizer.default_color = mapnik.Color(0,0,0,0);
colorizer.default_mode = mapnik2.COLORIZER_DISCRETE; colorizer.default_mode = mapnik.COLORIZER_DISCRETE;
colorizer.add_stop(10, mapnik2.Color(100,100,100,100)); colorizer.add_stop(10, mapnik.Color(100,100,100,100));
colorizer.add_stop(20, mapnik2.Color(200,200,200,200)); colorizer.add_stop(20, mapnik.Color(200,200,200,200));
#should be default colour #should be default colour
eq_(colorizer.get_color(-50), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
eq_(colorizer.get_color(0), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(0), mapnik.Color(0,0,0,0));
#now in stop 1 #now in stop 1
eq_(colorizer.get_color(10), mapnik2.Color(100,100,100,100)); eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
eq_(colorizer.get_color(19), mapnik2.Color(100,100,100,100)); eq_(colorizer.get_color(19), mapnik.Color(100,100,100,100));
#now in stop 2 #now in stop 2
eq_(colorizer.get_color(20), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
eq_(colorizer.get_color(1000), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(1000), mapnik.Color(200,200,200,200));
#test exact colorizer mode #test exact colorizer mode
def test_get_color_exact(): def test_get_color_exact():
#setup #setup
colorizer = mapnik2.RasterColorizer(); colorizer = mapnik.RasterColorizer();
colorizer.default_color = mapnik2.Color(0,0,0,0); colorizer.default_color = mapnik.Color(0,0,0,0);
colorizer.default_mode = mapnik2.COLORIZER_EXACT; colorizer.default_mode = mapnik.COLORIZER_EXACT;
colorizer.add_stop(10, mapnik2.Color(100,100,100,100)); colorizer.add_stop(10, mapnik.Color(100,100,100,100));
colorizer.add_stop(20, mapnik2.Color(200,200,200,200)); colorizer.add_stop(20, mapnik.Color(200,200,200,200));
#should be default colour #should be default colour
eq_(colorizer.get_color(-50), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
eq_(colorizer.get_color(11), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(11), mapnik.Color(0,0,0,0));
eq_(colorizer.get_color(20.001), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(20.001), mapnik.Color(0,0,0,0));
#should be stop 1 #should be stop 1
eq_(colorizer.get_color(10), mapnik2.Color(100,100,100,100)); eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
#should be stop 2 #should be stop 2
eq_(colorizer.get_color(20), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
@ -76,32 +76,32 @@ def test_get_color_exact():
#test linear colorizer mode #test linear colorizer mode
def test_get_color_linear(): def test_get_color_linear():
#setup #setup
colorizer = mapnik2.RasterColorizer(); colorizer = mapnik.RasterColorizer();
colorizer.default_color = mapnik2.Color(0,0,0,0); colorizer.default_color = mapnik.Color(0,0,0,0);
colorizer.default_mode = mapnik2.COLORIZER_LINEAR; colorizer.default_mode = mapnik.COLORIZER_LINEAR;
colorizer.add_stop(10, mapnik2.Color(100,100,100,100)); colorizer.add_stop(10, mapnik.Color(100,100,100,100));
colorizer.add_stop(20, mapnik2.Color(200,200,200,200)); colorizer.add_stop(20, mapnik.Color(200,200,200,200));
#should be default colour #should be default colour
eq_(colorizer.get_color(-50), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
eq_(colorizer.get_color(9.9), mapnik2.Color(0,0,0,0)); eq_(colorizer.get_color(9.9), mapnik.Color(0,0,0,0));
#should be stop 1 #should be stop 1
eq_(colorizer.get_color(10), mapnik2.Color(100,100,100,100)); eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
#should be stop 2 #should be stop 2
eq_(colorizer.get_color(20), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
#half way between stops 1 and 2 #half way between stops 1 and 2
eq_(colorizer.get_color(15), mapnik2.Color(150,150,150,150)); eq_(colorizer.get_color(15), mapnik.Color(150,150,150,150));
#after stop 2 #after stop 2
eq_(colorizer.get_color(100), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(100), mapnik.Color(200,200,200,200));
def test_stop_label(): def test_stop_label():
stop = mapnik2.ColorizerStop(1, mapnik2.COLORIZER_LINEAR, mapnik2.Color('red')) stop = mapnik.ColorizerStop(1, mapnik.COLORIZER_LINEAR, mapnik.Color('red'))
assert not stop.label assert not stop.label
label = u"32º C".encode('utf8') label = u"32º C".encode('utf8')
stop.label = label stop.label = label

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path, save_data, contains_word from utilities import execution_path, save_data, contains_word
import os, mapnik2 import os, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -13,20 +13,20 @@ def setup():
def test_dataraster_coloring(): def test_dataraster_coloring():
srs = '+init=epsg:32630' srs = '+init=epsg:32630'
lyr = mapnik2.Layer('dataraster') lyr = mapnik.Layer('dataraster')
if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names(): if 'gdal' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Gdal( lyr.datasource = mapnik.Gdal(
file = '../data/raster/dataraster.tif', file = '../data/raster/dataraster.tif',
band = 1, band = 1,
) )
lyr.srs = srs lyr.srs = srs
_map = mapnik2.Map(256,256, srs) _map = mapnik.Map(256,256, srs)
style = mapnik2.Style() style = mapnik.Style()
rule = mapnik2.Rule() rule = mapnik.Rule()
sym = mapnik2.RasterSymbolizer() sym = mapnik.RasterSymbolizer()
# Assigning a colorizer to the RasterSymbolizer tells the later # Assigning a colorizer to the RasterSymbolizer tells the later
# that it should use it to colorize the raw data raster # that it should use it to colorize the raw data raster
sym.colorizer = mapnik2.RasterColorizer(mapnik2.COLORIZER_DISCRETE, mapnik2.Color("transparent")) sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color("transparent"))
for value, color in [ for value, color in [
( 0, "#0044cc"), ( 0, "#0044cc"),
@ -41,7 +41,7 @@ def test_dataraster_coloring():
( 90, "#660066"), ( 90, "#660066"),
( 200, "transparent"), ( 200, "transparent"),
]: ]:
sym.colorizer.add_stop(value, mapnik2.Color(color)) sym.colorizer.add_stop(value, mapnik.Color(color))
rule.symbols.append(sym) rule.symbols.append(sym)
style.rules.append(rule) style.rules.append(rule)
_map.append_style('foo', style) _map.append_style('foo', style)
@ -49,8 +49,8 @@ def test_dataraster_coloring():
_map.layers.append(lyr) _map.layers.append(lyr)
_map.zoom_to_box(lyr.envelope()) _map.zoom_to_box(lyr.envelope())
im = mapnik2.Image(_map.width,_map.height) im = mapnik.Image(_map.width,_map.height)
mapnik2.render(_map, im) mapnik.render(_map, im)
# save a png somewhere so we can see it # save a png somewhere so we can see it
save_data('test_dataraster_coloring.png', im.tostring('png')) save_data('test_dataraster_coloring.png', im.tostring('png'))
imdata = im.tostring() imdata = im.tostring()
@ -59,14 +59,14 @@ def test_dataraster_coloring():
def test_dataraster_query_point(): def test_dataraster_query_point():
srs = '+init=epsg:32630' srs = '+init=epsg:32630'
lyr = mapnik2.Layer('dataraster') lyr = mapnik.Layer('dataraster')
if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names(): if 'gdal' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Gdal( lyr.datasource = mapnik.Gdal(
file = '../data/raster/dataraster.tif', file = '../data/raster/dataraster.tif',
band = 1, band = 1,
) )
lyr.srs = srs lyr.srs = srs
_map = mapnik2.Map(256,256, srs) _map = mapnik.Map(256,256, srs)
_map.layers.append(lyr) _map.layers.append(lyr)
# point inside raster extent with valid data # point inside raster extent with valid data
@ -88,12 +88,12 @@ def test_dataraster_query_point():
assert len(features) == 0 assert len(features) == 0
def test_load_save_map(): def test_load_save_map():
map = mapnik2.Map(256,256) map = mapnik.Map(256,256)
in_map = "../data/good_maps/raster_symbolizer.xml" in_map = "../data/good_maps/raster_symbolizer.xml"
try: try:
mapnik2.load_map(map, in_map) mapnik.load_map(map, in_map)
out_map = mapnik2.save_map_to_string(map) out_map = mapnik.save_map_to_string(map)
assert 'RasterSymbolizer' in out_map assert 'RasterSymbolizer' in out_map
assert 'RasterColorizer' in out_map assert 'RasterColorizer' in out_map
assert 'stop' in out_map assert 'stop' in out_map
@ -106,13 +106,13 @@ def test_raster_with_alpha_blends_correctly_with_background():
WIDTH = 500 WIDTH = 500
HEIGHT = 500 HEIGHT = 500
map = mapnik2.Map(WIDTH, HEIGHT) map = mapnik.Map(WIDTH, HEIGHT)
WHITE = mapnik2.Color(255, 255, 255) WHITE = mapnik.Color(255, 255, 255)
map.background = WHITE map.background = WHITE
style = mapnik2.Style() style = mapnik.Style()
rule = mapnik2.Rule() rule = mapnik.Rule()
symbolizer = mapnik2.RasterSymbolizer() symbolizer = mapnik.RasterSymbolizer()
#XXX: This fixes it, see http://trac.mapnik.org/ticket/759#comment:3 #XXX: This fixes it, see http://trac.mapnik.org/ticket/759#comment:3
# (and remove comment when this test passes) # (and remove comment when this test passes)
#symbolizer.scaling="bilinear_old" #symbolizer.scaling="bilinear_old"
@ -122,18 +122,18 @@ def test_raster_with_alpha_blends_correctly_with_background():
map.append_style('raster_style', style) map.append_style('raster_style', style)
map_layer = mapnik2.Layer('test_layer') map_layer = mapnik.Layer('test_layer')
filepath = '../data/raster/white-alpha.png' filepath = '../data/raster/white-alpha.png'
if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names(): if 'gdal' in mapnik.DatasourceCache.instance().plugin_names():
map_layer.datasource = mapnik2.Gdal(file=filepath) map_layer.datasource = mapnik.Gdal(file=filepath)
map_layer.styles.append('raster_style') map_layer.styles.append('raster_style')
map.layers.append(map_layer) map.layers.append(map_layer)
map.zoom_all() map.zoom_all()
mim = mapnik2.Image(WIDTH, HEIGHT) mim = mapnik.Image(WIDTH, HEIGHT)
mapnik2.render(map, mim) mapnik.render(map, mim)
save_data('test_raster_with_alpha_blends_correctly_with_background.png', save_data('test_raster_with_alpha_blends_correctly_with_background.png',
mim.tostring('png')) mim.tostring('png'))
imdata = mim.tostring() imdata = mim.tostring()
@ -143,28 +143,28 @@ def test_raster_with_alpha_blends_correctly_with_background():
def test_raster_warping(): def test_raster_warping():
lyrSrs = "+init=epsg:32630" lyrSrs = "+init=epsg:32630"
mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
lyr = mapnik2.Layer('dataraster', lyrSrs) lyr = mapnik.Layer('dataraster', lyrSrs)
if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names(): if 'gdal' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Gdal( lyr.datasource = mapnik.Gdal(
file = '../data/raster/dataraster.tif', file = '../data/raster/dataraster.tif',
band = 1, band = 1,
) )
sym = mapnik2.RasterSymbolizer() sym = mapnik.RasterSymbolizer()
sym.colorizer = mapnik2.RasterColorizer(mapnik2.COLORIZER_DISCRETE, mapnik2.Color(255,255,0)) sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color(255,255,0))
rule = mapnik2.Rule() rule = mapnik.Rule()
rule.symbols.append(sym) rule.symbols.append(sym)
style = mapnik2.Style() style = mapnik.Style()
style.rules.append(rule) style.rules.append(rule)
_map = mapnik2.Map(256,256, mapSrs) _map = mapnik.Map(256,256, mapSrs)
_map.append_style('foo', style) _map.append_style('foo', style)
lyr.styles.append('foo') lyr.styles.append('foo')
_map.layers.append(lyr) _map.layers.append(lyr)
prj_trans = mapnik2.ProjTransform(mapnik2.Projection(mapSrs), prj_trans = mapnik.ProjTransform(mapnik.Projection(mapSrs),
mapnik2.Projection(lyrSrs)) mapnik.Projection(lyrSrs))
_map.zoom_to_box(prj_trans.backward(lyr.envelope())) _map.zoom_to_box(prj_trans.backward(lyr.envelope()))
im = mapnik2.Image(_map.width,_map.height) im = mapnik.Image(_map.width,_map.height)
mapnik2.render(_map, im) mapnik.render(_map, im)
# save a png somewhere so we can see it # save a png somewhere so we can see it
save_data('test_raster_warping.png', im.tostring('png')) save_data('test_raster_warping.png', im.tostring('png'))
imdata = im.tostring() imdata = im.tostring()
@ -173,27 +173,27 @@ def test_raster_warping():
def test_raster_warping_does_not_overclip_source(): def test_raster_warping_does_not_overclip_source():
lyrSrs = "+init=epsg:32630" lyrSrs = "+init=epsg:32630"
mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' mapSrs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
lyr = mapnik2.Layer('dataraster', lyrSrs) lyr = mapnik.Layer('dataraster', lyrSrs)
if 'gdal' in mapnik2.DatasourceCache.instance().plugin_names(): if 'gdal' in mapnik.DatasourceCache.instance().plugin_names():
lyr.datasource = mapnik2.Gdal( lyr.datasource = mapnik.Gdal(
file = '../data/raster/dataraster.tif', file = '../data/raster/dataraster.tif',
band = 1, band = 1,
) )
sym = mapnik2.RasterSymbolizer() sym = mapnik.RasterSymbolizer()
sym.colorizer = mapnik2.RasterColorizer(mapnik2.COLORIZER_DISCRETE, mapnik2.Color(255,255,0)) sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color(255,255,0))
rule = mapnik2.Rule() rule = mapnik.Rule()
rule.symbols.append(sym) rule.symbols.append(sym)
style = mapnik2.Style() style = mapnik.Style()
style.rules.append(rule) style.rules.append(rule)
_map = mapnik2.Map(256,256, mapSrs) _map = mapnik.Map(256,256, mapSrs)
_map.background=mapnik2.Color('white') _map.background=mapnik.Color('white')
_map.append_style('foo', style) _map.append_style('foo', style)
lyr.styles.append('foo') lyr.styles.append('foo')
_map.layers.append(lyr) _map.layers.append(lyr)
_map.zoom_to_box(mapnik2.Box2d(3,42,4,43)) _map.zoom_to_box(mapnik.Box2d(3,42,4,43))
im = mapnik2.Image(_map.width,_map.height) im = mapnik.Image(_map.width,_map.height)
mapnik2.render(_map, im) mapnik.render(_map, im)
# save a png somewhere so we can see it # save a png somewhere so we can see it
save_data('test_raster_warping_does_not_overclip_source.png', save_data('test_raster_warping_does_not_overclip_source.png',
im.tostring('png')) im.tostring('png'))

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
import os, mapnik2 import os, mapnik
from utilities import Todo from utilities import Todo
import json import json
@ -35,31 +35,31 @@ def resolve(grid,x,y):
def create_grid_map(width,height): def create_grid_map(width,height):
places_ds = mapnik2.PointDatasource() places_ds = mapnik.PointDatasource()
places_ds.add_point(143.10,-38.60,'Name','South East') places_ds.add_point(143.10,-38.60,'Name','South East')
places_ds.add_point(142.48,-38.60,'Name','South West') places_ds.add_point(142.48,-38.60,'Name','South West')
places_ds.add_point(142.48,-38.38,'Name','North West') places_ds.add_point(142.48,-38.38,'Name','North West')
places_ds.add_point(143.10,-38.38,'Name','North East') places_ds.add_point(143.10,-38.38,'Name','North East')
s = mapnik2.Style() s = mapnik.Style()
r = mapnik2.Rule() r = mapnik.Rule()
#symb = mapnik2.PointSymbolizer() #symb = mapnik.PointSymbolizer()
symb = mapnik2.MarkersSymbolizer() symb = mapnik.MarkersSymbolizer()
symb.allow_overlap = True symb.allow_overlap = True
r.symbols.append(symb) r.symbols.append(symb)
label = mapnik2.TextSymbolizer(mapnik2.Expression('[Name]'), label = mapnik.TextSymbolizer(mapnik.Expression('[Name]'),
'DejaVu Sans Book', 'DejaVu Sans Book',
10, 10,
mapnik2.Color('black') mapnik.Color('black')
) )
label.allow_overlap = True label.allow_overlap = True
label.displacement = (0,-10) label.displacement = (0,-10)
#r.symbols.append(label) #r.symbols.append(label)
s.rules.append(r) s.rules.append(r)
lyr = mapnik2.Layer('Places') lyr = mapnik.Layer('Places')
lyr.datasource = places_ds lyr.datasource = places_ds
lyr.styles.append('places_labels') lyr.styles.append('places_labels')
m = mapnik2.Map(width,height) m = mapnik.Map(width,height)
m.append_style('places_labels',s) m.append_style('places_labels',s)
m.layers.append(lyr) m.layers.append(lyr)
return m return m
@ -68,10 +68,10 @@ def test_render_grid():
""" test old method """ """ test old method """
width,height = 256,256 width,height = 256,256
m = create_grid_map(width,height) m = create_grid_map(width,height)
ul_lonlat = mapnik2.Coord(142.30,-38.20) ul_lonlat = mapnik.Coord(142.30,-38.20)
lr_lonlat = mapnik2.Coord(143.40,-38.80) lr_lonlat = mapnik.Coord(143.40,-38.80)
m.zoom_to_box(mapnik2.Box2d(ul_lonlat,lr_lonlat)) m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
grid = mapnik2.render_grid(m,0,key='Name',resolution=4,fields=['Name']) grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
eq_(grid,grid_correct) eq_(grid,grid_correct)
eq_(resolve(grid,0,0),None) eq_(resolve(grid,0,0),None)
@ -104,18 +104,18 @@ def test_render_grid2():
""" test old against new""" """ test old against new"""
width,height = 256,256 width,height = 256,256
m = create_grid_map(width,height) m = create_grid_map(width,height)
ul_lonlat = mapnik2.Coord(142.30,-38.20) ul_lonlat = mapnik.Coord(142.30,-38.20)
lr_lonlat = mapnik2.Coord(143.40,-38.80) lr_lonlat = mapnik.Coord(143.40,-38.80)
m.zoom_to_box(mapnik2.Box2d(ul_lonlat,lr_lonlat)) m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
# new method # new method
grid = mapnik2.Grid(m.width,m.height,key='Name') grid = mapnik.Grid(m.width,m.height,key='Name')
mapnik2.render_layer(m,grid,layer=0,fields=['Name']) mapnik.render_layer(m,grid,layer=0,fields=['Name'])
utf1 = grid.encode('utf',resolution=4) utf1 = grid.encode('utf',resolution=4)
eq_(utf1,grid_correct_new) eq_(utf1,grid_correct_new)
# old method - to be removed # old method - to be removed
utf2 = mapnik2.render_grid(m,0,key='Name',resolution=4,fields=['Name']) utf2 = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
eq_(utf2,grid_correct) eq_(utf2,grid_correct)
# for complex polygons these will not be true # for complex polygons these will not be true

View file

@ -3,7 +3,7 @@
from nose.tools import * from nose.tools import *
import os, mapnik2 import os, mapnik
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
@ -16,19 +16,19 @@ def setup():
def test_simplest_render(): def test_simplest_render():
m = mapnik2.Map(256, 256) m = mapnik.Map(256, 256)
i = mapnik2.Image(m.width, m.height) i = mapnik.Image(m.width, m.height)
mapnik2.render(m, i) mapnik.render(m, i)
s = i.tostring() s = i.tostring()
eq_(s, 256 * 256 * '\x00\x00\x00\x00') eq_(s, 256 * 256 * '\x00\x00\x00\x00')
def test_render_image_to_string(): def test_render_image_to_string():
i = mapnik2.Image(256, 256) i = mapnik.Image(256, 256)
i.background = mapnik2.Color('black') i.background = mapnik.Color('black')
s = i.tostring() s = i.tostring()
@ -38,24 +38,24 @@ def test_render_image_to_string():
def test_setting_alpha(): def test_setting_alpha():
w,h = 256,256 w,h = 256,256
im1 = mapnik2.Image(w,h) im1 = mapnik.Image(w,h)
# white, half transparent # white, half transparent
im1.background = mapnik2.Color('rgba(255,255,255,.5)') im1.background = mapnik.Color('rgba(255,255,255,.5)')
# pure white # pure white
im2 = mapnik2.Image(w,h) im2 = mapnik.Image(w,h)
im2.background = mapnik2.Color('rgba(255,255,255,1)') im2.background = mapnik.Color('rgba(255,255,255,1)')
im2.set_alpha(.5) im2.set_alpha(.5)
eq_(len(im1.tostring()), len(im2.tostring())) eq_(len(im1.tostring()), len(im2.tostring()))
def test_render_image_to_file(): def test_render_image_to_file():
i = mapnik2.Image(256, 256) i = mapnik.Image(256, 256)
i.background = mapnik2.Color('black') i.background = mapnik.Color('black')
if mapnik2.has_jpeg(): if mapnik.has_jpeg():
i.save('test.jpg') i.save('test.jpg')
i.save('test.png', 'png') i.save('test.png', 'png')
@ -71,17 +71,17 @@ def test_render_image_to_file():
def get_paired_images(w,h,mapfile): def get_paired_images(w,h,mapfile):
tmp_map = 'tmp_map.xml' tmp_map = 'tmp_map.xml'
m = mapnik2.Map(w,h) m = mapnik.Map(w,h)
mapnik2.load_map(m,mapfile) mapnik.load_map(m,mapfile)
i = mapnik2.Image(w,h) i = mapnik.Image(w,h)
m.zoom_all() m.zoom_all()
mapnik2.render(m,i) mapnik.render(m,i)
mapnik2.save_map(m,tmp_map) mapnik.save_map(m,tmp_map)
m2 = mapnik2.Map(w,h) m2 = mapnik.Map(w,h)
mapnik2.load_map(m2,tmp_map) mapnik.load_map(m2,tmp_map)
i2 = mapnik2.Image(w,h) i2 = mapnik.Image(w,h)
m2.zoom_all() m2.zoom_all()
mapnik2.render(m2,i2) mapnik.render(m2,i2)
os.remove(tmp_map) os.remove(tmp_map)
return i,i2 return i,i2
@ -122,37 +122,37 @@ def resolve(grid,x,y):
def test_render_grid(): def test_render_grid():
places_ds = mapnik2.PointDatasource() places_ds = mapnik.PointDatasource()
places_ds.add_point(143.10,-38.60,'Name','South East') places_ds.add_point(143.10,-38.60,'Name','South East')
places_ds.add_point(142.48,-38.60,'Name','South West') places_ds.add_point(142.48,-38.60,'Name','South West')
places_ds.add_point(142.48,-38.38,'Name','North West') places_ds.add_point(142.48,-38.38,'Name','North West')
places_ds.add_point(143.10,-38.38,'Name','North East') places_ds.add_point(143.10,-38.38,'Name','North East')
s = mapnik2.Style() s = mapnik.Style()
r = mapnik2.Rule() r = mapnik.Rule()
#symb = mapnik2.PointSymbolizer() #symb = mapnik.PointSymbolizer()
symb = mapnik2.MarkersSymbolizer() symb = mapnik.MarkersSymbolizer()
symb.allow_overlap = True symb.allow_overlap = True
r.symbols.append(symb) r.symbols.append(symb)
label = mapnik2.TextSymbolizer(mapnik2.Expression('[Name]'), label = mapnik.TextSymbolizer(mapnik.Expression('[Name]'),
'DejaVu Sans Book', 'DejaVu Sans Book',
10, 10,
mapnik2.Color('black') mapnik.Color('black')
) )
label.allow_overlap = True label.allow_overlap = True
label.displacement = (0,-10) label.displacement = (0,-10)
#r.symbols.append(label) #r.symbols.append(label)
s.rules.append(r) s.rules.append(r)
lyr = mapnik2.Layer('Places') lyr = mapnik.Layer('Places')
lyr.datasource = places_ds lyr.datasource = places_ds
lyr.styles.append('places_labels') lyr.styles.append('places_labels')
m = mapnik2.Map(256,256) m = mapnik.Map(256,256)
m.append_style('places_labels',s) m.append_style('places_labels',s)
m.layers.append(lyr) m.layers.append(lyr)
ul_lonlat = mapnik2.Coord(142.30,-38.20) ul_lonlat = mapnik.Coord(142.30,-38.20)
lr_lonlat = mapnik2.Coord(143.40,-38.80) lr_lonlat = mapnik.Coord(143.40,-38.80)
m.zoom_to_box(mapnik2.Box2d(ul_lonlat,lr_lonlat)) m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat))
grid = mapnik2.render_grid(m,0,key='Name',resolution=4,fields=['Name']) grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
eq_(grid,grid_correct) eq_(grid,grid_correct)
eq_(resolve(grid,0,0),None) eq_(resolve(grid,0,0),None)
@ -183,25 +183,25 @@ def test_render_grid():
def test_render_points(): def test_render_points():
if not mapnik2.has_cairo(): return if not mapnik.has_cairo(): return
# create and populate point datasource (WGS84 lat-lon coordinates) # create and populate point datasource (WGS84 lat-lon coordinates)
places_ds = mapnik2.PointDatasource() places_ds = mapnik.PointDatasource()
places_ds.add_point(142.48,-38.38,'Name','Westernmost Point') # westernmost places_ds.add_point(142.48,-38.38,'Name','Westernmost Point') # westernmost
places_ds.add_point(143.10,-38.60,'Name','Southernmost Point') # southernmost places_ds.add_point(143.10,-38.60,'Name','Southernmost Point') # southernmost
# create layer/rule/style # create layer/rule/style
s = mapnik2.Style() s = mapnik.Style()
r = mapnik2.Rule() r = mapnik.Rule()
symb = mapnik2.PointSymbolizer() symb = mapnik.PointSymbolizer()
symb.allow_overlap = True symb.allow_overlap = True
r.symbols.append(symb) r.symbols.append(symb)
s.rules.append(r) s.rules.append(r)
lyr = mapnik2.Layer('Places','+proj=latlon +datum=WGS84') lyr = mapnik.Layer('Places','+proj=latlon +datum=WGS84')
lyr.datasource = places_ds lyr.datasource = places_ds
lyr.styles.append('places_labels') lyr.styles.append('places_labels')
# latlon bounding box corners # latlon bounding box corners
ul_lonlat = mapnik2.Coord(142.30,-38.20) ul_lonlat = mapnik.Coord(142.30,-38.20)
lr_lonlat = mapnik2.Coord(143.40,-38.80) lr_lonlat = mapnik.Coord(143.40,-38.80)
# render for different projections # render for different projections
projs = { projs = {
'latlon': '+proj=latlon +datum=WGS84', 'latlon': '+proj=latlon +datum=WGS84',
@ -210,14 +210,14 @@ def test_render_points():
'utm': '+proj=utm +zone=54 +datum=WGS84' 'utm': '+proj=utm +zone=54 +datum=WGS84'
} }
for projdescr in projs.iterkeys(): for projdescr in projs.iterkeys():
m = mapnik2.Map(1000, 500, projs[projdescr]) m = mapnik.Map(1000, 500, projs[projdescr])
m.append_style('places_labels',s) m.append_style('places_labels',s)
m.layers.append(lyr) m.layers.append(lyr)
p = mapnik2.Projection(projs[projdescr]) p = mapnik.Projection(projs[projdescr])
m.zoom_to_box(p.forward(mapnik2.Box2d(ul_lonlat,lr_lonlat))) m.zoom_to_box(p.forward(mapnik.Box2d(ul_lonlat,lr_lonlat)))
# Render to SVG so that it can be checked how many points are there with string comparison # Render to SVG so that it can be checked how many points are there with string comparison
svg_file = '/tmp/%s.svg' svg_file = '/tmp/%s.svg'
mapnik2.render_to_file(m, svg_file) mapnik.render_to_file(m, svg_file)
num_points_present = len(places_ds.all_features()) num_points_present = len(places_ds.all_features())
svg = open(svg_file,'r').read() svg = open(svg_file,'r').read()
num_points_rendered = svg.count('<image ') num_points_rendered = svg.count('<image ')

View file

@ -5,7 +5,7 @@ from utilities import Todo
from utilities import execution_path from utilities import execution_path
import tempfile import tempfile
import os, sys, glob, mapnik2 import os, sys, glob, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
@ -18,13 +18,13 @@ def test():
# 2. Save map as XML # 2. Save map as XML
# 3. Load map to a second object # 3. Load map to a second object
# 4. Compare both map objects # 4. Compare both map objects
map = mapnik2.Map(256, 256) map = mapnik.Map(256, 256)
raise Todo("map comparison is currently broken due to lacking relative paths support (#324,#340") raise Todo("map comparison is currently broken due to lacking relative paths support (#324,#340")
def compare_map(in_map): def compare_map(in_map):
mapnik2.load_map(map, in_map) mapnik.load_map(map, in_map)
(handle, test_map) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map1-') (handle, test_map) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map1-')
os.close(handle) os.close(handle)
@ -35,11 +35,11 @@ def test():
if os.path.exists(test_map): if os.path.exists(test_map):
os.remove(test_map) os.remove(test_map)
mapnik2.save_map(map, test_map) mapnik.save_map(map, test_map)
new_map = mapnik2.Map(256, 256) new_map = mapnik.Map(256, 256)
mapnik2.load_map(new_map, test_map) mapnik.load_map(new_map, test_map)
open(test_map2,'w').write(mapnik2.save_map_to_string(new_map)) open(test_map2,'w').write(mapnik.save_map_to_string(new_map))
diff = ' diff %s %s' % (os.path.abspath(test_map),os.path.abspath(test_map2)) diff = ' diff %s %s' % (os.path.abspath(test_map),os.path.abspath(test_map2))
try: try:

View file

@ -4,18 +4,18 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import os, mapnik2 import os, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
# from another directory we need to chdir() # from another directory we need to chdir()
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
if 'shape' in mapnik2.DatasourceCache.instance().plugin_names(): if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
# Shapefile initialization # Shapefile initialization
def test_shapefile_init(): def test_shapefile_init():
s = mapnik2.Shapefile(file='../../demo/data/boundaries') s = mapnik.Shapefile(file='../../demo/data/boundaries')
e = s.envelope() e = s.envelope()
@ -26,7 +26,7 @@ if 'shape' in mapnik2.DatasourceCache.instance().plugin_names():
# Shapefile properties # Shapefile properties
def test_shapefile_properties(): def test_shapefile_properties():
s = mapnik2.Shapefile(file='../../demo/data/boundaries', encoding='latin1') s = mapnik.Shapefile(file='../../demo/data/boundaries', encoding='latin1')
f = s.features_at_point(s.envelope().center()).features[0] f = s.features_at_point(s.envelope().center()).features[0]
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9') eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
import os, mapnik2 import os, mapnik
from timeit import Timer, time from timeit import Timer, time
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
@ -59,7 +59,7 @@ def do_encoding():
def blank(): def blank():
eval('image.tostring("%s")' % c) eval('image.tostring("%s")' % c)
blank_im = mapnik2.Image(512,512) blank_im = mapnik.Image(512,512)
for c in combinations: for c in combinations:
t = Timer(blank) t = Timer(blank)
@ -67,8 +67,8 @@ def do_encoding():
def solid(): def solid():
eval('image.tostring("%s")' % c) eval('image.tostring("%s")' % c)
solid_im = mapnik2.Image(512,512) solid_im = mapnik.Image(512,512)
solid_im.background = mapnik2.Color("#f2efe9") solid_im.background = mapnik.Color("#f2efe9")
for c in combinations: for c in combinations:
t = Timer(solid) t = Timer(solid)
@ -77,7 +77,7 @@ def do_encoding():
def many_colors(): def many_colors():
eval('image.tostring("%s")' % c) eval('image.tostring("%s")' % c)
# lots of colors: http://tile.osm.org/13/4194/2747.png # lots of colors: http://tile.osm.org/13/4194/2747.png
many_colors_im = mapnik2.Image.open('../data/images/13_4194_2747.png') many_colors_im = mapnik.Image.open('../data/images/13_4194_2747.png')
for c in combinations: for c in combinations:
t = Timer(many_colors) t = Timer(many_colors)

View file

@ -5,7 +5,7 @@ from utilities import execution_path
from Queue import Queue from Queue import Queue
import threading import threading
import os, mapnik2 import os, mapnik
import sqlite3 import sqlite3
def setup(): def setup():
@ -19,10 +19,10 @@ DB = '../data/sqlite/world.sqlite'
TABLE= 'world_merc' TABLE= 'world_merc'
def create_ds(): def create_ds():
ds = mapnik2.SQLite(file=DB,table=TABLE) ds = mapnik.SQLite(file=DB,table=TABLE)
fs = ds.all_features() fs = ds.all_features()
if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names(): if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
def test_rtree_creation(): def test_rtree_creation():
@ -47,19 +47,19 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(cur.fetchone()[0],TOTAL) eq_(cur.fetchone()[0],TOTAL)
cur.close() cur.close()
ds = mapnik2.SQLite(file=DB,table=TABLE) ds = mapnik.SQLite(file=DB,table=TABLE)
fs = ds.all_features() fs = ds.all_features()
eq_(len(fs),TOTAL) eq_(len(fs),TOTAL)
os.unlink(index) os.unlink(index)
ds = mapnik2.SQLite(file=DB,table=TABLE,use_spatial_index=False) ds = mapnik.SQLite(file=DB,table=TABLE,use_spatial_index=False)
fs = ds.all_features() fs = ds.all_features()
eq_(len(fs),TOTAL) eq_(len(fs),TOTAL)
eq_(os.path.exists(index),False) eq_(os.path.exists(index),False)
ds = mapnik2.SQLite(file=DB,table=TABLE,use_spatial_index=True) ds = mapnik.SQLite(file=DB,table=TABLE,use_spatial_index=True)
fs = ds.all_features() fs = ds.all_features()
for feat in fs: for feat in fs:
query = mapnik2.Query(feat.envelope()) query = mapnik.Query(feat.envelope())
selected = ds.features(query) selected = ds.features(query)
eq_(len(selected.features)>=1,True) eq_(len(selected.features)>=1,True)

View file

@ -3,19 +3,19 @@
from nose.tools import * from nose.tools import *
from utilities import execution_path from utilities import execution_path
import os, mapnik2 import os, mapnik
def setup(): def setup():
# All of the paths used are relative, if we run the tests # All of the paths used are relative, if we run the tests
# from another directory we need to chdir() # from another directory we need to chdir()
os.chdir(execution_path('.')) os.chdir(execution_path('.'))
if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names(): if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
def test_attachdb_with_relative_file(): def test_attachdb_with_relative_file():
# The point table and index is in the qgis_spatiallite.sqlite # The point table and index is in the qgis_spatiallite.sqlite
# database. If either is not found, then this fails # database. If either is not found, then this fails
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='point', table='point',
attachdb='scratch@qgis_spatiallite.sqlite' attachdb='scratch@qgis_spatiallite.sqlite'
) )
@ -24,7 +24,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['pkuid'],1) eq_(feature['pkuid'],1)
def test_attachdb_with_multiple_files(): def test_attachdb_with_multiple_files():
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='attachedtest', table='attachedtest',
attachdb='scratch1@:memory:,scratch2@:memory:', attachdb='scratch1@:memory:,scratch2@:memory:',
initdb=''' initdb='''
@ -41,7 +41,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
def test_attachdb_with_absolute_file(): def test_attachdb_with_absolute_file():
# The point table and index is in the qgis_spatiallite.sqlite # The point table and index is in the qgis_spatiallite.sqlite
# database. If either is not found, then this fails # database. If either is not found, then this fails
ds = mapnik2.SQLite(file=os.getcwd() + '/../data/sqlite/world.sqlite', ds = mapnik.SQLite(file=os.getcwd() + '/../data/sqlite/world.sqlite',
table='point', table='point',
attachdb='scratch@qgis_spatiallite.sqlite' attachdb='scratch@qgis_spatiallite.sqlite'
) )
@ -50,7 +50,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['pkuid'],1) eq_(feature['pkuid'],1)
def test_attachdb_with_index(): def test_attachdb_with_index():
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='attachedtest', table='attachedtest',
attachdb='scratch@:memory:', attachdb='scratch@:memory:',
initdb=''' initdb='''
@ -64,7 +64,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature,None) eq_(feature,None)
def test_attachdb_with_explicit_index(): def test_attachdb_with_explicit_index():
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='attachedtest', table='attachedtest',
index_table='myindex', index_table='myindex',
attachdb='scratch@:memory:', attachdb='scratch@:memory:',
@ -79,7 +79,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature,None) eq_(feature,None)
def test_attachdb_with_sql_join(): def test_attachdb_with_sql_join():
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)', table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
attachdb='busines@business.sqlite' attachdb='busines@business.sqlite'
) )
@ -127,7 +127,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
print 'invalid key/v %s/%s for: %s' % (k,v,feature) print 'invalid key/v %s/%s for: %s' % (k,v,feature)
def test_subqueries(): def test_subqueries():
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='world_merc', table='world_merc',
) )
fs = ds.featureset() fs = ds.featureset()
@ -145,7 +145,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['lon'],-61.783) eq_(feature['lon'],-61.783)
eq_(feature['lat'],17.078) eq_(feature['lat'],17.078)
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select * from world_merc)', table='(select * from world_merc)',
) )
fs = ds.featureset() fs = ds.featureset()
@ -163,7 +163,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['lon'],-61.783) eq_(feature['lon'],-61.783)
eq_(feature['lat'],17.078) eq_(feature['lat'],17.078)
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select OGC_FID,GEOMETRY from world_merc)', table='(select OGC_FID,GEOMETRY from world_merc)',
) )
fs = ds.featureset() fs = ds.featureset()
@ -171,7 +171,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['OGC_FID'],1) eq_(feature['OGC_FID'],1)
eq_(len(feature),1) eq_(len(feature),1)
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select GEOMETRY,OGC_FID,fips from world_merc)', table='(select GEOMETRY,OGC_FID,fips from world_merc)',
) )
fs = ds.featureset() fs = ds.featureset()
@ -179,7 +179,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['OGC_FID'],1) eq_(feature['OGC_FID'],1)
eq_(feature['fips'],u'AC') eq_(feature['fips'],u'AC')
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select GEOMETRY,rowid as aliased_id,fips from world_merc)', table='(select GEOMETRY,rowid as aliased_id,fips from world_merc)',
key_field='aliased_id' key_field='aliased_id'
) )
@ -188,7 +188,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
eq_(feature['aliased_id'],1) eq_(feature['aliased_id'],1)
eq_(feature['fips'],u'AC') eq_(feature['fips'],u'AC')
ds = mapnik2.SQLite(file='../data/sqlite/world.sqlite', ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)', table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)',
) )
fs = ds.featureset() fs = ds.featureset()
@ -198,7 +198,7 @@ if 'sqlite' in mapnik2.DatasourceCache.instance().plugin_names():
def test_empty_db(): def test_empty_db():
ds = mapnik2.SQLite(file='../data/sqlite/empty.db', ds = mapnik.SQLite(file='../data/sqlite/empty.db',
table='empty', table='empty',
) )
fs = ds.featureset() fs = ds.featureset()

View file

@ -42,14 +42,14 @@ def main():
# Allow python to find libraries for testing on the buildbot # Allow python to find libraries for testing on the buildbot
sys.path.insert(0, os.path.join(prefix, "lib/python%s/site-packages" % sys.version[:3])) sys.path.insert(0, os.path.join(prefix, "lib/python%s/site-packages" % sys.version[:3]))
import mapnik2 import mapnik
if not quiet: if not quiet:
print("- mapnik2 path: %s" % mapnik2.__file__) print("- mapnik path: %s" % mapnik.__file__)
if hasattr(mapnik2,'_mapnik2'): if hasattr(mapnik,'_mapnik'):
print("- _mapnik2.so path: %s" % mapnik2._mapnik2.__file__) print("- _mapnik.so path: %s" % mapnik._mapnik.__file__)
print("- Input plugins path: %s" % mapnik2.inputpluginspath) print("- Input plugins path: %s" % mapnik.inputpluginspath)
print("- Font path: %s" % mapnik2.fontscollectionpath) print("- Font path: %s" % mapnik.fontscollectionpath)
print('') print('')
print("- Running nosetests:") print("- Running nosetests:")
print('') print('')

View file

@ -79,7 +79,7 @@ git_revision = os.popen("git rev-list --max-count=1 HEAD").read()
configuration = { configuration = {
"prefix": config_env['PREFIX'], "prefix": config_env['PREFIX'],
"mapnik_libname": 'mapnik2', "mapnik_libname": 'mapnik',
"libdir_schema": config_env['LIBDIR_SCHEMA'], "libdir_schema": config_env['LIBDIR_SCHEMA'],
"ldflags": ldflags, "ldflags": ldflags,
"dep_libs": dep_libs, "dep_libs": dep_libs,

View file

@ -37,7 +37,7 @@ headers = ['#plugins/input/ogr'] + env['CPPPATH']
program_env['LIBS'] = [env['PLUGINS']['ogr']['lib']] program_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
program_env['LIBS'].append('mapnik2') program_env['LIBS'].append('mapnik')
program_env['LIBS'].append(env['ICU_LIB_NAME']) program_env['LIBS'].append(env['ICU_LIB_NAME'])
program_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) program_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND'])
program_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND']) program_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND'])

View file

@ -40,7 +40,7 @@ headers = ['#plugins/input/postgis'] + env['CPPPATH']
libraries = [] libraries = []
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,'sqlite3','pq','mapnik2']) libraries.extend([boost_program_options,'sqlite3','pq','mapnik'])
linkflags = env['CUSTOM_LDFLAGS'] linkflags = env['CUSTOM_LDFLAGS']
if env['SQLITE_LINKFLAGS']: if env['SQLITE_LINKFLAGS']:

View file

@ -37,7 +37,7 @@ headers = env['CPPPATH']
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'])
svg2png = program_env.Program('svg2png', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) svg2png = program_env.Program('svg2png', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])

View file

@ -132,7 +132,7 @@ if __name__ == "__main__":
fixed_xml_string = re.sub(pattern, '', fixed_xml_string) fixed_xml_string = re.sub(pattern, '', fixed_xml_string)
print "removed ", layer print "removed ", layer
# Tree to be updated to be mapnik2 compliant # Tree to be updated to be mapnik compliant
tree = objectify.parse(StringIO.StringIO(fixed_xml_string), parser=parser) tree = objectify.parse(StringIO.StringIO(fixed_xml_string), parser=parser)
root = tree.getroot() root = tree.getroot()

View file

@ -1,15 +1,15 @@
# ------------------------------------------------- # -------------------------------------------------
# QtCreator Project For Mapnik2 # QtCreator Project For Mapnik
# ------------------------------------------------- # -------------------------------------------------
QT = QT =
TARGET = mapnik2 TARGET = mapnik
TEMPLATE = lib TEMPLATE = lib
INCLUDEPATH = \ INCLUDEPATH = \
../deps/agg/include \ ../deps/agg/include \
../deps/threadpool \ ../deps/threadpool \
../include/mapnik2 ../include/mapnik
HEADERS += \ HEADERS += \
../include/mapnik/grid/grid.hpp \ ../include/mapnik/grid/grid.hpp \