Merge branch 'master' of https://github.com/mapnik/mapnik
This commit is contained in:
commit
9d1afbbfc6
293 changed files with 4114 additions and 2863 deletions
|
@ -1,8 +1,4 @@
|
|||
# $Id: CHANGELOG 776 2008-12-7 01:30:27Z dane $
|
||||
|
||||
----------------
|
||||
Mapnik Changelog
|
||||
----------------
|
||||
# Mapnik Changelog
|
||||
|
||||
A simple log of core changes affecting Mapnik usage.
|
||||
|
||||
|
@ -11,10 +7,9 @@ Developers: Please commit along with changes.
|
|||
For a complete change history, see the SVN log.
|
||||
|
||||
|
||||
Mapnik 2.1.0
|
||||
------------
|
||||
## Mapnik 2.1.0
|
||||
|
||||
- Removed mutex locking during reprojection if using >= proj 4.7 (#1072)
|
||||
- Fix Markers rendering so that ellipse height/width units are pixels (previously were unintentially radii)
|
||||
|
||||
- Removed PointDatasource - use more robust MemoryDatasource instead (#1032)
|
||||
|
||||
|
@ -26,11 +21,12 @@ Mapnik 2.1.0
|
|||
|
||||
- Added <layer_by_sql> parameter in OGR plugin to select a layer by SQL query (besides name or index): see http://www.gdal.org/ogr/ogr_sql.html for specifications (kunitoki) (#472)
|
||||
|
||||
- Added suppport for output maps as tiff files (addresses #967 partially)
|
||||
- Added support for output maps as tiff files (addresses #967 partially)
|
||||
|
||||
- Added support for justify-alignment=auto. This is the new default. (#1125)
|
||||
|
||||
|
||||
Mapnik 2.0.0
|
||||
------------
|
||||
## Mapnik 2.0.0
|
||||
|
||||
- Add minimum-path-length property to text_symbolizer to allow labels to be placed only on lines of a certain length (#865)
|
||||
|
||||
|
@ -119,8 +115,7 @@ Mapnik 2.0.0
|
|||
- Implement MarkersSymbolizer in Cairo render and improve the markers placement finder. (#553)
|
||||
|
||||
|
||||
Mapnik 0.7.2 Release
|
||||
--------------------
|
||||
# Mapnik 0.7.2 Release
|
||||
|
||||
- Added forward compatibility for Mapnik 2.0 XML syntax (https://trac.mapnik.org/wiki/Mapnik2/Changes)
|
||||
|
||||
|
@ -163,8 +158,7 @@ Mapnik 0.7.2 Release
|
|||
- Fixed reading of label_position_tolerance on text_symbolizer and height for building_symbolizer
|
||||
|
||||
|
||||
Mapnik 0.7.0 Release
|
||||
--------------------
|
||||
# Mapnik 0.7.0 Release
|
||||
|
||||
(Packaged from r1574)
|
||||
|
||||
|
@ -203,13 +197,13 @@ Mapnik 0.7.0 Release
|
|||
|
||||
* Valid Usages include:
|
||||
|
||||
<Parameter name="table">
|
||||
(Select ST_Union(geom) as geom from table where ST_Intersects(geometry,!bbox!)) as map
|
||||
</Parameter>
|
||||
<Parameter name="table">
|
||||
(Select ST_Union(geom) as geom from table where ST_Intersects(geometry,!bbox!)) as map
|
||||
</Parameter>
|
||||
|
||||
<Parameter name="table">
|
||||
(Select * from table where geom && !bbox!) as map
|
||||
</Parameter>
|
||||
<Parameter name="table">
|
||||
(Select * from table where geom && !bbox!) as map
|
||||
</Parameter>
|
||||
|
||||
- PostGIS Plugin: Added 'scale_denominator' substitution ability in sql query string (#415/#465)
|
||||
|
||||
|
@ -305,8 +299,7 @@ Mapnik 0.7.0 Release
|
|||
|
||||
|
||||
|
||||
Mapnik 0.6.1 Release
|
||||
--------------------
|
||||
# Mapnik 0.6.1 Release
|
||||
|
||||
(Packaged from r1247)
|
||||
|
||||
|
@ -390,8 +383,7 @@ Mapnik 0.6.1 Release
|
|||
|
||||
|
||||
|
||||
Mapnik 0.6.0 Release
|
||||
--------------------
|
||||
# Mapnik 0.6.0 Release
|
||||
|
||||
(Packaged from r1066)
|
||||
|
6
Makefile
6
Makefile
|
@ -18,6 +18,9 @@ uninstall:
|
|||
python scons/scons.py uninstall
|
||||
|
||||
test:
|
||||
@python tests/visual_tests/test.py
|
||||
@tests/cpp_tests/font_registration_test
|
||||
@tests/cpp_tests/params_test
|
||||
@python tests/run_tests.py -q
|
||||
|
||||
pep8:
|
||||
|
@ -26,4 +29,7 @@ pep8:
|
|||
@pep8 -r --select=W293 -q --filename=*.py `pwd`/tests/ | xargs gsed -i 's/^[ \r\t]*$//'
|
||||
@pep8 -r --select=W391 -q --filename=*.py `pwd`/tests/ | xargs gsed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}'
|
||||
|
||||
grind:
|
||||
@valgrind --leak-check=full tests/cpp_tests/font_registration_test
|
||||
|
||||
.PHONY: clean reset uninstall test install
|
||||
|
|
25
SConstruct
25
SConstruct
|
@ -768,7 +768,7 @@ def GetMapnikLibVersion(context):
|
|||
|
||||
int main()
|
||||
{
|
||||
std::cout << MAPNIK_VERSION << std::endl;
|
||||
std::cout << MAPNIK_VERSION_STRING << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -778,11 +778,7 @@ int main()
|
|||
context.Result(ret[0])
|
||||
if not ret[1]:
|
||||
return []
|
||||
version = int(ret[1].strip())
|
||||
patch_level = version % 100
|
||||
minor_version = version / 100 % 1000
|
||||
major_version = version / 100000
|
||||
return [major_version,minor_version,patch_level]
|
||||
return ret[1].strip()
|
||||
|
||||
def icu_at_least_four_two(context):
|
||||
ret = context.TryRun("""
|
||||
|
@ -1072,7 +1068,7 @@ if not preconfigured:
|
|||
|
||||
# libxml2 should be optional but is currently not
|
||||
# https://github.com/mapnik/mapnik/issues/913
|
||||
if conf.parse_config('XML2_CONFIG'):
|
||||
if conf.parse_config('XML2_CONFIG',checks='--cflags'):
|
||||
env['HAS_LIBXML2'] = True
|
||||
|
||||
LIBSHEADERS = [
|
||||
|
@ -1382,14 +1378,13 @@ if not preconfigured:
|
|||
# fetch the mapnik version header in order to set the
|
||||
# ABI version used to build libmapnik.so on linux in src/build.py
|
||||
abi = conf.GetMapnikLibVersion()
|
||||
abi_fallback = [2,0,0]
|
||||
abi_fallback = "2.0.1-pre"
|
||||
if not abi:
|
||||
color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback)
|
||||
env['ABI_VERSION'] = abi_fallback
|
||||
else:
|
||||
env['ABI_VERSION'] = abi
|
||||
env['MAPNIK_VERSION_STRING'] = '.'.join(['%d' % i for i in env['ABI_VERSION']])
|
||||
abi = abi_fallback
|
||||
|
||||
env['ABI_VERSION'] = abi.replace('-pre','').split('.')
|
||||
env['MAPNIK_VERSION_STRING'] = abi
|
||||
|
||||
# Common C++ flags.
|
||||
if env['THREADING'] == 'multi':
|
||||
|
@ -1411,7 +1406,9 @@ if not preconfigured:
|
|||
pthread = '-pthread'
|
||||
|
||||
# Common debugging flags.
|
||||
debug_flags = '-g -DDEBUG -DMAPNIK_DEBUG'
|
||||
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
|
||||
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'
|
||||
|
||||
ndebug_flags = '-DNDEBUG'
|
||||
|
||||
|
||||
|
@ -1719,7 +1716,7 @@ if not HELP_REQUESTED:
|
|||
|
||||
# build C++ tests
|
||||
# not ready for release
|
||||
#SConscript('tests/cpp_tests/build.py')
|
||||
SConscript('tests/cpp_tests/build.py')
|
||||
|
||||
# not ready for release
|
||||
#if env['SVG_RENDERER']:
|
||||
|
|
|
@ -120,7 +120,7 @@ class _Coord(Coord,_injector):
|
|||
|
||||
Returns the easting (x) and northing (y) as a
|
||||
coordinate pair.
|
||||
|
||||
|
||||
Example: Project the geographic coordinates of the
|
||||
city center of Stuttgart into the local
|
||||
map projection (GK Zone 3/DHDN, EPSG 31467)
|
||||
|
@ -136,7 +136,7 @@ class _Coord(Coord,_injector):
|
|||
into the geographic space. The x component is
|
||||
considered to be the easting, the y component
|
||||
to be the northing.
|
||||
|
||||
|
||||
Returns the longitude (x) and latitude (y) as a
|
||||
coordinate pair.
|
||||
|
||||
|
@ -153,8 +153,8 @@ class _Coord(Coord,_injector):
|
|||
class _Box2d(Box2d,_injector):
|
||||
"""
|
||||
Represents a spatial envelope (i.e. bounding box).
|
||||
|
||||
|
||||
|
||||
|
||||
Following operators are defined for Box2d:
|
||||
|
||||
Addition:
|
||||
|
@ -285,12 +285,12 @@ def Datasource(**keywords):
|
|||
Create a Mapnik Datasource using a dictionary of parameters.
|
||||
|
||||
Keywords must include:
|
||||
|
||||
|
||||
type='plugin_name' # e.g. type='gdal'
|
||||
|
||||
|
||||
See the convenience factory methods of each input plugin for
|
||||
details on additional required keyword arguments.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
return CreateDatasource(keywords)
|
||||
|
@ -322,7 +322,7 @@ def PostGIS(**keywords):
|
|||
Required keyword arguments:
|
||||
dbname -- database name to connect to
|
||||
table -- table name or subselect query
|
||||
|
||||
|
||||
*Note: if using subselects for the 'table' value consider also
|
||||
passing the 'geometry_field' and 'srid' and 'extent_from_subquery'
|
||||
options and/or specifying the 'geometry_table' option.
|
||||
|
@ -572,13 +572,6 @@ def Geos(**keywords):
|
|||
keywords['type'] = 'geos'
|
||||
return CreateDatasource(keywords)
|
||||
|
||||
def mapnik_version_string(version=mapnik_version()):
|
||||
"""Return the Mapnik version as a string."""
|
||||
patch_level = version % 100
|
||||
minor_version = version / 100 % 1000
|
||||
major_version = version / 100000
|
||||
return '%s.%s.%s' % ( major_version, minor_version,patch_level)
|
||||
|
||||
def mapnik_version_from_string(version_string):
|
||||
"""Return the Mapnik version from a string."""
|
||||
n = version_string.split('.')
|
||||
|
@ -598,112 +591,3 @@ def register_fonts(path=fontscollectionpath,valid_extensions=['.ttf','.otf','.tt
|
|||
# auto-register known plugins and fonts
|
||||
register_plugins()
|
||||
register_fonts()
|
||||
|
||||
# Explicitly export API members to avoid namespace pollution
|
||||
# and ensure correct documentation processing
|
||||
__all__ = [
|
||||
# classes
|
||||
'CharProperties',
|
||||
'Color',
|
||||
'Coord',
|
||||
'Palette',
|
||||
#'ColorBand',
|
||||
'CompositeOp',
|
||||
'DatasourceCache',
|
||||
'MemoryDatasource',
|
||||
'Box2d',
|
||||
'Feature',
|
||||
'Featureset',
|
||||
'FontEngine',
|
||||
'FontSet',
|
||||
'FormattingNode',
|
||||
'FormattingText',
|
||||
'FormattingFormat',
|
||||
'FormattingList',
|
||||
'FormattingExpressionFormat',
|
||||
'Geometry2d',
|
||||
'Image',
|
||||
'ImageView',
|
||||
'Grid',
|
||||
'GridView',
|
||||
'Layer',
|
||||
'Layers',
|
||||
'LinePatternSymbolizer',
|
||||
'LineSymbolizer',
|
||||
'Map',
|
||||
'MarkersSymbolizer',
|
||||
'Names',
|
||||
'Path',
|
||||
'Parameter',
|
||||
'Parameters',
|
||||
'PointSymbolizer',
|
||||
'PolygonPatternSymbolizer',
|
||||
'PolygonSymbolizer',
|
||||
'ProcessedText',
|
||||
'ProjTransform',
|
||||
'Projection',
|
||||
'Query',
|
||||
'RasterSymbolizer',
|
||||
'RasterColorizer',
|
||||
'Rule', 'Rules',
|
||||
'ShieldSymbolizer',
|
||||
'Singleton',
|
||||
'Stroke',
|
||||
'Style',
|
||||
'Symbolizer',
|
||||
'Symbolizers',
|
||||
'TextPlacements',
|
||||
'TextPlacementInfo',
|
||||
'TextSymbolizer',
|
||||
'TextSymbolizerProperties',
|
||||
'ViewTransform',
|
||||
# enums
|
||||
'aspect_fix_mode',
|
||||
'point_placement',
|
||||
'label_placement',
|
||||
'line_cap',
|
||||
'line_join',
|
||||
'text_transform',
|
||||
'vertical_alignment',
|
||||
'horizontal_alignment',
|
||||
'justify_alignment',
|
||||
'pattern_alignment',
|
||||
'filter_mode',
|
||||
# functions
|
||||
# datasources
|
||||
'Datasource',
|
||||
'CreateDatasource',
|
||||
'Shapefile',
|
||||
'PostGIS',
|
||||
'Raster',
|
||||
'Gdal',
|
||||
'Occi',
|
||||
'Ogr',
|
||||
'SQLite',
|
||||
'Osm',
|
||||
'Kismet',
|
||||
# version and environment
|
||||
'mapnik_version_string',
|
||||
'mapnik_version',
|
||||
'has_cairo',
|
||||
'has_pycairo',
|
||||
# factory methods
|
||||
'Expression',
|
||||
'PathExpression',
|
||||
# load/save/render
|
||||
'load_map',
|
||||
'load_map_from_string',
|
||||
'save_map',
|
||||
'save_map_to_string',
|
||||
'render',
|
||||
'render_grid',
|
||||
'render_tile_to_file',
|
||||
'render_to_file',
|
||||
# other
|
||||
'register_plugins',
|
||||
'register_fonts',
|
||||
'scale_denominator',
|
||||
# deprecated
|
||||
'Filter',
|
||||
'Envelope',
|
||||
]
|
||||
|
|
|
@ -43,7 +43,7 @@ except ImportError:
|
|||
|
||||
class centering:
|
||||
"""Style of centering to use with the map, the default is constrained
|
||||
|
||||
|
||||
none: map will be placed flush with the margin/box in the top left corner
|
||||
constrained: map will be centered on the most constrained axis (for a portrait page
|
||||
and a square map this will be horizontally)
|
||||
|
@ -167,7 +167,7 @@ def sequence_scale(scale,scale_sequence):
|
|||
"""Default scale helper, this rounds scale to a 'sensible' value"""
|
||||
factor = math.floor(math.log10(scale))
|
||||
norm = scale/(10**factor)
|
||||
|
||||
|
||||
for s in scale_sequence:
|
||||
if norm <= s:
|
||||
return s*10**factor
|
||||
|
@ -199,7 +199,7 @@ def deg_min_sec_scale(scale):
|
|||
return x
|
||||
else:
|
||||
return x
|
||||
|
||||
|
||||
def format_deg_min_sec(value):
|
||||
deg = math.floor(value)
|
||||
min = math.floor((value-deg)/(1.0/60))
|
||||
|
@ -219,12 +219,12 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
opens the given multipage PDF and converts each page to be a layer in a single page PDF
|
||||
layer_names should be a sequence of the user visible names of the layers, if not given
|
||||
or if shorter than num pages generic names will be given to the unnamed layers
|
||||
|
||||
|
||||
if output_name is not provided a temporary file will be used for the conversion which
|
||||
will then be copied back over the source file.
|
||||
|
||||
|
||||
requires pyPdf >= 1.13 to be available"""
|
||||
|
||||
|
||||
|
||||
if not HAS_PYPDF:
|
||||
raise Exception("pyPdf Not available")
|
||||
|
@ -235,13 +235,13 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
else:
|
||||
(outfd,outfilename) = tempfile.mkstemp(dir=os.path.dirname(filename))
|
||||
outfile = os.fdopen(outfd,'wb')
|
||||
|
||||
|
||||
i = pyPdf.PdfFileReader(infile)
|
||||
o = pyPdf.PdfFileWriter()
|
||||
|
||||
|
||||
template_page_size = i.pages[0].mediaBox
|
||||
op = o.addBlankPage(width=template_page_size.getWidth(),height=template_page_size.getHeight())
|
||||
|
||||
|
||||
contentkey = pyPdf.generic.NameObject('/Contents')
|
||||
resourcekey = pyPdf.generic.NameObject('/Resources')
|
||||
propertieskey = pyPdf.generic.NameObject('/Properties')
|
||||
|
@ -249,7 +249,7 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
op[resourcekey] = pyPdf.generic.DictionaryObject()
|
||||
properties = pyPdf.generic.DictionaryObject()
|
||||
ocgs = pyPdf.generic.ArrayObject()
|
||||
|
||||
|
||||
for (i, p) in enumerate(i.pages):
|
||||
# first start an OCG for the layer
|
||||
ocgname = pyPdf.generic.NameObject('/oc%d' % i)
|
||||
|
@ -262,9 +262,9 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
p[pyPdf.generic.NameObject('/Contents')].append(ocgend)
|
||||
else:
|
||||
p[pyPdf.generic.NameObject('/Contents')] = pyPdf.generic.ArrayObject((ocgstart,p['/Contents'],ocgend))
|
||||
|
||||
|
||||
op.mergePage(p)
|
||||
|
||||
|
||||
ocg = pyPdf.generic.DictionaryObject()
|
||||
ocg[pyPdf.generic.NameObject('/Type')] = pyPdf.generic.NameObject('/OCG')
|
||||
if len(layer_names) > i:
|
||||
|
@ -274,9 +274,9 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
indirect_ocg = o._addObject(ocg)
|
||||
properties[ocgname] = indirect_ocg
|
||||
ocgs.append(indirect_ocg)
|
||||
|
||||
|
||||
op[resourcekey][propertieskey] = o._addObject(properties)
|
||||
|
||||
|
||||
ocproperties = pyPdf.generic.DictionaryObject()
|
||||
ocproperties[pyPdf.generic.NameObject('/OCGs')] = ocgs
|
||||
defaultview = pyPdf.generic.DictionaryObject()
|
||||
|
@ -289,16 +289,16 @@ def convert_pdf_pages_to_layers(filename,output_name=None,layer_names=(),reverse
|
|||
else:
|
||||
defaultview[pyPdf.generic.NameObject('/Order')] = pyPdf.generic.ArrayObject(reversed(ocgs))
|
||||
defaultview[pyPdf.generic.NameObject('/OFF')] = pyPdf.generic.ArrayObject()
|
||||
|
||||
|
||||
ocproperties[pyPdf.generic.NameObject('/D')] = o._addObject(defaultview)
|
||||
|
||||
|
||||
o._root.getObject()[pyPdf.generic.NameObject('/OCProperties')] = o._addObject(ocproperties)
|
||||
|
||||
|
||||
o.write(outfile)
|
||||
|
||||
|
||||
outfile.close()
|
||||
infile.close()
|
||||
|
||||
|
||||
if not output_name:
|
||||
os.rename(outfilename, filename)
|
||||
|
||||
|
@ -318,7 +318,7 @@ class PDFPrinter:
|
|||
is_latlon=False,
|
||||
use_ocg_layers=False):
|
||||
"""Creates a cairo surface and context to render a PDF with.
|
||||
|
||||
|
||||
pagesize: tuple of page size in meters, see predefined sizes in pagessizes dict (default a4)
|
||||
margin: page margin in meters (default 0.01)
|
||||
box: box within the page to render the map into (will not render over margin). This should be
|
||||
|
@ -348,54 +348,54 @@ class PDFPrinter:
|
|||
self._centering = centering
|
||||
self._is_latlon = is_latlon
|
||||
self._use_ocg_layers = use_ocg_layers
|
||||
|
||||
|
||||
self._s = None
|
||||
self._layer_names = []
|
||||
self._filename = None
|
||||
|
||||
|
||||
self.map_box = None
|
||||
self.scale = None
|
||||
|
||||
|
||||
# don't both to round the scale if they are not preserving the aspect ratio
|
||||
if not preserve_aspect:
|
||||
self._scale = any_scale
|
||||
|
||||
|
||||
if percent_box:
|
||||
self._box = Box2d(percent_box[0]*pagesize[0],percent_box[1]*pagesize[1],
|
||||
percent_box[2]*pagesize[0],percent_box[3]*pagesize[1])
|
||||
|
||||
if not HAS_PYCAIRO_MODULE:
|
||||
raise Exception("PDF rendering only available when pycairo is available")
|
||||
|
||||
|
||||
self.font_name = "DejaVu Sans"
|
||||
|
||||
|
||||
def finish(self):
|
||||
if self._s:
|
||||
self._s.finish()
|
||||
self._s = None
|
||||
|
||||
|
||||
if self._use_ocg_layers:
|
||||
convert_pdf_pages_to_layers(self._filename,layer_names=self._layer_names + ["Legend and Information"],reverse_all_but_last=True)
|
||||
|
||||
|
||||
def add_geospatial_pdf_header(self,m,filename,epsg=None,wkt=None):
|
||||
""" Postprocessing step to add geospatial PDF information to PDF file as per
|
||||
PDF standard 1.7 extension level 3 (also in draft PDF v2 standard at time of writing)
|
||||
|
||||
|
||||
one of either the epsg code or wkt text for the projection must be provided
|
||||
|
||||
|
||||
Should be called *after* the page has had .finish() called"""
|
||||
if HAS_PYPDF and (epsg or wkt):
|
||||
infile=file(filename,'rb')
|
||||
(outfd,outfilename) = tempfile.mkstemp(dir=os.path.dirname(filename))
|
||||
outfile = os.fdopen(outfd,'wb')
|
||||
|
||||
|
||||
i=pyPdf.PdfFileReader(infile)
|
||||
o=pyPdf.PdfFileWriter()
|
||||
|
||||
|
||||
# preserve OCProperties at document root if we have one
|
||||
if i.trailer['/Root'].has_key(pyPdf.generic.NameObject('/OCProperties')):
|
||||
o._root.getObject()[pyPdf.generic.NameObject('/OCProperties')] = i.trailer['/Root'].getObject()[pyPdf.generic.NameObject('/OCProperties')]
|
||||
|
||||
|
||||
for p in i.pages:
|
||||
gcs = pyPdf.generic.DictionaryObject()
|
||||
gcs[pyPdf.generic.NameObject('/Type')]=pyPdf.generic.NameObject('/PROJCS')
|
||||
|
@ -403,7 +403,7 @@ class PDFPrinter:
|
|||
gcs[pyPdf.generic.NameObject('/EPSG')]=pyPdf.generic.NumberObject(int(epsg))
|
||||
if wkt:
|
||||
gcs[pyPdf.generic.NameObject('/WKT')]=pyPdf.generic.TextStringObject(wkt)
|
||||
|
||||
|
||||
measure = pyPdf.generic.DictionaryObject()
|
||||
measure[pyPdf.generic.NameObject('/Type')]=pyPdf.generic.NameObject('/Measure')
|
||||
measure[pyPdf.generic.NameObject('/Subtype')]=pyPdf.generic.NameObject('/GEO')
|
||||
|
@ -414,7 +414,7 @@ class PDFPrinter:
|
|||
measure[pyPdf.generic.NameObject('/Bounds')]=bounds
|
||||
measure[pyPdf.generic.NameObject('/LPTS')]=bounds
|
||||
gpts=pyPdf.generic.ArrayObject()
|
||||
|
||||
|
||||
proj=Projection(m.srs)
|
||||
env=m.envelope()
|
||||
for x in ((env.minx, env.miny), (env.minx, env.maxy), (env.maxx, env.maxy), (env.maxx, env.miny)):
|
||||
|
@ -423,31 +423,31 @@ class PDFPrinter:
|
|||
gpts.append(pyPdf.generic.FloatObject(str(latlon_corner.y)))
|
||||
gpts.append(pyPdf.generic.FloatObject(str(latlon_corner.x)))
|
||||
measure[pyPdf.generic.NameObject('/GPTS')]=gpts
|
||||
|
||||
|
||||
vp=pyPdf.generic.DictionaryObject()
|
||||
vp[pyPdf.generic.NameObject('/Type')]=pyPdf.generic.NameObject('/Viewport')
|
||||
bbox=pyPdf.generic.ArrayObject()
|
||||
|
||||
|
||||
for x in self.map_box:
|
||||
bbox.append(pyPdf.generic.FloatObject(str(x)))
|
||||
vp[pyPdf.generic.NameObject('/BBox')]=bbox
|
||||
vp[pyPdf.generic.NameObject('/Measure')]=measure
|
||||
|
||||
|
||||
vpa = pyPdf.generic.ArrayObject()
|
||||
vpa.append(vp)
|
||||
p[pyPdf.generic.NameObject('/VP')]=vpa
|
||||
o.addPage(p)
|
||||
|
||||
|
||||
o.write(outfile)
|
||||
infile=None
|
||||
outfile.close()
|
||||
os.rename(outfilename,filename)
|
||||
|
||||
|
||||
|
||||
|
||||
def get_context(self):
|
||||
"""allow access so that extra 'bits' can be rendered to the page directly"""
|
||||
return cairo.Context(self._s)
|
||||
|
||||
|
||||
def get_width(self):
|
||||
return self._pagesize[0]
|
||||
|
||||
|
@ -456,7 +456,7 @@ class PDFPrinter:
|
|||
|
||||
def get_margin(self):
|
||||
return self._margin
|
||||
|
||||
|
||||
def write_text(self,ctx,text,box_width=None,size=10, fill_color=(0.0, 0.0, 0.0), alignment=None):
|
||||
if HAS_PANGOCAIRO_MODULE:
|
||||
(attr,t,accel) = pango.parse_markup(text)
|
||||
|
@ -474,7 +474,7 @@ class PDFPrinter:
|
|||
pctx.set_source_rgb(*fill_color)
|
||||
pctx.show_layout(l)
|
||||
return l.get_pixel_extents()[0]
|
||||
|
||||
|
||||
else:
|
||||
ctx.rel_move_to(0,size)
|
||||
ctx.select_font_face(self.font_name, cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
|
@ -489,18 +489,18 @@ class PDFPrinter:
|
|||
elif HAS_PYCAIRO_MODULE:
|
||||
return cairo.Context(self._s)
|
||||
return None
|
||||
|
||||
|
||||
def _get_render_area(self):
|
||||
"""return a bounding box with the area of the page we are allowed to render out map to
|
||||
in page coordinates (i.e. meters)
|
||||
"""
|
||||
# take off our page margins
|
||||
render_area = Box2d(self._margin,self._margin,self._pagesize[0]-self._margin,self._pagesize[1]-self._margin)
|
||||
|
||||
|
||||
#then if user specified a box to render get intersection with that
|
||||
if self._box:
|
||||
return render_area.intersect(self._box)
|
||||
|
||||
|
||||
return render_area
|
||||
|
||||
def _get_render_area_size(self):
|
||||
|
@ -513,7 +513,7 @@ class PDFPrinter:
|
|||
available_area = self._get_render_area_size()
|
||||
map_aspect = m.envelope().width()/m.envelope().height()
|
||||
page_aspect = available_area[0]/available_area[1]
|
||||
|
||||
|
||||
return map_aspect > page_aspect
|
||||
|
||||
def _get_meta_info_corner(self,render_size,m):
|
||||
|
@ -526,7 +526,7 @@ class PDFPrinter:
|
|||
else:
|
||||
x += render_size[0]+0.005
|
||||
y = self._margin
|
||||
|
||||
|
||||
return (x,y)
|
||||
|
||||
def _get_render_corner(self,render_size,m):
|
||||
|
@ -535,9 +535,9 @@ class PDFPrinter:
|
|||
|
||||
x=available_area[0]
|
||||
y=available_area[1]
|
||||
|
||||
|
||||
h_is_contrained = self._is_h_contrained(m)
|
||||
|
||||
|
||||
if (self._centering == centering.both or
|
||||
self._centering == centering.horizontal or
|
||||
(self._centering == centering.constrained and h_is_contrained) or
|
||||
|
@ -550,26 +550,26 @@ class PDFPrinter:
|
|||
(self._centering == centering.unconstrained and h_is_contrained)):
|
||||
y+=(available_area.height()-render_size[1])/2
|
||||
return (x,y)
|
||||
|
||||
|
||||
def _get_map_pixel_size(self, width_page_m, height_page_m):
|
||||
"""for a given map size in paper coordinates return a tuple of the map 'pixel' size we
|
||||
should create at the defined resolution"""
|
||||
return (int(m2px(width_page_m,self._resolution)), int(m2px(height_page_m,self._resolution)))
|
||||
|
||||
|
||||
def render_map(self,m, filename):
|
||||
"""Render the given map to filename"""
|
||||
|
||||
|
||||
# store this for later so we can post process the PDF
|
||||
self._filename = filename
|
||||
|
||||
|
||||
# work out the best scale to render out map at given the available space
|
||||
(eff_width,eff_height) = self._get_render_area_size()
|
||||
map_aspect = m.envelope().width()/m.envelope().height()
|
||||
page_aspect = eff_width/eff_height
|
||||
|
||||
|
||||
scalex=m.envelope().width()/eff_width
|
||||
scaley=m.envelope().height()/eff_height
|
||||
|
||||
|
||||
scale=max(scalex,scaley)
|
||||
|
||||
rounded_mapscale=self._scale(scale)
|
||||
|
@ -581,26 +581,26 @@ class PDFPrinter:
|
|||
maph=mapw*(1/map_aspect)
|
||||
else:
|
||||
mapw=maph*map_aspect
|
||||
|
||||
|
||||
# set the map size so that raster elements render at the correct resolution
|
||||
m.resize(*self._get_map_pixel_size(mapw,maph))
|
||||
# calculate the translation for the map starting point
|
||||
(tx,ty) = self._get_render_corner((mapw,maph),m)
|
||||
|
||||
|
||||
# create our cairo surface and context and then render the map into it
|
||||
self._s = cairo.PDFSurface(filename, m2pt(self._pagesize[0]),m2pt(self._pagesize[1]))
|
||||
ctx=cairo.Context(self._s)
|
||||
|
||||
|
||||
for l in m.layers:
|
||||
# extract the layer names for naming layers if we use OCG
|
||||
self._layer_names.append(l.name)
|
||||
|
||||
|
||||
layer_map = Map(m.width,m.height,m.srs)
|
||||
layer_map.layers.append(l)
|
||||
for s in l.styles:
|
||||
layer_map.append_style(s,m.find_style(s))
|
||||
layer_map.zoom_to_box(m.envelope())
|
||||
|
||||
|
||||
def render_map():
|
||||
ctx.save()
|
||||
ctx.translate(m2pt(tx),m2pt(ty))
|
||||
|
@ -608,7 +608,7 @@ class PDFPrinter:
|
|||
ctx.scale(72.0/self._resolution,72.0/self._resolution)
|
||||
render(layer_map, ctx)
|
||||
ctx.restore()
|
||||
|
||||
|
||||
# antimeridian
|
||||
render_map()
|
||||
if self._is_latlon and (m.envelope().minx < -180 or m.envelope().maxx > 180):
|
||||
|
@ -621,10 +621,10 @@ class PDFPrinter:
|
|||
render_map()
|
||||
# restore the original env
|
||||
m.zoom_to_box(old_env)
|
||||
|
||||
|
||||
if self._use_ocg_layers:
|
||||
self._s.show_page()
|
||||
|
||||
|
||||
self.scale = rounded_mapscale
|
||||
self.map_box = Box2d(tx,ty,tx+mapw,ty+maph)
|
||||
|
||||
|
@ -640,7 +640,7 @@ class PDFPrinter:
|
|||
|
||||
if p2.inverse(m.envelope().center()).y > latlon_bounds.maxy:
|
||||
latlon_bounds = Box2d(latlon_bounds.miny,latlon_bounds.maxy,latlon_bounds.maxx,latlon_bounds.miny+360)
|
||||
|
||||
|
||||
latlon_mapwidth = latlon_bounds.width()
|
||||
# render an extra 20% so we generally won't miss the ends of lines
|
||||
latlon_buffer = 0.2*latlon_mapwidth
|
||||
|
@ -649,7 +649,7 @@ class PDFPrinter:
|
|||
else:
|
||||
latlon_divsize = deg_min_sec_scale(latlon_mapwidth/7.0)
|
||||
latlon_interpsize = latlon_mapwidth/m.width
|
||||
|
||||
|
||||
self._render_lat_lon_axis(m,p2,latlon_bounds.minx,latlon_bounds.maxx,latlon_bounds.miny,latlon_bounds.maxy,latlon_buffer,latlon_interpsize,latlon_divsize,dec_degrees,True)
|
||||
self._render_lat_lon_axis(m,p2,latlon_bounds.miny,latlon_bounds.maxy,latlon_bounds.minx,latlon_bounds.maxx,latlon_buffer,latlon_interpsize,latlon_divsize,dec_degrees,False)
|
||||
|
||||
|
@ -658,21 +658,21 @@ class PDFPrinter:
|
|||
ctx.set_source_rgb(1,0,0)
|
||||
ctx.set_line_width(1)
|
||||
latlon_labelsize = 6
|
||||
|
||||
|
||||
ctx.translate(m2pt(self.map_box.minx),m2pt(self.map_box.miny))
|
||||
ctx.rectangle(0,0,m2pt(self.map_box.width()),m2pt(self.map_box.height()))
|
||||
ctx.clip()
|
||||
|
||||
|
||||
ctx.select_font_face("DejaVu", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
ctx.set_font_size(latlon_labelsize)
|
||||
|
||||
|
||||
box_top = self.map_box.height()
|
||||
if not is_x_axis:
|
||||
ctx.translate(m2pt(self.map_box.width()/2),m2pt(self.map_box.height()/2))
|
||||
ctx.rotate(-math.pi/2)
|
||||
ctx.translate(-m2pt(self.map_box.height()/2),-m2pt(self.map_box.width()/2))
|
||||
box_top = self.map_box.width()
|
||||
|
||||
|
||||
for xvalue in round_grid_generator(x1 - latlon_buffer,x2 + latlon_buffer,latlon_divsize):
|
||||
yvalue = y1 - latlon_buffer
|
||||
start_cross = None
|
||||
|
@ -693,12 +693,12 @@ class PDFPrinter:
|
|||
ctx.move_to(start.x,start.y)
|
||||
ctx.line_to(end.x,end.y)
|
||||
ctx.stroke()
|
||||
|
||||
|
||||
if cmp(start.y, 0) != cmp(end.y,0):
|
||||
start_cross = end.x
|
||||
if cmp(start.y,m2pt(self.map_box.height())) != cmp(end.y, m2pt(self.map_box.height())):
|
||||
end_cross = end.x
|
||||
|
||||
|
||||
if dec_degrees:
|
||||
line_text = "%g" % (xvalue)
|
||||
else:
|
||||
|
@ -712,19 +712,19 @@ class PDFPrinter:
|
|||
|
||||
def render_on_map_scale(self,m):
|
||||
(div_size,page_div_size) = self._get_sensible_scalebar_size(m)
|
||||
|
||||
|
||||
first_value_x = (math.floor(m.envelope().minx / div_size) + 1) * div_size
|
||||
first_value_x_percent = (first_value_x-m.envelope().minx)/m.envelope().width()
|
||||
self._render_scale_axis(first_value_x,first_value_x_percent,self.map_box.minx,self.map_box.maxx,page_div_size,div_size,self.map_box.miny,self.map_box.maxy,True)
|
||||
|
||||
|
||||
first_value_y = (math.floor(m.envelope().miny / div_size) + 1) * div_size
|
||||
first_value_y_percent = (first_value_y-m.envelope().miny)/m.envelope().height()
|
||||
self._render_scale_axis(first_value_y,first_value_y_percent,self.map_box.miny,self.map_box.maxy,page_div_size,div_size,self.map_box.minx,self.map_box.maxx,False)
|
||||
|
||||
|
||||
if self._use_ocg_layers:
|
||||
self._s.show_page()
|
||||
self._layer_names.append("Coordinate Grid Overlay")
|
||||
|
||||
|
||||
def _get_sensible_scalebar_size(self,m,width=-1):
|
||||
# aim for about 8 divisions across the map
|
||||
# also make sure we can fit the bar with in page area width if specified
|
||||
|
@ -744,7 +744,7 @@ class PDFPrinter:
|
|||
ctx.set_source_rgb(*stroke_color)
|
||||
ctx.rectangle(x,y,w,h)
|
||||
ctx.stroke()
|
||||
|
||||
|
||||
if text:
|
||||
ctx.move_to(x+1,y)
|
||||
self.write_text(ctx,text,fill_color=[1-z for z in fill_color],size=h-2)
|
||||
|
@ -758,14 +758,14 @@ class PDFPrinter:
|
|||
label_value = first-div_size
|
||||
if self._is_latlon and label_value < -180:
|
||||
label_value += 360
|
||||
|
||||
|
||||
ctx=cairo.Context(self._s)
|
||||
|
||||
|
||||
if not is_x_axis:
|
||||
ctx.translate(m2pt(self.map_box.center().x),m2pt(self.map_box.center().y))
|
||||
ctx.rotate(-math.pi/2)
|
||||
ctx.translate(-m2pt(self.map_box.center().y),-m2pt(self.map_box.center().x))
|
||||
|
||||
|
||||
while value < end:
|
||||
ctx.move_to(m2pt(value),m2pt(boundary_start))
|
||||
ctx.line_to(m2pt(value),m2pt(boundary_end))
|
||||
|
@ -775,7 +775,7 @@ class PDFPrinter:
|
|||
|
||||
for bar in (m2pt(boundary_start)-border_size,m2pt(boundary_end)):
|
||||
self._render_box(ctx,m2pt(prev),bar,m2pt(value-prev),border_size,text,fill_color=fill)
|
||||
|
||||
|
||||
prev = value
|
||||
value+=page_div_size
|
||||
fill = [1-z for z in fill]
|
||||
|
@ -787,18 +787,18 @@ class PDFPrinter:
|
|||
for bar in (m2pt(boundary_start)-border_size,m2pt(boundary_end)):
|
||||
self._render_box(ctx,m2pt(prev),bar,m2pt(end-prev),border_size,fill_color=fill)
|
||||
|
||||
|
||||
|
||||
def render_scale(self,m,ctx=None,width=0.05):
|
||||
""" m: map to render scale for
|
||||
ctx: A cairo context to render the scale to. If this is None (the default) then
|
||||
automatically create a context and choose the best location for the scale bar.
|
||||
width: Width of area available to render scale bar in (in m)
|
||||
|
||||
|
||||
will return the size of the rendered scale block in pts
|
||||
"""
|
||||
|
||||
|
||||
(w,h) = (0,0)
|
||||
|
||||
|
||||
# don't render scale if we are lat lon
|
||||
# dont report scale if we have warped the aspect ratio
|
||||
if self._preserve_aspect and not self._is_latlon:
|
||||
|
@ -808,15 +808,15 @@ class PDFPrinter:
|
|||
ctx=cairo.Context(self._s)
|
||||
(tx,ty) = self._get_meta_info_corner((self.map_box.width(),self.map_box.height()),m)
|
||||
ctx.translate(tx,ty)
|
||||
|
||||
|
||||
(div_size,page_div_size) = self._get_sensible_scalebar_size(m, width/box_count)
|
||||
|
||||
|
||||
|
||||
div_unit = "m"
|
||||
if div_size > 1000:
|
||||
div_size /= 1000
|
||||
div_unit = "km"
|
||||
|
||||
|
||||
text = "0%s" % div_unit
|
||||
ctx.save()
|
||||
if width > 0:
|
||||
|
@ -846,7 +846,7 @@ class PDFPrinter:
|
|||
|
||||
text_ext=self.write_text(ctx,"Scale 1:%d" % self.scale,box_width=box_width,size=font_size, alignment=alignment)
|
||||
h+=text_ext[3]+2
|
||||
|
||||
|
||||
return (w,h)
|
||||
|
||||
def render_legend(self,m, page_break=False, ctx=None, collumns=1,width=None, height=None, item_per_rule=False, attribution={}, legend_item_box_size=(0.015,0.0075)):
|
||||
|
@ -858,7 +858,7 @@ class PDFPrinter:
|
|||
collumns: number of collumns available in legend box
|
||||
attribution: additional text that will be rendered in gray under the layer name. keyed by layer name
|
||||
legend_item_box_size: two tuple with width and height of legend item box size in meters
|
||||
|
||||
|
||||
will return the size of the rendered block in pts
|
||||
"""
|
||||
|
||||
|
@ -879,7 +879,7 @@ class PDFPrinter:
|
|||
else:
|
||||
cwidth = None
|
||||
current_collumn = 0
|
||||
|
||||
|
||||
processed_layers = []
|
||||
for l in reversed(m.layers):
|
||||
have_layer_header = False
|
||||
|
@ -888,7 +888,7 @@ class PDFPrinter:
|
|||
if layer_title in processed_layers:
|
||||
continue
|
||||
processed_layers.append(layer_title)
|
||||
|
||||
|
||||
# check through the features to find which combinations of styles are active
|
||||
# for each unique combination add a legend entry
|
||||
for f in l.datasource.all_features():
|
||||
|
@ -913,20 +913,20 @@ class PDFPrinter:
|
|||
active_rules = tuple(active_rules)
|
||||
if added_styles.has_key(active_rules):
|
||||
continue
|
||||
|
||||
|
||||
added_styles[active_rules] = (f,rule_text)
|
||||
if not item_per_rule:
|
||||
break
|
||||
else:
|
||||
added_styles[l] = (None,None)
|
||||
|
||||
|
||||
legend_items = added_styles.keys()
|
||||
legend_items.sort()
|
||||
for li in legend_items:
|
||||
if True:
|
||||
(f,rule_text) = added_styles[li]
|
||||
|
||||
|
||||
|
||||
|
||||
legend_map_size = (int(m2pt(legend_item_box_size[0])),int(m2pt(legend_item_box_size[1])))
|
||||
lemap=Map(legend_map_size[0],legend_map_size[1],srs=m.srs)
|
||||
if m.background:
|
||||
|
@ -967,11 +967,11 @@ class PDFPrinter:
|
|||
for s in l.styles:
|
||||
lelayer.styles.append(s)
|
||||
lemap.layers.append(lelayer)
|
||||
|
||||
|
||||
if f is None or f.envelope().width() != 0:
|
||||
lemap.zoom_all()
|
||||
lemap.zoom(1.1)
|
||||
|
||||
|
||||
item_size = legend_map_size[1]
|
||||
if not have_layer_header:
|
||||
item_size += 8
|
||||
|
@ -998,7 +998,7 @@ class PDFPrinter:
|
|||
ctx.save()
|
||||
render(lemap, ctx)
|
||||
ctx.restore()
|
||||
|
||||
|
||||
ctx.rectangle(0,0,*legend_map_size)
|
||||
ctx.set_source_rgb(0.5,0.5,0.5)
|
||||
ctx.set_line_width(1)
|
||||
|
@ -1017,12 +1017,12 @@ class PDFPrinter:
|
|||
if attribution.has_key(layer_title):
|
||||
e=self.write_text(ctx, attribution[layer_title], m2pt(cwidth-legend_item_box_size[0]-0.005), 6, fill_color=(0.5,0.5,0.5))
|
||||
legend_text_size += e[3]
|
||||
|
||||
|
||||
if legend_text_size > legend_entry_size:
|
||||
legend_entry_size=legend_text_size
|
||||
|
||||
|
||||
y+=legend_entry_size +2
|
||||
if y > h:
|
||||
h = y
|
||||
return (w,h)
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ void export_font_engine()
|
|||
.def("register_fonts",&freetype_engine::register_fonts)
|
||||
.def("face_names",&freetype_engine::face_names)
|
||||
.staticmethod("register_font")
|
||||
.staticmethod("register_fonts")
|
||||
.staticmethod("face_names")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ bool painted(mapnik::image_32 const& im)
|
|||
void set_pixel(mapnik::image_32 & im, unsigned x, unsigned y, mapnik::color const& c)
|
||||
{
|
||||
im.setPixel(x, y, c.rgba());
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<image_32> open_from_file(std::string const& filename)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
|
|||
{
|
||||
s.append(style_names[i]);
|
||||
}
|
||||
return boost::python::make_tuple(l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
|
||||
return boost::python::make_tuple(l.clear_label_cache(),l.min_zoom(),l.max_zoom(),l.queryable(),l.datasource()->params(),l.cache_features(),s);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -72,11 +72,11 @@ struct layer_pickle_suite : boost::python::pickle_suite
|
|||
|
||||
l.set_clear_label_cache(extract<bool>(state[0]));
|
||||
|
||||
l.setMinZoom(extract<double>(state[1]));
|
||||
l.set_min_zoom(extract<double>(state[1]));
|
||||
|
||||
l.setMaxZoom(extract<double>(state[2]));
|
||||
l.set_max_zoom(extract<double>(state[2]));
|
||||
|
||||
l.setQueryable(extract<bool>(state[3]));
|
||||
l.set_queryable(extract<bool>(state[3]));
|
||||
|
||||
mapnik::parameters params = extract<parameters>(state[4]);
|
||||
l.set_datasource(datasource_cache::instance()->create(params));
|
||||
|
@ -128,7 +128,7 @@ void export_layer()
|
|||
"box2d(-1.0,-1.0,0.0,0.0) # default until a datasource is loaded\n"
|
||||
)
|
||||
|
||||
.def("visible", &layer::isVisible,
|
||||
.def("visible", &layer::visible,
|
||||
"Return True if this layer's data is active and visible at a given scale.\n"
|
||||
"\n"
|
||||
"Otherwise returns False.\n"
|
||||
|
@ -149,8 +149,8 @@ void export_layer()
|
|||
)
|
||||
|
||||
.add_property("active",
|
||||
&layer::isActive,
|
||||
&layer::setActive,
|
||||
&layer::active,
|
||||
&layer::set_active,
|
||||
"Get/Set whether this layer is active and will be rendered.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
|
@ -199,8 +199,8 @@ void export_layer()
|
|||
)
|
||||
|
||||
.add_property("maxzoom",
|
||||
&layer::getMaxZoom,
|
||||
&layer::setMaxZoom,
|
||||
&layer::max_zoom,
|
||||
&layer::set_max_zoom,
|
||||
"Get/Set the maximum zoom lever of the layer.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
|
@ -214,8 +214,8 @@ void export_layer()
|
|||
)
|
||||
|
||||
.add_property("minzoom",
|
||||
&layer::getMinZoom,
|
||||
&layer::setMinZoom,
|
||||
&layer::min_zoom,
|
||||
&layer::set_min_zoom,
|
||||
"Get/Set the minimum zoom lever of the layer.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
|
@ -244,8 +244,8 @@ void export_layer()
|
|||
)
|
||||
|
||||
.add_property("queryable",
|
||||
&layer::isQueryable,
|
||||
&layer::setQueryable,
|
||||
&layer::queryable,
|
||||
&layer::set_queryable,
|
||||
"Get/Set whether this layer is queryable.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
|
|
|
@ -62,5 +62,9 @@ void export_line_symbolizer()
|
|||
(&line_symbolizer::get_stroke,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&line_symbolizer::set_stroke)
|
||||
.add_property("smooth",
|
||||
&line_symbolizer::smooth,
|
||||
&line_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -117,11 +117,8 @@ struct map_pickle_suite : boost::python::pickle_suite
|
|||
|
||||
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
||||
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
||||
|
||||
mapnik::parameters& (Map::*attr_nonconst)() = &Map::get_extra_attributes;
|
||||
mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters;
|
||||
|
||||
|
||||
mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name)
|
||||
{
|
||||
boost::optional<mapnik::feature_type_style const&> style = m.find_style(name);
|
||||
|
@ -482,7 +479,6 @@ void export_map()
|
|||
)
|
||||
|
||||
.def("__deepcopy__",&map_deepcopy)
|
||||
.add_property("extra_attributes",make_function(attr_nonconst,return_value_policy<reference_existing_object>()),"TODO")
|
||||
.add_property("parameters",make_function(params_nonconst,return_value_policy<reference_existing_object>()),"TODO")
|
||||
|
||||
.add_property("aspect_fix_mode",
|
||||
|
|
|
@ -60,7 +60,8 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
static boost::python::tuple
|
||||
getstate(markers_symbolizer const& p)
|
||||
{
|
||||
return boost::python::make_tuple(p.get_allow_overlap());//,p.get_opacity());
|
||||
return boost::python::make_tuple(p.get_allow_overlap(),
|
||||
p.get_ignore_placement());//,p.get_opacity());
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -77,7 +78,8 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
}
|
||||
|
||||
p.set_allow_overlap(extract<bool>(state[0]));
|
||||
//p.set_opacity(extract<float>(state[1]));
|
||||
p.set_ignore_placement(extract<bool>(state[1]));
|
||||
//p.set_opacity(extract<float>(state[2]));
|
||||
|
||||
}
|
||||
|
||||
|
@ -108,8 +110,19 @@ void export_markers_symbolizer()
|
|||
&markers_symbolizer::get_opacity,
|
||||
&markers_symbolizer::set_opacity,
|
||||
"Set/get the text opacity")
|
||||
.add_property("ignore_placement",
|
||||
&markers_symbolizer::get_ignore_placement,
|
||||
&markers_symbolizer::set_ignore_placement)
|
||||
.add_property("transform",
|
||||
&mapnik::get_svg_transform<markers_symbolizer>,
|
||||
&mapnik::set_svg_transform<markers_symbolizer>)
|
||||
.add_property("width",
|
||||
&markers_symbolizer::get_width,
|
||||
&markers_symbolizer::set_width,
|
||||
"Set/get the marker width")
|
||||
.add_property("height",
|
||||
&markers_symbolizer::get_height,
|
||||
&markers_symbolizer::set_height,
|
||||
"Set/get the marker height")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,11 @@ void export_polygon_symbolizer()
|
|||
.add_property("gamma_method",
|
||||
&polygon_symbolizer::get_gamma_method,
|
||||
&polygon_symbolizer::set_gamma_method,
|
||||
"Set/get the gamma correction method of the polygon")
|
||||
"gamma correction method")
|
||||
.add_property("smooth",
|
||||
&polygon_symbolizer::smooth,
|
||||
&polygon_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -279,6 +279,11 @@ unsigned mapnik_version()
|
|||
return MAPNIK_VERSION;
|
||||
}
|
||||
|
||||
std::string mapnik_version_string()
|
||||
{
|
||||
return MAPNIK_VERSION_STRING;
|
||||
}
|
||||
|
||||
// indicator for jpeg read/write support within libmapnik
|
||||
bool has_jpeg()
|
||||
{
|
||||
|
@ -573,6 +578,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
|
||||
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
|
||||
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
|
||||
def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string");
|
||||
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
|
||||
def("has_cairo", &has_cairo, "Get cairo library status");
|
||||
def("has_pycairo", &has_pycairo, "Get pycairo module status");
|
||||
|
|
|
@ -40,15 +40,15 @@
|
|||
using namespace mapnik;
|
||||
|
||||
/* Notes:
|
||||
Overriding functions in inherited classes:
|
||||
boost.python documentation doesn't really tell you how to do it.
|
||||
But this helps:
|
||||
http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
|
||||
Overriding functions in inherited classes:
|
||||
boost.python documentation doesn't really tell you how to do it.
|
||||
But this helps:
|
||||
http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
|
||||
|
||||
register_ptr_to_python is required for wrapped classes, but not for unwrapped.
|
||||
register_ptr_to_python is required for wrapped classes, but not for unwrapped.
|
||||
|
||||
Functions don't have to be members of the class, but can also be
|
||||
normal functions taking a ref to the class as first parameter.
|
||||
Functions don't have to be members of the class, but can also be
|
||||
normal functions taking a ref to the class as first parameter.
|
||||
*/
|
||||
|
||||
namespace {
|
||||
|
@ -261,7 +261,7 @@ struct TextPlacementsWrap: text_placements, wrapper<text_placements>
|
|||
struct TextPlacementInfoWrap: text_placement_info, wrapper<text_placement_info>
|
||||
{
|
||||
TextPlacementInfoWrap(text_placements const* parent,
|
||||
double scale_factor_)
|
||||
double scale_factor_)
|
||||
: text_placement_info(parent, scale_factor_)
|
||||
{
|
||||
|
||||
|
@ -329,6 +329,7 @@ void export_text_placement()
|
|||
.value("LEFT",J_LEFT)
|
||||
.value("MIDDLE",J_MIDDLE)
|
||||
.value("RIGHT",J_RIGHT)
|
||||
.value("AUTO", J_AUTO)
|
||||
;
|
||||
|
||||
enumeration_<text_transform_e>("text_transform")
|
||||
|
@ -339,7 +340,7 @@ void export_text_placement()
|
|||
;
|
||||
|
||||
class_<text_symbolizer>("TextSymbolizer",
|
||||
init<>())
|
||||
init<>())
|
||||
.def(init<expression_ptr, std::string const&, unsigned, color const&>())
|
||||
.add_property("placements",
|
||||
&text_symbolizer::get_placement_options,
|
||||
|
@ -357,7 +358,7 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_with_converter<text_symbolizer_properties>
|
||||
("TextSymbolizerProperties")
|
||||
("TextSymbolizerProperties")
|
||||
.def_readwrite_convert("label_placement", &text_symbolizer_properties::label_placement)
|
||||
.def_readwrite_convert("horizontal_alignment", &text_symbolizer_properties::halign)
|
||||
.def_readwrite_convert("justify_alignment", &text_symbolizer_properties::jalign)
|
||||
|
@ -381,15 +382,15 @@ void export_text_placement()
|
|||
.add_property ("format_tree",
|
||||
&text_symbolizer_properties::format_tree,
|
||||
&text_symbolizer_properties::set_format_tree);
|
||||
/* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
|
||||
add_expressions isn't useful in python either. The result is only needed by
|
||||
attribute_collector (which isn't exposed in python) and
|
||||
it just calls add_expressions of the associated formatting tree.
|
||||
set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
|
||||
;
|
||||
/* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
|
||||
add_expressions isn't useful in python either. The result is only needed by
|
||||
attribute_collector (which isn't exposed in python) and
|
||||
it just calls add_expressions of the associated formatting tree.
|
||||
set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
|
||||
;
|
||||
|
||||
class_<char_properties>
|
||||
("CharProperties")
|
||||
("CharProperties")
|
||||
.def(init<char_properties const&>()) //Copy constructor
|
||||
.def_readwrite("face_name", &char_properties::face_name)
|
||||
.def_readwrite("fontset", &char_properties::fontset)
|
||||
|
@ -407,9 +408,9 @@ void export_text_placement()
|
|||
;
|
||||
|
||||
class_<TextPlacementsWrap,
|
||||
boost::shared_ptr<TextPlacementsWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacements")
|
||||
boost::shared_ptr<TextPlacementsWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacements")
|
||||
.def_readwrite("defaults", &text_placements::defaults)
|
||||
.def("get_placement_info", pure_virtual(&text_placements::get_placement_info))
|
||||
/* TODO: add_expressions() */
|
||||
|
@ -417,10 +418,10 @@ void export_text_placement()
|
|||
register_ptr_to_python<boost::shared_ptr<text_placements> >();
|
||||
|
||||
class_<TextPlacementInfoWrap,
|
||||
boost::shared_ptr<TextPlacementInfoWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacementInfo",
|
||||
init<text_placements const*, double>())
|
||||
boost::shared_ptr<TextPlacementInfoWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacementInfo",
|
||||
init<text_placements const*, double>())
|
||||
.def("next", pure_virtual(&text_placement_info::next))
|
||||
.def("get_actual_label_spacing", &text_placement_info::get_actual_label_spacing)
|
||||
.def("get_actual_minimum_distance", &text_placement_info::get_actual_minimum_distance)
|
||||
|
@ -432,27 +433,27 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_<processed_text,
|
||||
boost::shared_ptr<processed_text>,
|
||||
boost::noncopyable>
|
||||
("ProcessedText", no_init)
|
||||
boost::shared_ptr<processed_text>,
|
||||
boost::noncopyable>
|
||||
("ProcessedText", no_init)
|
||||
.def("push_back", &processed_text::push_back)
|
||||
.def("clear", &processed_text::clear)
|
||||
;
|
||||
|
||||
|
||||
class_<expression_set,
|
||||
boost::shared_ptr<expression_set>,
|
||||
boost::noncopyable>
|
||||
("ExpressionSet")
|
||||
boost::shared_ptr<expression_set>,
|
||||
boost::noncopyable>
|
||||
("ExpressionSet")
|
||||
.def("insert", &insert_expression);
|
||||
;
|
||||
;
|
||||
|
||||
|
||||
//TODO: Python namespace
|
||||
class_<NodeWrap,
|
||||
boost::shared_ptr<NodeWrap>,
|
||||
boost::noncopyable>
|
||||
("FormattingNode")
|
||||
boost::shared_ptr<NodeWrap>,
|
||||
boost::noncopyable>
|
||||
("FormattingNode")
|
||||
.def("apply", pure_virtual(&formatting::node::apply))
|
||||
.def("add_expressions",
|
||||
&formatting::node::add_expressions,
|
||||
|
@ -462,10 +463,10 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_<TextNodeWrap,
|
||||
boost::shared_ptr<TextNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingText", init<expression_ptr>())
|
||||
boost::shared_ptr<TextNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingText", init<expression_ptr>())
|
||||
.def(init<std::string>())
|
||||
.def("apply", &formatting::text_node::apply, &TextNodeWrap::default_apply)
|
||||
.add_property("text",
|
||||
|
@ -476,10 +477,10 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_with_converter<FormatNodeWrap,
|
||||
boost::shared_ptr<FormatNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingFormat")
|
||||
boost::shared_ptr<FormatNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingFormat")
|
||||
.def_readwrite_convert("text_size", &formatting::format_node::text_size)
|
||||
.def_readwrite_convert("face_name", &formatting::format_node::face_name)
|
||||
.def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing)
|
||||
|
@ -499,10 +500,10 @@ void export_text_placement()
|
|||
register_ptr_to_python<boost::shared_ptr<formatting::format_node> >();
|
||||
|
||||
class_<ListNodeWrap,
|
||||
boost::shared_ptr<ListNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingList", init<>())
|
||||
boost::shared_ptr<ListNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingList", init<>())
|
||||
.def(init<list>())
|
||||
.def("append", &formatting::list_node::push_back)
|
||||
.def("apply", &formatting::list_node::apply, &ListNodeWrap::default_apply)
|
||||
|
@ -510,15 +511,15 @@ void export_text_placement()
|
|||
.def("__getitem__", &ListNodeWrap::get_item)
|
||||
.def("__setitem__", &ListNodeWrap::set_item)
|
||||
.def("append", &ListNodeWrap::append)
|
||||
;
|
||||
;
|
||||
|
||||
register_ptr_to_python<boost::shared_ptr<formatting::list_node> >();
|
||||
|
||||
class_<ExprFormatWrap,
|
||||
boost::shared_ptr<ExprFormatWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingExpressionFormat")
|
||||
boost::shared_ptr<ExprFormatWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingExpressionFormat")
|
||||
.def_readwrite("text_size", &formatting::expression_format::text_size)
|
||||
.def_readwrite("face_name", &formatting::expression_format::face_name)
|
||||
.def_readwrite("character_spacing", &formatting::expression_format::character_spacing)
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace mapnik {
|
|||
class python_thread
|
||||
{
|
||||
/* Docs:
|
||||
http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
|
||||
*/
|
||||
http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
|
||||
*/
|
||||
public:
|
||||
static void unblock()
|
||||
{
|
||||
|
@ -38,8 +38,8 @@ public:
|
|||
if (state.get())
|
||||
{
|
||||
std::cerr << "ERROR: Python threads are already unblocked. "
|
||||
"Unblocking again will loose the current state and "
|
||||
"might crash later. Aborting!\n";
|
||||
"Unblocking again will loose the current state and "
|
||||
"might crash later. Aborting!\n";
|
||||
abort(); //This is a serious error and can't be handled in any other sane way
|
||||
}
|
||||
#endif
|
||||
|
@ -59,9 +59,9 @@ public:
|
|||
if (thread_support && !state.get())
|
||||
{
|
||||
std::cerr << "ERROR: Trying to restore python thread state, "
|
||||
"but no state is saved. Can't continue and also "
|
||||
"can't raise an exception because the python "
|
||||
"interpreter might be non-function. Aborting!\n";
|
||||
"but no state is saved. Can't continue and also "
|
||||
"can't raise an exception because the python "
|
||||
"interpreter might be non-function. Aborting!\n";
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -102,8 +102,8 @@ struct python_optional : public boost::noncopyable
|
|||
|
||||
/** This class works around a bug in boost python.
|
||||
|
||||
See http://osdir.com/ml/python.c++/2003-11/msg00158.html
|
||||
*/
|
||||
See http://osdir.com/ml/python.c++/2003-11/msg00158.html
|
||||
*/
|
||||
template <typename T, typename X1 = boost::python::detail::not_specified, typename X2 = boost::python::detail::not_specified, typename X3 = boost::python::detail::not_specified>
|
||||
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
|
||||
{
|
||||
|
@ -131,8 +131,8 @@ public:
|
|||
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
|
||||
{
|
||||
this->add_property(name,
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -138,7 +138,9 @@ qcdrain_lyr.datasource = mapnik.Shapefile(file='../data/qcdrainage')
|
|||
qcdrain_style = mapnik.Style()
|
||||
qcdrain_rule = mapnik.Rule()
|
||||
qcdrain_rule.filter = mapnik.Expression('[HYC] = 8')
|
||||
qcdrain_rule.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color(153, 204, 255)))
|
||||
sym = mapnik.PolygonSymbolizer(mapnik.Color(153, 204, 255))
|
||||
sym.smooth = 1.0 # very smooth
|
||||
qcdrain_rule.symbols.append(sym)
|
||||
qcdrain_style.rules.append(qcdrain_rule)
|
||||
|
||||
m.append_style('drainage', qcdrain_style)
|
||||
|
|
|
@ -49,7 +49,7 @@ QVariant LayerListModel::data(QModelIndex const& index,int role) const
|
|||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
double scale = map_->scale();
|
||||
if (map_->layers().at(index.row()).isVisible(scale))
|
||||
if (map_->layers().at(index.row()).visible(scale))
|
||||
{
|
||||
return QIcon(":/images/globe.png");
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ QVariant LayerListModel::data(QModelIndex const& index,int role) const
|
|||
}
|
||||
else if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (map_->layers().at(index.row()).isActive())
|
||||
if (map_->layers().at(index.row()).active())
|
||||
return QVariant(Qt::Checked);
|
||||
else
|
||||
return QVariant(Qt::Unchecked);
|
||||
|
@ -92,7 +92,7 @@ bool LayerListModel::setData(const QModelIndex &index,
|
|||
{
|
||||
int status = value.toInt();
|
||||
std::vector<mapnik::layer> & layers = const_cast<std::vector<mapnik::layer>& >(map_->layers());
|
||||
layers.at(index.row()).setActive(status);
|
||||
layers.at(index.row()).set_active(status);
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <mapnik/ctrans.hpp>
|
||||
#include <mapnik/memory_datasource.hpp>
|
||||
#include <mapnik/feature_kv_iterator.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include "mapwidget.hpp"
|
||||
#include "info_dialog.hpp"
|
||||
|
||||
|
@ -157,7 +158,7 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
|
|||
if (int(index) != selectedLayer_) continue;
|
||||
|
||||
layer & layer = map_->layers()[index];
|
||||
if (!layer.isVisible(scale_denom)) continue;
|
||||
if (!layer.visible(scale_denom)) continue;
|
||||
std::string name = layer.name();
|
||||
double x = e->x();
|
||||
double y = e->y();
|
||||
|
@ -487,7 +488,7 @@ void MapWidget::updateMap()
|
|||
}
|
||||
catch (mapnik::config_error & ex)
|
||||
{
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
|
91
include/mapnik/agg_helpers.hpp
Normal file
91
include/mapnik/agg_helpers.hpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_AGG_HELPERS_HPP
|
||||
#define MAPNIK_AGG_HELPERS_HPP
|
||||
|
||||
#include "agg_gamma_functions.h"
|
||||
#include "agg_math_stroke.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T0, typename T1>
|
||||
void set_gamma_method(T0 const& obj, T1 & ras_ptr)
|
||||
{
|
||||
switch (obj.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(obj.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Stroke,typename PathType>
|
||||
void set_join_caps(Stroke const& stroke_, PathType & stroke)
|
||||
{
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
switch (join)
|
||||
{
|
||||
case MITER_JOIN:
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
break;
|
||||
case MITER_REVERT_JOIN:
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
break;
|
||||
case ROUND_JOIN:
|
||||
stroke.generator().line_join(agg::round_join);
|
||||
break;
|
||||
default:
|
||||
stroke.generator().line_join(agg::bevel_join);
|
||||
}
|
||||
|
||||
line_cap_e cap=stroke_.get_line_cap();
|
||||
switch (cap)
|
||||
{
|
||||
case BUTT_CAP:
|
||||
stroke.generator().line_cap(agg::butt_cap);
|
||||
break;
|
||||
case SQUARE_CAP:
|
||||
stroke.generator().line_cap(agg::square_cap);
|
||||
break;
|
||||
default:
|
||||
stroke.generator().line_cap(agg::round_cap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //MAPNIK_AGG_HELPERS_HPP
|
|
@ -29,10 +29,6 @@
|
|||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
//#include <mapnik/marker.hpp>
|
||||
|
||||
// agg
|
||||
//#include "agg_trans_affine.h"
|
||||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
|
@ -67,10 +63,10 @@ public:
|
|||
~agg_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
void start_layer_processing(layer const& lay);
|
||||
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
|
||||
void end_layer_processing(layer const& lay);
|
||||
void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity);
|
||||
|
||||
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans);
|
||||
|
@ -123,7 +119,7 @@ private:
|
|||
face_manager<freetype_engine> font_manager_;
|
||||
boost::shared_ptr<label_collision_detector4> detector_;
|
||||
boost::scoped_ptr<rasterizer> ras_ptr;
|
||||
|
||||
box2d<double> query_extent_;
|
||||
void setup(Map const &m);
|
||||
};
|
||||
}
|
||||
|
|
99
include/mapnik/boolean.hpp
Normal file
99
include/mapnik/boolean.hpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef MAPNIK_BOOLEAN_HPP
|
||||
#define MAPNIK_BOOLEAN_HPP
|
||||
|
||||
// std
|
||||
#include <istream>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
/** Helper for class bool */
|
||||
class boolean {
|
||||
public:
|
||||
boolean(): b_(false) {}
|
||||
boolean(bool b) : b_(b) {}
|
||||
boolean(boolean const& b) : b_(b.b_) {}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return b_;
|
||||
}
|
||||
|
||||
boolean & operator = (boolean const& other)
|
||||
{
|
||||
b_ = other.b_;
|
||||
return * this;
|
||||
}
|
||||
|
||||
boolean & operator = (bool other)
|
||||
{
|
||||
b_ = other;
|
||||
return * this;
|
||||
}
|
||||
|
||||
private:
|
||||
bool b_;
|
||||
};
|
||||
|
||||
/** Special stream input operator for boolean values */
|
||||
template <typename charT, typename traits>
|
||||
std::basic_istream<charT, traits> &
|
||||
operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
|
||||
{
|
||||
std::string word;
|
||||
s >> word;
|
||||
boost::algorithm::to_lower(word);
|
||||
if ( s )
|
||||
{
|
||||
if ( word == "true" || word == "yes" || word == "on" ||
|
||||
word == "1")
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else if ( word == "false" || word == "no" || word == "off" ||
|
||||
word == "0")
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setstate( std::ios::failbit );
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, boolean const& b )
|
||||
{
|
||||
s << ( b ? "true" : "false" );
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_BOOLEAN_HPP
|
|
@ -78,7 +78,7 @@ protected:
|
|||
public:
|
||||
~cairo_renderer_base();
|
||||
void start_map_processing(Map const& map);
|
||||
void start_layer_processing(layer const& lay);
|
||||
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
|
||||
void end_layer_processing(layer const& lay);
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
|
@ -132,6 +132,7 @@ protected:
|
|||
face_manager<freetype_engine> font_manager_;
|
||||
cairo_face_manager face_manager_;
|
||||
label_collision_detector4 detector_;
|
||||
box2d<double> query_extent_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -137,6 +137,14 @@ public:
|
|||
std::string to_hex_string() const;
|
||||
};
|
||||
|
||||
template <typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
|
||||
{
|
||||
std::string hex_string( c.to_string() );
|
||||
s << hex_string;
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,134 +25,26 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
|
||||
#if BOOST_VERSION >= 104500
|
||||
#include <mapnik/css_color_grammar.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class color;
|
||||
|
||||
template <typename Iterator> struct css_color_grammar;
|
||||
class MAPNIK_DECL color_factory : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
static void init_from_string(color & c, std::string const& css_color)
|
||||
{
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
|
||||
|
||||
css_color_grammar g;
|
||||
iterator_type first = css_color.begin();
|
||||
iterator_type last = css_color.end();
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
c);
|
||||
if (!result)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse color value: ") +
|
||||
"Expected a CSS color, but got '" + css_color + "'");
|
||||
}
|
||||
}
|
||||
static void init_from_string(color & c, std::string const& css_color);
|
||||
|
||||
static bool parse_from_string(color & c, std::string const& css_color,
|
||||
mapnik::css_color_grammar<std::string::const_iterator> const& g)
|
||||
{
|
||||
std::string::const_iterator first = css_color.begin();
|
||||
std::string::const_iterator last = css_color.end();
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
c);
|
||||
return result && (first == last);
|
||||
}
|
||||
mapnik::css_color_grammar<std::string::const_iterator> const& g);
|
||||
|
||||
static color from_string(std::string const& css_color)
|
||||
{
|
||||
color c;
|
||||
init_from_string(c,css_color);
|
||||
return c;
|
||||
}
|
||||
static color from_string(std::string const& css_color);
|
||||
};
|
||||
}
|
||||
|
||||
#else
|
||||
#include <mapnik/css_color_grammar_deprecated.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class MAPNIK_DECL color_factory : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
static bool parse_from_string(color & c, std::string const& css_color,
|
||||
mapnik::css_color_grammar<std::string::const_iterator> const& g)
|
||||
{
|
||||
std::string::const_iterator first = css_color.begin();
|
||||
std::string::const_iterator last = css_color.end();
|
||||
mapnik::css css_;
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
css_);
|
||||
if (result && (first == last))
|
||||
{
|
||||
c.set_red(css_.r);
|
||||
c.set_green(css_.g);
|
||||
c.set_blue(css_.b);
|
||||
c.set_alpha(css_.a);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void init_from_string(color & c, std::string const& css_color)
|
||||
{
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
|
||||
|
||||
css_color_grammar g;
|
||||
iterator_type first = css_color.begin();
|
||||
iterator_type last = css_color.end();
|
||||
mapnik::css css_;
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
css_);
|
||||
if (!result)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse color value: ") +
|
||||
"Expected a CSS color, but got '" + css_color + "'");
|
||||
}
|
||||
c.set_red(css_.r);
|
||||
c.set_green(css_.g);
|
||||
c.set_blue(css_.b);
|
||||
c.set_alpha(css_.a);
|
||||
}
|
||||
|
||||
static color from_string(std::string const& css_color)
|
||||
{
|
||||
color c;
|
||||
init_from_string(c,css_color);
|
||||
return c;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // MAPNIK_COLOR_FACTORY_HPP
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
// Windows DLL support
|
||||
|
||||
#define MAPNIK_SUPPORTS_GRID_RENDERER
|
||||
|
||||
#ifdef _WINDOWS
|
||||
# define MAPNIK_EXP __declspec (dllexport)
|
||||
# define MAPNIK_IMP __declspec (dllimport)
|
||||
|
|
|
@ -28,31 +28,28 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
class xml_node;
|
||||
class config_error : public std::exception
|
||||
{
|
||||
public:
|
||||
config_error():
|
||||
what_() {}
|
||||
|
||||
config_error( std::string const& what ) :
|
||||
what_( what )
|
||||
{
|
||||
}
|
||||
config_error(std::string const& what);
|
||||
config_error(std::string const& what, xml_node const& node);
|
||||
config_error(std::string const& what, unsigned line_number, std::string const& filename);
|
||||
virtual ~config_error() throw() {}
|
||||
|
||||
virtual const char * what() const throw()
|
||||
{
|
||||
return what_.c_str();
|
||||
}
|
||||
|
||||
void append_context(std::string const& ctx) const
|
||||
{
|
||||
what_ += " " + ctx;
|
||||
}
|
||||
virtual const char * what() const throw();
|
||||
|
||||
void append_context(const std::string & ctx) const;
|
||||
void append_context(const std::string & ctx, xml_node const& node) const;
|
||||
void append_context(xml_node const& node) const;
|
||||
protected:
|
||||
mutable std::string what_;
|
||||
mutable unsigned line_number_;
|
||||
mutable std::string file_;
|
||||
mutable std::string node_name_;
|
||||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_CONFIG_ERROR_HPP
|
||||
|
|
|
@ -72,16 +72,16 @@ template <typename Transform, typename Geometry>
|
|||
struct MAPNIK_DECL coord_transform2
|
||||
{
|
||||
typedef std::size_t size_type;
|
||||
typedef typename Geometry::value_type value_type;
|
||||
//typedef typename Geometry::value_type value_type;
|
||||
|
||||
coord_transform2(Transform const& t,
|
||||
Geometry const& geom,
|
||||
Geometry & geom,
|
||||
proj_transform const& prj_trans)
|
||||
: t_(t),
|
||||
geom_(geom),
|
||||
prj_trans_(prj_trans) {}
|
||||
|
||||
unsigned vertex(double *x, double *y) const
|
||||
unsigned vertex(double *x, double *y)
|
||||
{
|
||||
unsigned command = SEG_MOVETO;
|
||||
bool ok = false;
|
||||
|
@ -115,7 +115,7 @@ struct MAPNIK_DECL coord_transform2
|
|||
|
||||
private:
|
||||
Transform const& t_;
|
||||
Geometry const& geom_;
|
||||
Geometry & geom_;
|
||||
proj_transform const& prj_trans_;
|
||||
};
|
||||
|
||||
|
@ -397,9 +397,9 @@ public:
|
|||
sx_(1.0),
|
||||
sy_(1.0)
|
||||
{
|
||||
if (extent_.width())
|
||||
if (extent_.width() > 0)
|
||||
sx_ = static_cast<double>(width_) / extent_.width();
|
||||
if (extent_.height())
|
||||
if (extent_.height() > 0)
|
||||
sy_ = static_cast<double>(height_) / extent_.height();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
@ -35,6 +34,7 @@ namespace mapnik
|
|||
{
|
||||
|
||||
typedef boost::shared_ptr<expr_node> expression_ptr;
|
||||
template <typename Iterator> struct expression_grammar;
|
||||
|
||||
class expression_factory
|
||||
{
|
||||
|
|
|
@ -229,7 +229,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
|||
("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\')
|
||||
("\\\'", '\'')("\\\"", '\"')
|
||||
;
|
||||
|
||||
|
||||
#if BOOST_VERSION > 104500
|
||||
quote_char %= char_('\'') | char_('"');
|
||||
ustring %= omit[quote_char[_a = _1]]
|
||||
|
@ -237,7 +237,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
|||
>> lit(_a);
|
||||
attr %= '[' >> no_skip[+~char_(']')] >> ']';
|
||||
#else
|
||||
ustring %= lit('\'')
|
||||
ustring %= lit('\'')
|
||||
>> *(unesc_char | "\\x" >> hex | (char_ - lit('\'')))
|
||||
>> lit('\'');
|
||||
attr %= '[' >> lexeme[+(char_ - ']')] >> ']';
|
||||
|
|
|
@ -99,11 +99,11 @@ public:
|
|||
|
||||
feature_impl(context_ptr const& ctx, int id)
|
||||
: id_(id),
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
geom_cont_(),
|
||||
raster_()
|
||||
{}
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
geom_cont_(),
|
||||
raster_()
|
||||
{}
|
||||
|
||||
inline int id() const { return id_;}
|
||||
|
||||
|
@ -163,25 +163,25 @@ public:
|
|||
{
|
||||
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
|
||||
if (itr != ctx_->mapping_.end())
|
||||
return get(itr->second);
|
||||
else
|
||||
throw std::out_of_range(std::string("Key does not exist: '") + key + "'");
|
||||
return get(itr->second);
|
||||
else
|
||||
throw std::out_of_range(std::string("Key does not exist: '") + key + "'");
|
||||
}
|
||||
|
||||
|
||||
value_type const& get(std::size_t index) const
|
||||
{
|
||||
if (index < data_.size())
|
||||
return data_[index];
|
||||
throw std::out_of_range("Index out of range");
|
||||
}
|
||||
|
||||
|
||||
boost::optional<value_type const&> get_optional(std::size_t index) const
|
||||
{
|
||||
if (index < data_.size())
|
||||
return boost::optional<value_type const&>(data_[index]);
|
||||
return boost::optional<value_type const&>();
|
||||
}
|
||||
|
||||
|
||||
std::size_t size() const
|
||||
{
|
||||
return data_.size();
|
||||
|
@ -224,13 +224,14 @@ public:
|
|||
|
||||
box2d<double> envelope() const
|
||||
{
|
||||
// TODO - cache this
|
||||
box2d<double> result;
|
||||
for (unsigned i=0;i<num_geometries();++i)
|
||||
{
|
||||
geometry_type const& geom = get_geometry(i);
|
||||
if (i==0)
|
||||
{
|
||||
box2d<double> box = geom.envelope();
|
||||
box2d<double> const& box = geom.envelope();
|
||||
result.init(box.minx(),box.miny(),box.maxx(),box.maxy());
|
||||
}
|
||||
else
|
||||
|
@ -273,7 +274,7 @@ public:
|
|||
if (index < data_.size())
|
||||
{
|
||||
ss << " " << itr->first << ":" << data_[itr->second] << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
ss << ")" << std::endl;
|
||||
return ss.str();
|
||||
|
|
|
@ -46,6 +46,7 @@ extern "C"
|
|||
#include <boost/make_shared.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
@ -153,7 +154,7 @@ class MAPNIK_DECL font_face_set : private boost::noncopyable
|
|||
public:
|
||||
font_face_set(void)
|
||||
: faces_(),
|
||||
dimension_cache_() {}
|
||||
dimension_cache_() {}
|
||||
|
||||
void add(face_ptr face)
|
||||
{
|
||||
|
@ -168,11 +169,10 @@ public:
|
|||
|
||||
glyph_ptr get_glyph(unsigned c) const
|
||||
{
|
||||
for (std::vector<face_ptr>::const_iterator face = faces_.begin(); face != faces_.end(); ++face)
|
||||
BOOST_FOREACH ( face_ptr const& face, faces_)
|
||||
{
|
||||
FT_UInt g = (*face)->get_char(c);
|
||||
|
||||
if (g) return boost::make_shared<font_glyph>(*face, g);
|
||||
FT_UInt g = face->get_char(c);
|
||||
if (g) return boost::make_shared<font_glyph>(face, g);
|
||||
}
|
||||
|
||||
// Final fallback to empty square if nothing better in any font
|
||||
|
@ -185,17 +185,17 @@ public:
|
|||
|
||||
void set_pixel_sizes(unsigned size)
|
||||
{
|
||||
for (std::vector<face_ptr>::iterator face = faces_.begin(); face != faces_.end(); ++face)
|
||||
BOOST_FOREACH ( face_ptr const& face, faces_)
|
||||
{
|
||||
(*face)->set_pixel_sizes(size);
|
||||
face->set_pixel_sizes(size);
|
||||
}
|
||||
}
|
||||
|
||||
void set_character_sizes(float size)
|
||||
{
|
||||
for (std::vector<face_ptr>::iterator face = faces_.begin(); face != faces_.end(); ++face)
|
||||
BOOST_FOREACH ( face_ptr const& face, faces_)
|
||||
{
|
||||
(*face)->set_character_sizes(size);
|
||||
face->set_character_sizes(size);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
@ -263,7 +263,7 @@ template <typename T>
|
|||
class MAPNIK_DECL face_manager : private boost::noncopyable
|
||||
{
|
||||
typedef T font_engine_type;
|
||||
typedef std::map<std::string,face_ptr> faces;
|
||||
typedef std::map<std::string,face_ptr> face_ptr_cache_type;
|
||||
|
||||
public:
|
||||
face_manager(T & engine)
|
||||
|
@ -272,9 +272,9 @@ public:
|
|||
|
||||
face_ptr get_face(std::string const& name)
|
||||
{
|
||||
typename faces::iterator itr;
|
||||
itr = faces_.find(name);
|
||||
if (itr != faces_.end())
|
||||
face_ptr_cache_type::iterator itr;
|
||||
itr = face_ptr_cache_.find(name);
|
||||
if (itr != face_ptr_cache_.end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
face_ptr face = engine_.create_face(name);
|
||||
if (face)
|
||||
{
|
||||
faces_.insert(make_pair(name,face));
|
||||
face_ptr_cache_.insert(make_pair(name,face));
|
||||
}
|
||||
return face;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
faces faces_;
|
||||
face_ptr_cache_type face_ptr_cache_;
|
||||
font_engine_type & engine_;
|
||||
stroker_ptr stroker_;
|
||||
};
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace mapnik {
|
|||
|
||||
typedef std::set<expression_ptr> expression_set;
|
||||
class processed_text;
|
||||
class xml_node;
|
||||
struct char_properties;
|
||||
|
||||
namespace formatting {
|
||||
|
@ -48,7 +49,7 @@ class node
|
|||
public:
|
||||
virtual ~node() {}
|
||||
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const = 0;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace formatting {
|
|||
class expression_format: public node {
|
||||
public:
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
private:
|
||||
node_ptr child_;
|
||||
static expression_ptr get_expression(boost::property_tree::ptree const& xml, std::string name);
|
||||
static expression_ptr get_expression(xml_node const& xml, std::string name);
|
||||
};
|
||||
} //ns formatting
|
||||
} //ns mapnik
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace formatting {
|
|||
class format_node: public node {
|
||||
public:
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
|
|
|
@ -38,16 +38,16 @@ namespace mapnik
|
|||
namespace formatting
|
||||
{
|
||||
|
||||
typedef node_ptr (*from_xml_function_ptr)(boost::property_tree::ptree const& xml);
|
||||
typedef node_ptr (*from_xml_function_ptr)(xml_node const& xml);
|
||||
|
||||
class registry : public singleton<registry, CreateStatic>,
|
||||
private boost::noncopyable
|
||||
private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
registry();
|
||||
~registry() {}
|
||||
void register_name(std::string name, from_xml_function_ptr ptr, bool overwrite=false);
|
||||
node_ptr from_xml(std::string name, boost::property_tree::ptree const& xml);
|
||||
node_ptr from_xml(xml_node const& xml);
|
||||
private:
|
||||
std::map<std::string, from_xml_function_ptr> map_;
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
text_node(expression_ptr text): node(), text_(text) {}
|
||||
text_node(std::string text): node(), text_(parse_expression(text)) {}
|
||||
void to_xml(boost::property_tree::ptree &xml) const;
|
||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
||||
static node_ptr from_xml(xml_node const& xml);
|
||||
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
|
||||
virtual void add_expressions(expression_set &output) const;
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef geometry<double,vertex_vector> geometry_type;
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
~grid_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
void start_layer_processing(layer const& lay);
|
||||
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
|
||||
void end_layer_processing(layer const& lay);
|
||||
void render_marker(mapnik::feature_ptr const& feature, unsigned int step, pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity);
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public:
|
|||
|
||||
~hextree()
|
||||
{}
|
||||
|
||||
|
||||
void setMaxColors(unsigned max_colors)
|
||||
{
|
||||
max_colors_ = max_colors;
|
||||
|
@ -335,7 +335,7 @@ public:
|
|||
|
||||
sorted_pal_.reserve(colors_);
|
||||
create_palette_rek(sorted_pal_, root_.get());
|
||||
|
||||
|
||||
// sort palette for binary searching in quantization
|
||||
#if BOOST_VERSION >= 104600
|
||||
boost::sort(sorted_pal_, rgba::mean_sort_cmp());
|
||||
|
|
|
@ -24,11 +24,6 @@
|
|||
#define MAPNIK_IMAGE_COMPOSITING_HPP
|
||||
|
||||
// agg
|
||||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_rasterizer_scanline_aa.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -69,116 +64,7 @@ enum composite_mode_e
|
|||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void composite(T1 & im, T2 & im2, composite_mode_e mode)
|
||||
{
|
||||
typedef agg::rgba8 color;
|
||||
typedef agg::order_bgra order;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba<color, order> blender_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
|
||||
typedef agg::renderer_base<pixfmt_type> renderer_type;
|
||||
typedef agg::comp_op_adaptor_rgba<color, order> blender_type;
|
||||
typedef agg::renderer_base<pixfmt_type> renderer_type;
|
||||
|
||||
agg::rendering_buffer source(im.getBytes(),im.width(),im.height(),im.width() * 4);
|
||||
agg::rendering_buffer mask(im2.getBytes(),im2.width(),im2.height(),im2.width() * 4);
|
||||
|
||||
agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixf(source);
|
||||
agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixf_mask(mask);
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case clear :
|
||||
pixf.comp_op(agg::comp_op_clear);
|
||||
break;
|
||||
case src:
|
||||
pixf.comp_op(agg::comp_op_src);
|
||||
break;
|
||||
case dst:
|
||||
pixf.comp_op(agg::comp_op_dst);
|
||||
break;
|
||||
case src_over:
|
||||
pixf.comp_op(agg::comp_op_src_over);
|
||||
break;
|
||||
case dst_over:
|
||||
pixf.comp_op(agg::comp_op_dst_over);
|
||||
break;
|
||||
case src_in:
|
||||
pixf.comp_op(agg::comp_op_src_in);
|
||||
break;
|
||||
case dst_in:
|
||||
pixf.comp_op(agg::comp_op_dst_in);
|
||||
break;
|
||||
case src_out:
|
||||
pixf.comp_op(agg::comp_op_src_out);
|
||||
break;
|
||||
case dst_out:
|
||||
pixf.comp_op(agg::comp_op_dst_out);
|
||||
break;
|
||||
case src_atop:
|
||||
pixf.comp_op(agg::comp_op_src_atop);
|
||||
break;
|
||||
case dst_atop:
|
||||
pixf.comp_op(agg::comp_op_dst_atop);
|
||||
break;
|
||||
case _xor:
|
||||
pixf.comp_op(agg::comp_op_xor);
|
||||
break;
|
||||
case plus:
|
||||
pixf.comp_op(agg::comp_op_plus);
|
||||
break;
|
||||
case minus:
|
||||
pixf.comp_op(agg::comp_op_minus);
|
||||
break;
|
||||
case multiply:
|
||||
pixf.comp_op(agg::comp_op_multiply);
|
||||
break;
|
||||
case screen:
|
||||
pixf.comp_op(agg::comp_op_screen);
|
||||
break;
|
||||
case overlay:
|
||||
pixf.comp_op(agg::comp_op_overlay);
|
||||
break;
|
||||
case darken:
|
||||
pixf.comp_op(agg::comp_op_darken);
|
||||
break;
|
||||
case lighten:
|
||||
pixf.comp_op(agg::comp_op_lighten);
|
||||
break;
|
||||
case color_dodge:
|
||||
pixf.comp_op(agg::comp_op_color_dodge);
|
||||
break;
|
||||
case color_burn:
|
||||
pixf.comp_op(agg::comp_op_color_burn);
|
||||
break;
|
||||
case hard_light:
|
||||
pixf.comp_op(agg::comp_op_hard_light);
|
||||
break;
|
||||
case soft_light:
|
||||
pixf.comp_op(agg::comp_op_soft_light);
|
||||
break;
|
||||
case difference:
|
||||
pixf.comp_op(agg::comp_op_difference);
|
||||
break;
|
||||
case exclusion:
|
||||
pixf.comp_op(agg::comp_op_exclusion);
|
||||
break;
|
||||
case contrast:
|
||||
pixf.comp_op(agg::comp_op_contrast);
|
||||
break;
|
||||
case invert:
|
||||
pixf.comp_op(agg::comp_op_invert);
|
||||
break;
|
||||
case invert_rgb:
|
||||
pixf.comp_op(agg::comp_op_invert_rgb);
|
||||
break;
|
||||
}
|
||||
renderer_type ren(pixf);
|
||||
agg::renderer_base<pixfmt_type> rb(pixf);
|
||||
rb.blend_from(pixf_mask,0,0,0,255);
|
||||
void composite(T1 & im, T2 & im2, composite_mode_e mode);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // MAPNIK_IMAGE_COMPOSITING_HPP
|
||||
|
|
|
@ -1,26 +1,34 @@
|
|||
#ifndef DUMP_XML_HPP
|
||||
#define DUMP_XML_HPP
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <mapnik/xml_node.hpp>
|
||||
|
||||
/* Debug dump ptree XML representation.
|
||||
*/
|
||||
void dump_xml(boost::property_tree::ptree const& xml, unsigned level=0)
|
||||
*/
|
||||
void dump_xml(xml_node const& xml, unsigned level=0)
|
||||
{
|
||||
std::string indent;
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i=0; i<level; i++)
|
||||
{
|
||||
indent += " ";
|
||||
}
|
||||
if (xml.data().length()) std::cout << indent << "data: '" << xml.data() << "'\n";
|
||||
boost::property_tree::ptree::const_iterator itr = xml.begin();
|
||||
boost::property_tree::ptree::const_iterator end = xml.end();
|
||||
xml_node::attribute_map const& attr = xml.get_attributes();
|
||||
std::cerr << indent <<"[" << xml.name();
|
||||
xml_node::attribute_map::const_iterator aitr = attr.begin();
|
||||
xml_node::attribute_map::const_iterator aend = attr.end();
|
||||
for (;aitr!=aend; aitr++)
|
||||
{
|
||||
std::cerr << " (" << aitr->first << ", " << aitr->second.value << ", " << aitr->second.processed << ")";
|
||||
}
|
||||
std::cerr << "]" << "\n";
|
||||
if (xml.is_text()) std::cerr << indent << "text: '" << xml.text() << "'\n";
|
||||
xml_node::const_iterator itr = xml.begin();
|
||||
xml_node::const_iterator end = xml.end();
|
||||
for (; itr!=end; itr++)
|
||||
{
|
||||
std::cout << indent <<"[" << itr->first << "]" << "\n";
|
||||
dump_xml(itr->second, level+1);
|
||||
std::cout << indent << "[/" << itr->first << "]" << "\n";
|
||||
dump_xml(*itr, level+1);
|
||||
}
|
||||
std::cerr << indent << "[/" << xml.name() << "]" << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ struct label_collision_detector
|
|||
{
|
||||
typedef std::vector<box2d<double> > label_placements;
|
||||
|
||||
bool has_plasement(box2d<double> const& box)
|
||||
bool has_placement(box2d<double> const& box)
|
||||
{
|
||||
label_placements::const_iterator itr=labels_.begin();
|
||||
for( ; itr !=labels_.end();++itr)
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
//quad tree based label collission detector so labels dont appear within a given distance
|
||||
//quad tree based label collision detector so labels dont appear within a given distance
|
||||
class label_collision_detector4 : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -88,44 +88,44 @@ public:
|
|||
std::vector<std::string>& styles();
|
||||
|
||||
/*!
|
||||
* @param maxZoom The minimum zoom level to set
|
||||
* @param max_zoom The minimum zoom level to set
|
||||
*/
|
||||
void setMinZoom(double minZoom);
|
||||
void set_min_zoom(double min_zoom);
|
||||
|
||||
/*!
|
||||
* @param maxZoom The maximum zoom level to set
|
||||
* @param max_zoom The maximum zoom level to set
|
||||
*/
|
||||
void setMaxZoom(double maxZoom);
|
||||
void set_max_zoom(double max_zoom);
|
||||
|
||||
/*!
|
||||
* @return the minimum zoom level of the layer.
|
||||
*/
|
||||
double getMinZoom() const;
|
||||
double min_zoom() const;
|
||||
|
||||
/*!
|
||||
* @return the maximum zoom level of the layer.
|
||||
*/
|
||||
double getMaxZoom() const;
|
||||
double max_zoom() const;
|
||||
|
||||
/*!
|
||||
* @brief Set whether this layer is active and will be rendered.
|
||||
*/
|
||||
void setActive(bool active);
|
||||
void set_active(bool active);
|
||||
|
||||
/*!
|
||||
* @return whether this layer is active and will be rendered.
|
||||
*/
|
||||
bool isActive() const;
|
||||
bool active() const;
|
||||
|
||||
/*!
|
||||
* @brief Set whether this layer is queryable.
|
||||
*/
|
||||
void setQueryable(bool queryable);
|
||||
void set_queryable(bool queryable);
|
||||
|
||||
/*!
|
||||
* @return whether this layer is queryable or not.
|
||||
*/
|
||||
bool isQueryable() const;
|
||||
bool queryable() const;
|
||||
|
||||
/*!
|
||||
* @brief Get the visability for a specific scale.
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
* or
|
||||
* scale < maxzoom + 1e-6
|
||||
*/
|
||||
bool isVisible(double scale) const;
|
||||
bool visible(double scale) const;
|
||||
|
||||
/*!
|
||||
* @param clear_cache Set whether this layer's labels are cached.
|
||||
|
@ -195,8 +195,8 @@ private:
|
|||
std::string name_;
|
||||
std::string srs_;
|
||||
|
||||
double minZoom_;
|
||||
double maxZoom_;
|
||||
double min_zoom_;
|
||||
double max_zoom_;
|
||||
bool active_;
|
||||
bool queryable_;
|
||||
bool clear_label_cache_;
|
||||
|
|
|
@ -44,17 +44,20 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
|
|||
explicit line_symbolizer()
|
||||
: symbolizer_base(),
|
||||
stroke_(),
|
||||
rasterizer_p_(RASTERIZER_FULL) {}
|
||||
rasterizer_p_(RASTERIZER_FULL),
|
||||
smooth_(0.0) {}
|
||||
|
||||
line_symbolizer(stroke const& stroke)
|
||||
: symbolizer_base(),
|
||||
stroke_(stroke),
|
||||
rasterizer_p_(RASTERIZER_FULL) {}
|
||||
rasterizer_p_(RASTERIZER_FULL),
|
||||
smooth_(0.0) {}
|
||||
|
||||
line_symbolizer(color const& pen,float width=1.0)
|
||||
: symbolizer_base(),
|
||||
stroke_(pen,width),
|
||||
rasterizer_p_(RASTERIZER_FULL) {}
|
||||
rasterizer_p_(RASTERIZER_FULL),
|
||||
smooth_(0.0) {}
|
||||
|
||||
stroke const& get_stroke() const
|
||||
{
|
||||
|
@ -76,9 +79,20 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
|
|||
return rasterizer_p_;
|
||||
}
|
||||
|
||||
void set_smooth(double smooth)
|
||||
{
|
||||
smooth_ = smooth;
|
||||
}
|
||||
|
||||
double smooth() const
|
||||
{
|
||||
return smooth_;
|
||||
}
|
||||
|
||||
private:
|
||||
stroke stroke_;
|
||||
line_rasterizer_e rasterizer_p_;
|
||||
double smooth_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ private:
|
|||
box2d<double> current_extent_;
|
||||
boost::optional<box2d<double> > maximum_extent_;
|
||||
std::string base_path_;
|
||||
parameters extra_attr_;
|
||||
parameters extra_params_;
|
||||
|
||||
public:
|
||||
|
@ -440,21 +439,6 @@ public:
|
|||
*/
|
||||
std::string get_metawriter_property(std::string name) const;
|
||||
|
||||
/*!
|
||||
* @brief Get extra valid attributes of the Map that are not true members
|
||||
*/
|
||||
parameters const& get_extra_attributes() const;
|
||||
|
||||
/*!
|
||||
* @brief Get non-const extra valid attributes of the Map that are not true members
|
||||
*/
|
||||
parameters& get_extra_attributes();
|
||||
|
||||
/*!
|
||||
* @brief Set extra attributes of the Map
|
||||
*/
|
||||
void set_extra_attributes(parameters& attr);
|
||||
|
||||
/*!
|
||||
* @brief Get extra, arbitrary Parameters attached to the Map
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,7 @@ struct MAPNIK_DECL mapped_memory_cache :
|
|||
static boost::unordered_map<std::string,mapped_region_ptr> cache_;
|
||||
static bool insert(std::string const& key, mapped_region_ptr);
|
||||
static boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
|
||||
static void clear();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,14 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/svg/svg_storage.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_path_storage.h"
|
||||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
|
@ -43,7 +36,7 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
using namespace mapnik::svg;
|
||||
class marker;
|
||||
|
||||
typedef boost::shared_ptr<marker> marker_ptr;
|
||||
|
||||
|
@ -57,6 +50,7 @@ struct MAPNIK_DECL marker_cache :
|
|||
static boost::unordered_map<std::string,marker_ptr> cache_;
|
||||
static bool insert(std::string const& key, marker_ptr);
|
||||
static boost::optional<marker_ptr> find(std::string const& key, bool update_cache = false);
|
||||
static void clear();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
explicit markers_symbolizer();
|
||||
markers_symbolizer(path_expression_ptr filename);
|
||||
markers_symbolizer(markers_symbolizer const& rhs);
|
||||
void set_ignore_placement(bool ignore_placement);
|
||||
bool get_ignore_placement() const;
|
||||
void set_allow_overlap(bool overlap);
|
||||
bool get_allow_overlap() const;
|
||||
void set_spacing(double spacing);
|
||||
|
@ -76,6 +78,7 @@ public:
|
|||
marker_type_e get_marker_type() const;
|
||||
|
||||
private:
|
||||
bool ignore_placement_;
|
||||
bool allow_overlap_;
|
||||
color fill_;
|
||||
double spacing_;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
class xml_node;
|
||||
|
||||
/**
|
||||
* Creates a metawriter with the properties specified in the property
|
||||
|
@ -37,7 +38,7 @@ namespace mapnik {
|
|||
* metawriters, but should provide an easy point to make them a
|
||||
* proper factory method if this is wanted in the future.
|
||||
*/
|
||||
metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt);
|
||||
metawriter_ptr metawriter_create(xml_node const& pt);
|
||||
|
||||
/**
|
||||
* Writes properties into the given property tree representing the
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
|
|
|
@ -23,13 +23,20 @@
|
|||
#ifndef MAPNIK_PLACEMENT_FINDER_HPP
|
||||
#define MAPNIK_PLACEMENT_FINDER_HPP
|
||||
|
||||
//mapnik
|
||||
// mapnik
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/text_properties.hpp>
|
||||
#include <mapnik/text_placements/base.hpp>
|
||||
#include <mapnik/symbolizer_helpers.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/ctrans.hpp>
|
||||
|
||||
//stl
|
||||
|
||||
// agg
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
|
||||
// stl
|
||||
#include <queue>
|
||||
|
||||
namespace mapnik
|
||||
|
@ -39,6 +46,12 @@ class text_placement_info;
|
|||
class string_info;
|
||||
class text_path;
|
||||
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> ClippedPathType;
|
||||
typedef coord_transform2<CoordTransform,geometry_type> PathType;
|
||||
|
||||
typedef label_collision_detector4 DetectorType;
|
||||
|
||||
|
||||
template <typename DetectorT>
|
||||
class placement_finder : boost::noncopyable
|
||||
|
@ -124,19 +137,20 @@ private:
|
|||
text_symbolizer_properties const& p;
|
||||
text_placement_info const& pi;
|
||||
/** Length of the longest line after linebreaks.
|
||||
* Before find_line_breaks() this is the total length of the string.
|
||||
*/
|
||||
* Before find_line_breaks() this is the total length of the string.
|
||||
*/
|
||||
double string_width_;
|
||||
/** Height of the string after linebreaks.
|
||||
* Before find_line_breaks() this is the total length of the string.
|
||||
*/
|
||||
* Before find_line_breaks() this is the total length of the string.
|
||||
*/
|
||||
double string_height_;
|
||||
/** Height of the tallest font in the first line not including line spacing.
|
||||
* Used to determine the correct offset for the first line.
|
||||
*/
|
||||
* Used to determine the correct offset for the first line.
|
||||
*/
|
||||
double first_line_space_;
|
||||
vertical_alignment_e valign_;
|
||||
horizontal_alignment_e halign_;
|
||||
justify_alignment_e jalign_;
|
||||
std::vector<unsigned> line_breaks_;
|
||||
std::vector<std::pair<double, double> > line_sizes_;
|
||||
std::queue< box2d<double> > envelopes_;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace mapnik
|
|||
struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
|
||||
{
|
||||
polygon_symbolizer();
|
||||
polygon_symbolizer(color const& fill);
|
||||
explicit polygon_symbolizer(color const& fill);
|
||||
color const& get_fill() const;
|
||||
void set_fill(color const& fill);
|
||||
void set_opacity(double opacity);
|
||||
|
@ -44,12 +44,14 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
|
|||
double get_gamma() const;
|
||||
void set_gamma_method(gamma_method_e gamma_method);
|
||||
gamma_method_e get_gamma_method() const;
|
||||
|
||||
void set_smooth(double smooth);
|
||||
double smooth() const;
|
||||
private:
|
||||
color fill_;
|
||||
double opacity_;
|
||||
double gamma_;
|
||||
gamma_method_e gamma_method_;
|
||||
double smooth_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -23,450 +23,17 @@
|
|||
#ifndef MAPNIK_PTREE_HELPERS_HPP
|
||||
#define MAPNIK_PTREE_HELPERS_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/color_factory.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
// boost
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
// stl
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T>
|
||||
inline boost::optional<T> fast_cast(std::string const& value);
|
||||
|
||||
template <typename T>
|
||||
T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute,
|
||||
T const& default_value);
|
||||
template <typename T>
|
||||
T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute);
|
||||
template <typename T>
|
||||
T get_value(boost::property_tree::ptree const& node, std::string const& name);
|
||||
template <typename T>
|
||||
boost::optional<T> get_optional(boost::property_tree::ptree const& node, std::string const& name,
|
||||
bool is_attribute);
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_opt_attr( boost::property_tree::ptree const& node,
|
||||
std::string const& name)
|
||||
{
|
||||
return get_optional<T>( node, name, true);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_opt_child( boost::property_tree::ptree const& node,
|
||||
std::string const& name)
|
||||
{
|
||||
return get_optional<T>( node, name, false);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get_attr( boost::property_tree::ptree const& node, std::string const& name,
|
||||
T const& default_value )
|
||||
{
|
||||
return get<T>( node, name, true, default_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get_attr( boost::property_tree::ptree const& node, std::string const& name )
|
||||
{
|
||||
return get<T>( node, name, true );
|
||||
}
|
||||
|
||||
|
||||
template <typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
|
||||
{
|
||||
std::string hex_string( c.to_string() );
|
||||
s << hex_string;
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Helper for class bool */
|
||||
class boolean {
|
||||
public:
|
||||
boolean() : b_(false) {}
|
||||
boolean(bool b) : b_(b) {}
|
||||
boolean(boolean const& b) : b_(b.b_) {}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return b_;
|
||||
}
|
||||
boolean & operator = (boolean const& other)
|
||||
{
|
||||
b_ = other.b_;
|
||||
return * this;
|
||||
}
|
||||
boolean & operator = (bool other)
|
||||
{
|
||||
b_ = other;
|
||||
return * this;
|
||||
}
|
||||
private:
|
||||
bool b_;
|
||||
};
|
||||
|
||||
/** Special stream input operator for boolean values */
|
||||
template <typename charT, typename traits>
|
||||
std::basic_istream<charT, traits> &
|
||||
operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
|
||||
{
|
||||
std::string word;
|
||||
s >> word;
|
||||
if ( s )
|
||||
{
|
||||
if ( word == "true" || word == "yes" || word == "on" ||
|
||||
word == "1")
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else if ( word == "false" || word == "no" || word == "off" ||
|
||||
word == "0")
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setstate( std::ios::failbit );
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, boolean const& b )
|
||||
{
|
||||
s << ( b ? "true" : "false" );
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set_attr(boost::property_tree::ptree & pt, std::string const& name, T const& v)
|
||||
{
|
||||
pt.put("<xmlattr>." + name, v);
|
||||
}
|
||||
|
||||
|
||||
class boolean;
|
||||
|
||||
template <typename T>
|
||||
struct name_trait
|
||||
{
|
||||
static std::string name()
|
||||
{
|
||||
return "<unknown>";
|
||||
}
|
||||
// missing name_trait for type ...
|
||||
// if you get here you are probably using a new type
|
||||
// in the XML file. Just add a name trait for the new
|
||||
// type below.
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == 0 );
|
||||
};
|
||||
|
||||
#define DEFINE_NAME_TRAIT( type, type_name ) \
|
||||
template <> \
|
||||
struct name_trait<type> \
|
||||
{ \
|
||||
static std::string name() { return std::string("type ") + type_name; } \
|
||||
};
|
||||
|
||||
|
||||
DEFINE_NAME_TRAIT( double, "double")
|
||||
DEFINE_NAME_TRAIT( float, "float")
|
||||
DEFINE_NAME_TRAIT( unsigned, "unsigned")
|
||||
DEFINE_NAME_TRAIT( boolean, "boolean")
|
||||
DEFINE_NAME_TRAIT( int, "integer" )
|
||||
DEFINE_NAME_TRAIT( std::string, "string" )
|
||||
DEFINE_NAME_TRAIT( color, "color" )
|
||||
|
||||
template <typename ENUM, int MAX>
|
||||
struct name_trait< mapnik::enumeration<ENUM, MAX> >
|
||||
{
|
||||
typedef enumeration<ENUM, MAX> Enum;
|
||||
|
||||
static std::string name()
|
||||
{
|
||||
std::string value_list("one of [");
|
||||
for (unsigned i = 0; i < Enum::MAX; ++i)
|
||||
{
|
||||
value_list += Enum::get_string( i );
|
||||
if ( i + 1 < Enum::MAX ) value_list += ", ";
|
||||
}
|
||||
value_list += "]";
|
||||
|
||||
return value_list;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline boost::optional<T> fast_cast(std::string const& value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::lexical_cast<T>( value );
|
||||
}
|
||||
catch (boost::bad_lexical_cast const& ex)
|
||||
{
|
||||
return boost::optional<T>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::optional<int> fast_cast(std::string const& value)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::conversions::string2int(value,result))
|
||||
return boost::optional<int>(result);
|
||||
return boost::optional<int>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::optional<double> fast_cast(std::string const& value)
|
||||
{
|
||||
double result;
|
||||
if (mapnik::conversions::string2double(value,result))
|
||||
return boost::optional<double>(result);
|
||||
return boost::optional<double>();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::optional<float> fast_cast(std::string const& value)
|
||||
{
|
||||
float result;
|
||||
if (mapnik::conversions::string2float(value,result))
|
||||
return boost::optional<float>(result);
|
||||
return boost::optional<float>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get(boost::property_tree::ptree const& node,
|
||||
std::string const& name,
|
||||
bool is_attribute,
|
||||
T const& default_value)
|
||||
{
|
||||
boost::optional<std::string> str;
|
||||
if (is_attribute)
|
||||
{
|
||||
str = node.get_optional<std::string>( std::string("<xmlattr>.") + name );
|
||||
}
|
||||
else
|
||||
{
|
||||
str = node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
|
||||
if ( str )
|
||||
{
|
||||
boost::optional<T> result = fast_cast<T>(*str);
|
||||
if (result)
|
||||
{
|
||||
return *result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
(is_attribute ? "attribute" : "child node") + " '" +
|
||||
name + "'. Expected " + name_trait<T>::name() +
|
||||
" but got '" + *str + "'");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline color get(boost::property_tree::ptree const& node,
|
||||
std::string const& name,
|
||||
bool is_attribute,
|
||||
color const& default_value)
|
||||
{
|
||||
boost::optional<std::string> str;
|
||||
if (is_attribute)
|
||||
{
|
||||
str = node.get_optional<std::string>( std::string("<xmlattr>.") + name );
|
||||
}
|
||||
else
|
||||
{
|
||||
str = node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
|
||||
if ( str )
|
||||
{
|
||||
try
|
||||
{
|
||||
return mapnik::color_factory::from_string((*str).c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
(is_attribute ? "attribute" : "child node") + " '" +
|
||||
name + "'. Expected " + name_trait<color>::name() +
|
||||
" but got '" + *str + "'");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute)
|
||||
{
|
||||
boost::optional<std::string> str;
|
||||
if (is_attribute)
|
||||
{
|
||||
str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
|
||||
if ( ! str )
|
||||
{
|
||||
throw config_error(std::string("Required ") +
|
||||
(is_attribute ? "attribute " : "child node ") +
|
||||
"'" + name + "' is missing");
|
||||
}
|
||||
boost::optional<T> result = fast_cast<T>(*str);
|
||||
if (result)
|
||||
{
|
||||
return *result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
(is_attribute ? "attribute" : "child node") + " '" +
|
||||
name + "'. Expected " + name_trait<T>::name() +
|
||||
" but got '" + *str + "'");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get_value(boost::property_tree::ptree const& node, std::string const& name)
|
||||
{
|
||||
try
|
||||
{
|
||||
/* NOTE: get_child works as long as there is only one child with that name.
|
||||
If this function is used this used this condition must always be satisfied.
|
||||
*/
|
||||
return node.get_child("<xmltext>").get_value<T>();
|
||||
}
|
||||
catch (boost::property_tree::ptree_bad_path)
|
||||
{
|
||||
/* If the XML parser did not find any non-empty data element the is no
|
||||
<xmltext> node. But we don't want to fail here but simply return a
|
||||
default constructed value of the requested type.
|
||||
*/
|
||||
return T();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
name + ". Expected " + name_trait<T>::name() +
|
||||
" but got '" + node.data() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_optional(boost::property_tree::ptree const& node,
|
||||
std::string const& name,
|
||||
bool is_attribute)
|
||||
{
|
||||
boost::optional<std::string> str;
|
||||
if (is_attribute)
|
||||
{
|
||||
str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
|
||||
boost::optional<T> result;
|
||||
if ( str )
|
||||
{
|
||||
result = fast_cast<T>(*str);
|
||||
if (!result)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
(is_attribute ? "attribute" : "child node") + " '" +
|
||||
name + "'. Expected " + name_trait<T>::name() +
|
||||
" but got '" + *str + "'");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::optional<std::string> get_optional(boost::property_tree::ptree const& node,
|
||||
std::string const& name,
|
||||
bool is_attribute)
|
||||
{
|
||||
if (is_attribute)
|
||||
{
|
||||
return node.get_optional<std::string>( std::string("<xmlattr>.") + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline boost::optional<color> get_optional(boost::property_tree::ptree const& node,
|
||||
std::string const& name,
|
||||
bool is_attribute)
|
||||
{
|
||||
boost::optional<std::string> str;
|
||||
if (is_attribute)
|
||||
{
|
||||
str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = node.get_optional<std::string>(name + ".<xmltext>");
|
||||
}
|
||||
|
||||
boost::optional<color> result;
|
||||
if ( str )
|
||||
{
|
||||
try
|
||||
{
|
||||
result = mapnik::color_factory::from_string((*str).c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse ") +
|
||||
(is_attribute ? "attribute" : "child node") + " '" +
|
||||
name + "'. Expected " + name_trait<color>::name() +
|
||||
" but got '" + *str + "'");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline bool has_child(boost::property_tree::ptree const& node, std::string const& name)
|
||||
{
|
||||
boost::optional<std::string> str = node.get_optional<std::string>(name);
|
||||
return str;
|
||||
}
|
||||
|
||||
} // end of namespace mapnik
|
||||
|
||||
#endif // MAPNIK_PTREE_HELPERS_HPP
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/enumeration.hpp>
|
||||
|
|
|
@ -55,7 +55,8 @@ public:
|
|||
double scale_factor,
|
||||
CoordTransform const& t,
|
||||
FaceManagerT &font_manager,
|
||||
DetectorT &detector)
|
||||
DetectorT &detector,
|
||||
box2d<double> const& query_extent)
|
||||
: sym_(sym),
|
||||
feature_(feature),
|
||||
prj_trans_(prj_trans),
|
||||
|
@ -64,6 +65,7 @@ public:
|
|||
detector_(detector),
|
||||
writer_(sym.get_metawriter()),
|
||||
dims_(0, 0, width, height),
|
||||
query_extent_(query_extent),
|
||||
text_(font_manager, scale_factor),
|
||||
angle_(0.0),
|
||||
placement_valid_(false),
|
||||
|
@ -100,7 +102,7 @@ protected:
|
|||
DetectorT & detector_;
|
||||
metawriter_with_properties writer_;
|
||||
box2d<double> dims_;
|
||||
|
||||
box2d<double> const& query_extent_;
|
||||
//Processing
|
||||
processed_text text_;
|
||||
/* Using list instead of vector, because we delete random elements and need iterators to stay valid. */
|
||||
|
@ -137,10 +139,11 @@ public:
|
|||
unsigned width,
|
||||
unsigned height,
|
||||
double scale_factor,
|
||||
CoordTransform const& t,
|
||||
FaceManagerT & font_manager,
|
||||
DetectorT & detector) :
|
||||
text_symbolizer_helper<FaceManagerT, DetectorT>(sym, feature, prj_trans, width, height, scale_factor, t, font_manager, detector),
|
||||
CoordTransform const &t,
|
||||
FaceManagerT &font_manager,
|
||||
DetectorT &detector,
|
||||
box2d<double> const& query_extent) :
|
||||
text_symbolizer_helper<FaceManagerT, DetectorT>(sym, feature, prj_trans, width, height, scale_factor, t, font_manager, detector, query_extent),
|
||||
sym_(sym)
|
||||
{
|
||||
this->points_on_line_ = true;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
text_symbolizer_properties & add();
|
||||
text_symbolizer_properties & get(unsigned i);
|
||||
unsigned size() const;
|
||||
static text_placements_ptr from_xml(boost::property_tree::ptree const &xml, fontset_map const & fontsets);
|
||||
static text_placements_ptr from_xml(xml_node const &xml, fontset_map const & fontsets);
|
||||
private:
|
||||
std::vector<text_symbolizer_properties> list_;
|
||||
friend class text_placement_info_list;
|
||||
|
|
|
@ -39,17 +39,17 @@ namespace placements
|
|||
{
|
||||
|
||||
typedef text_placements_ptr (*from_xml_function_ptr)(
|
||||
boost::property_tree::ptree const& xml, fontset_map const & fontsets);
|
||||
xml_node const& xml, fontset_map const & fontsets);
|
||||
|
||||
class registry : public singleton<registry, CreateStatic>,
|
||||
private boost::noncopyable
|
||||
private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
registry();
|
||||
~registry() {}
|
||||
void register_name(std::string name, from_xml_function_ptr ptr, bool overwrite=false);
|
||||
text_placements_ptr from_xml(std::string name,
|
||||
boost::property_tree::ptree const& xml,
|
||||
xml_node const& xml,
|
||||
fontset_map const & fontsets);
|
||||
private:
|
||||
std::map<std::string, from_xml_function_ptr> map_;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
text_placement_info_ptr get_placement_info(double scale_factor) const;
|
||||
void set_positions(std::string positions);
|
||||
std::string get_positions();
|
||||
static text_placements_ptr from_xml(boost::property_tree::ptree const &xml, fontset_map const & fontsets);
|
||||
static text_placements_ptr from_xml(xml_node const &xml, fontset_map const & fontsets);
|
||||
private:
|
||||
std::string positions_;
|
||||
std::vector<directions_t> direction_;
|
||||
|
|
|
@ -54,7 +54,7 @@ struct char_properties
|
|||
{
|
||||
char_properties();
|
||||
/** Construct object from XML. */
|
||||
void from_xml(boost::property_tree::ptree const &sym, fontset_map const & fontsets);
|
||||
void from_xml(xml_node const &sym, fontset_map const & fontsets);
|
||||
/** Write object to XML ptree. */
|
||||
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, char_properties const& dfl=char_properties()) const;
|
||||
std::string face_name;
|
||||
|
@ -110,6 +110,7 @@ enum justify_alignment
|
|||
J_LEFT = 0,
|
||||
J_MIDDLE,
|
||||
J_RIGHT,
|
||||
J_AUTO,
|
||||
justify_alignment_MAX
|
||||
};
|
||||
|
||||
|
@ -124,7 +125,7 @@ struct text_symbolizer_properties
|
|||
{
|
||||
text_symbolizer_properties();
|
||||
/** Load all values from XML ptree. */
|
||||
void from_xml(boost::property_tree::ptree const &sym, fontset_map const & fontsets);
|
||||
void from_xml(xml_node const &sym, fontset_map const & fontsets);
|
||||
/** Save all values to XML ptree (but does not create a new parent node!). */
|
||||
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, text_symbolizer_properties const &dfl=text_symbolizer_properties()) const;
|
||||
|
||||
|
|
|
@ -20,26 +20,25 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_CONVERSIONS_UTIL_HPP
|
||||
#define MAPNIK_CONVERSIONS_UTIL_HPP
|
||||
#ifndef MAPNIK_UTIL_CONVERSIONS_HPP
|
||||
#define MAPNIK_UTIL_CONVERSIONS_HPP
|
||||
|
||||
// mapnik
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace conversions {
|
||||
namespace mapnik { namespace util {
|
||||
|
||||
bool string2int(const char * value, int & result);
|
||||
bool string2int(std::string const& value, int & result);
|
||||
|
||||
bool string2double(std::string const& value, double & result);
|
||||
bool string2double(const char * value, double & result);
|
||||
|
||||
bool string2float(std::string const& value, float & result);
|
||||
bool string2float(const char * value, float & result);
|
||||
bool string2int(const char * value, int & result);
|
||||
bool string2int(std::string const& value, int & result);
|
||||
|
||||
}
|
||||
}
|
||||
bool string2double(std::string const& value, double & result);
|
||||
bool string2double(const char * value, double & result);
|
||||
|
||||
#endif // MAPNIK_CONVERSIONS_UTIL_HPP
|
||||
bool string2float(std::string const& value, float & result);
|
||||
bool string2float(const char * value, float & result);
|
||||
|
||||
}}
|
||||
|
||||
#endif // MAPNIK_UTIL_CONVERSIONS_HPP
|
||||
|
|
69
include/mapnik/util/dasharray_parser.hpp
Normal file
69
include/mapnik/util/dasharray_parser.hpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP
|
||||
#define MAPNIK_UTIL_DASHARRAY_PARSER_HPP
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
|
||||
namespace mapnik { namespace util {
|
||||
|
||||
template <typename Iterator>
|
||||
bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
|
||||
{
|
||||
using qi::double_;
|
||||
using qi::phrase_parse;
|
||||
using qi::_1;
|
||||
using qi::lit;
|
||||
using qi::char_;
|
||||
#if BOOST_VERSION > 104200
|
||||
using qi::no_skip;
|
||||
#else
|
||||
using qi::lexeme;
|
||||
#endif
|
||||
using phoenix::push_back;
|
||||
// SVG
|
||||
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
|
||||
// no support for 'percentage' as viewport is unknown at load_map
|
||||
//
|
||||
bool r = phrase_parse(first, last,
|
||||
(double_[push_back(phoenix::ref(dasharray), _1)] %
|
||||
#if BOOST_VERSION > 104200
|
||||
no_skip[char_(", ")]
|
||||
#else
|
||||
lexeme[char_(", ")]
|
||||
#endif
|
||||
| lit("none")),
|
||||
qi::ascii::space);
|
||||
|
||||
if (first != last)
|
||||
return false;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif // MAPNIK_UTIL_DASHARRAY_PARSER_HPP
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant.hpp>
|
||||
|
|
|
@ -23,6 +23,28 @@
|
|||
#ifndef MAPNIK_VERSION_HPP
|
||||
#define MAPNIK_VERSION_HPP
|
||||
|
||||
#define MAPNIK_VERSION 200000
|
||||
#define MAPNIK_VERSION_IS_RELEASE 0
|
||||
|
||||
#define MAPNIK_MAJOR_VERSION 2
|
||||
#define MAPNIK_MINOR_VERSION 1
|
||||
#define MAPNIK_PATCH_VERSION 0
|
||||
|
||||
#define MAPNIK_VERSION (MAPNIK_MAJOR_VERSION*100000) + (MAPNIK_MINOR_VERSION*100) + (MAPNIK_PATCH_VERSION)
|
||||
|
||||
#ifndef MAPNIK_STRINGIFY
|
||||
#define MAPNIK_STRINGIFY(n) MAPNIK_STRINGIFY_HELPER(n)
|
||||
#define MAPNIK_STRINGIFY_HELPER(n) #n
|
||||
#endif
|
||||
|
||||
#if MAPNIK_VERSION_IS_RELEASE
|
||||
# define MAPNIK_VERSION_STRING MAPNIK_STRINGIFY(MAPNIK_MAJOR_VERSION) "." \
|
||||
MAPNIK_STRINGIFY(MAPNIK_MINOR_VERSION) "." \
|
||||
MAPNIK_STRINGIFY(MAPNIK_PATCH_VERSION)
|
||||
|
||||
#else
|
||||
# define MAPNIK_VERSION_STRING MAPNIK_STRINGIFY(MAPNIK_MAJOR_VERSION) "." \
|
||||
MAPNIK_STRINGIFY(MAPNIK_MINOR_VERSION) "." \
|
||||
MAPNIK_STRINGIFY(MAPNIK_PATCH_VERSION) "-pre"
|
||||
#endif
|
||||
|
||||
#endif // MAPNIK_VERSION_HPP
|
||||
|
|
|
@ -55,16 +55,16 @@ public:
|
|||
// required for iterators support
|
||||
typedef boost::tuple<unsigned,coord_type,coord_type> value_type;
|
||||
typedef std::size_t size_type;
|
||||
|
||||
|
||||
private:
|
||||
unsigned num_blocks_;
|
||||
unsigned max_blocks_;
|
||||
coord_type** vertices_;
|
||||
unsigned char** commands_;
|
||||
size_type pos_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
vertex_vector()
|
||||
: num_blocks_(0),
|
||||
max_blocks_(0),
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
*y = (*vertex);
|
||||
return commands_[block] [pos & block_mask];
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void allocate_block(unsigned block)
|
||||
{
|
||||
|
|
|
@ -23,16 +23,14 @@
|
|||
#ifndef MAPNIK_LIBXML2_LOADER_HPP
|
||||
#define MAPNIK_LIBXML2_LOADER_HPP
|
||||
|
||||
// boost
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
void read_xml2( std::string const & filename, boost::property_tree::ptree & pt);
|
||||
void read_xml2_string( std::string const & str, boost::property_tree::ptree & pt, std::string const & base_path="");
|
||||
class xml_node;
|
||||
void read_xml(std::string const & filename, xml_node &node);
|
||||
void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
|
||||
}
|
||||
|
||||
#endif // MAPNIK_LIBXML2_LOADER_HPP
|
137
include/mapnik/xml_node.hpp
Normal file
137
include/mapnik/xml_node.hpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_XML_NODE_H
|
||||
#define MAPNIK_XML_NODE_H
|
||||
|
||||
//mapnik
|
||||
#include <mapnik/boolean.hpp>
|
||||
|
||||
|
||||
//boost
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
//stl
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class xml_tree;
|
||||
|
||||
class xml_attribute
|
||||
{
|
||||
public:
|
||||
xml_attribute(std::string const& value);
|
||||
std::string value;
|
||||
mutable bool processed;
|
||||
};
|
||||
|
||||
class node_not_found: public std::exception
|
||||
{
|
||||
public:
|
||||
node_not_found(std::string node_name);
|
||||
virtual const char* what() const throw();
|
||||
~node_not_found() throw ();
|
||||
private:
|
||||
std::string node_name_;
|
||||
};
|
||||
|
||||
class attribute_not_found: public std::exception
|
||||
{
|
||||
public:
|
||||
attribute_not_found(std::string const& node_name, std::string const& attribute_name);
|
||||
virtual const char* what() const throw();
|
||||
~attribute_not_found() throw ();
|
||||
private:
|
||||
std::string node_name_;
|
||||
std::string attribute_name_;
|
||||
};
|
||||
|
||||
class more_than_one_child: public std::exception
|
||||
{
|
||||
public:
|
||||
more_than_one_child(std::string const& node_name);
|
||||
virtual const char* what() const throw();
|
||||
~more_than_one_child() throw ();
|
||||
private:
|
||||
std::string node_name_;
|
||||
};
|
||||
|
||||
class xml_node
|
||||
{
|
||||
public:
|
||||
typedef std::list<xml_node>::const_iterator const_iterator;
|
||||
typedef std::map<std::string, xml_attribute> attribute_map;
|
||||
xml_node(xml_tree &tree, std::string name, unsigned line=0, bool text_node = false);
|
||||
|
||||
std::string const& name() const;
|
||||
std::string const& text() const;
|
||||
std::string const& filename() const;
|
||||
bool is_text() const;
|
||||
bool is(std::string const& name) const;
|
||||
|
||||
xml_node &add_child(std::string const& name, unsigned line=0, bool text_node = false);
|
||||
void add_attribute(std::string const& name, std::string const& value);
|
||||
attribute_map const& get_attributes() const;
|
||||
|
||||
bool processed() const;
|
||||
void set_processed(bool processed) const;
|
||||
|
||||
unsigned line() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
xml_node & get_child(std::string const& name);
|
||||
xml_node const& get_child(std::string const& name) const;
|
||||
xml_node const* get_opt_child(std::string const& name) const;
|
||||
bool has_child(std::string const& name) const;
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> get_opt_attr(std::string const& name) const;
|
||||
|
||||
template <typename T>
|
||||
T get_attr(std::string const& name, T const& default_value) const;
|
||||
template <typename T>
|
||||
T get_attr(std::string const& name) const;
|
||||
|
||||
std::string get_text() const;
|
||||
|
||||
template <typename T>
|
||||
T get_value() const;
|
||||
private:
|
||||
xml_tree &tree_;
|
||||
std::string name_;
|
||||
std::list<xml_node> children_;
|
||||
attribute_map attributes_;
|
||||
bool text_node_;
|
||||
unsigned line_;
|
||||
mutable bool processed_;
|
||||
static std::string xml_text;
|
||||
};
|
||||
|
||||
} //ns mapnik
|
||||
|
||||
#endif // MAPNIK_XML_NODE_H
|
62
include/mapnik/xml_tree.hpp
Normal file
62
include/mapnik/xml_tree.hpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_XML_TREE_H
|
||||
#define MAPNIK_XML_TREE_H
|
||||
//mapnik
|
||||
#include <mapnik/xml_node.hpp>
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#if BOOST_VERSION >= 104500
|
||||
#include <mapnik/css_color_grammar.hpp>
|
||||
#else
|
||||
#include <mapnik/css_color_grammar_deprecated.hpp>
|
||||
#endif
|
||||
|
||||
//stl
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class xml_tree
|
||||
{
|
||||
public:
|
||||
xml_tree(std::string const& encoding="utf8");
|
||||
void set_filename(std::string fn);
|
||||
std::string const& filename() const;
|
||||
xml_node &root();
|
||||
private:
|
||||
xml_node node_;
|
||||
std::string file_;
|
||||
transcoder tr_;
|
||||
public:
|
||||
mapnik::css_color_grammar<std::string::const_iterator> color_grammar;
|
||||
mapnik::expression_grammar<std::string::const_iterator> expr_grammar;
|
||||
};
|
||||
|
||||
} //ns mapnik
|
||||
|
||||
#endif // MAPNIK_XML_TREE_H
|
|
@ -6,6 +6,7 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
|
@ -14,7 +15,7 @@
|
|||
#include <mapnik/memory_featureset.hpp>
|
||||
#include <mapnik/wkt/wkt_factory.hpp>
|
||||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/ptree_helpers.hpp> // mapnik::boolean
|
||||
#include <mapnik/boolean.hpp>
|
||||
|
||||
// stl
|
||||
#include <sstream>
|
||||
|
@ -45,7 +46,8 @@ csv_datasource::csv_datasource(parameters const& params, bool bind)
|
|||
manual_headers_(boost::trim_copy(*params_.get<std::string>("headers", ""))),
|
||||
strict_(*params_.get<mapnik::boolean>("strict", false)),
|
||||
quiet_(*params_.get<mapnik::boolean>("quiet", false)),
|
||||
filesize_max_(*params_.get<float>("filesize_max", 20.0)) // MB
|
||||
filesize_max_(*params_.get<float>("filesize_max", 20.0)), // MB
|
||||
ctx_(boost::make_shared<mapnik::context_type>())
|
||||
{
|
||||
/* TODO:
|
||||
general:
|
||||
|
@ -391,7 +393,6 @@ void csv_datasource::parse_csv(T& stream,
|
|||
bool extent_initialized = false;
|
||||
std::size_t num_headers = headers_.size();
|
||||
|
||||
ctx_ = boost::make_shared<mapnik::context_type>();
|
||||
for (std::size_t i = 0; i < headers_.size(); ++i)
|
||||
{
|
||||
ctx_->push(headers_[i]);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "gdal_featureset.hpp"
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
|
||||
#include <gdal_version.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <cstdarg>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
|
||||
// boost
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <cstdio>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "occi_featureset.hpp"
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
|
||||
// boost
|
||||
|
|
|
@ -373,7 +373,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
|||
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
||||
{
|
||||
geometry_type* geom = new geometry_type(geom_type);
|
||||
|
||||
|
||||
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
||||
{
|
||||
int next_offset = elem_info[i];
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <gdal_version.h>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
|
||||
// boost
|
||||
|
|
|
@ -52,6 +52,7 @@ DATASOURCE_PLUGIN(osm_datasource)
|
|||
|
||||
osm_datasource::osm_datasource(const parameters& params, bool bind)
|
||||
: datasource (params),
|
||||
extent_(),
|
||||
type_(datasource::Vector),
|
||||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8"))
|
||||
{
|
||||
|
@ -71,13 +72,11 @@ void osm_datasource::bind() const
|
|||
std::string url = *params_.get<std::string>("url", "");
|
||||
std::string bbox = *params_.get<std::string>("bbox", "");
|
||||
|
||||
bool do_process = false;
|
||||
|
||||
// load the data
|
||||
// if we supplied a filename, load from file
|
||||
if (url != "" && bbox != "")
|
||||
{
|
||||
// otherwise if we supplied a url and a bounding box, load from the url
|
||||
// if we supplied a url and a bounding box, load from the url
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "Osm Plugin: loading_from_url: url=" << url << " bbox=" << bbox << std::endl;
|
||||
#endif
|
||||
|
@ -85,44 +84,40 @@ void osm_datasource::bind() const
|
|||
{
|
||||
throw datasource_exception("Error loading from URL");
|
||||
}
|
||||
|
||||
do_process = true;
|
||||
}
|
||||
else if (osm_filename != "")
|
||||
{
|
||||
if ((osm_data_= dataset_deliverer::load_from_file(osm_filename, parser)) == NULL)
|
||||
// if we supplied a filename, load from file
|
||||
if ((osm_data_ = dataset_deliverer::load_from_file(osm_filename, parser)) == NULL)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "OSM Plugin: Error loading from file '" << osm_filename << "'";
|
||||
throw datasource_exception(s.str());
|
||||
}
|
||||
|
||||
do_process = true;
|
||||
} else {
|
||||
throw datasource_exception("OSM Plugin: Neither 'file' nor 'url' and 'bbox' specified");
|
||||
}
|
||||
|
||||
if (do_process == true)
|
||||
|
||||
osm_tag_types tagtypes;
|
||||
tagtypes.add_type("maxspeed", mapnik::Integer);
|
||||
tagtypes.add_type("z_order", mapnik::Integer);
|
||||
|
||||
osm_data_->rewind();
|
||||
|
||||
// Need code to get the attributes of all the data
|
||||
std::set<std::string> keys = osm_data_->get_keys();
|
||||
|
||||
// Add the attributes to the datasource descriptor - assume they are
|
||||
// all of type String
|
||||
for (std::set<std::string>::iterator i = keys.begin(); i != keys.end(); i++)
|
||||
{
|
||||
osm_tag_types tagtypes;
|
||||
tagtypes.add_type("maxspeed", mapnik::Integer);
|
||||
tagtypes.add_type("z_order", mapnik::Integer);
|
||||
|
||||
osm_data_->rewind();
|
||||
|
||||
// Need code to get the attributes of all the data
|
||||
std::set<std::string> keys = osm_data_->get_keys();
|
||||
|
||||
// Add the attributes to the datasource descriptor - assume they are
|
||||
// all of type String
|
||||
for (std::set<std::string>::iterator i = keys.begin(); i != keys.end(); i++)
|
||||
{
|
||||
desc_.add_descriptor(attribute_descriptor(*i, tagtypes.get_type(*i)));
|
||||
}
|
||||
|
||||
// Get the bounds of the data and set extent_ accordingly
|
||||
bounds b = osm_data_->get_bounds();
|
||||
extent_ = box2d<double>(b.w, b.s, b.e, b.n);
|
||||
desc_.add_descriptor(attribute_descriptor(*i, tagtypes.get_type(*i)));
|
||||
}
|
||||
|
||||
// Get the bounds of the data and set extent_ accordingly
|
||||
bounds b = osm_data_->get_bounds();
|
||||
extent_ = box2d<double>(b.w, b.s, b.e, b.n);
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
|
@ -149,7 +144,7 @@ layer_descriptor osm_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr osm_datasource::features(const query& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
if (!is_bound_) bind();
|
||||
|
||||
filter_in_box filter(q.get_bbox());
|
||||
// so we need to filter osm features by bbox here...
|
||||
|
@ -162,7 +157,7 @@ featureset_ptr osm_datasource::features(const query& q) const
|
|||
|
||||
featureset_ptr osm_datasource::features_at_point(coord2d const& pt) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
if (!is_bound_) bind();
|
||||
|
||||
filter_at_point filter(pt);
|
||||
// collect all attribute names
|
||||
|
@ -185,8 +180,7 @@ featureset_ptr osm_datasource::features_at_point(coord2d const& pt) const
|
|||
|
||||
box2d<double> osm_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
if (!is_bound_) bind();
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -194,4 +188,4 @@ boost::optional<mapnik::datasource::geometry_t> osm_datasource::get_geometry_typ
|
|||
{
|
||||
if (! is_bound_) bind();
|
||||
return boost::optional<mapnik::datasource::geometry_t>(mapnik::datasource::Collection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,11 @@ void osmparser::startElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||
xmlFree(xk);
|
||||
xmlFree(xv);
|
||||
}
|
||||
if (xmlTextReaderIsEmptyElement(reader))
|
||||
{
|
||||
// Fake endElement for empty nodes
|
||||
endElement(name);
|
||||
}
|
||||
}
|
||||
|
||||
void osmparser::endElement(const xmlChar* name)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
|
@ -175,7 +175,7 @@ void postgis_datasource::bind() const
|
|||
if (srid_c != NULL)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::conversions::string2int(srid_c,result))
|
||||
if (mapnik::util::string2int(srid_c,result))
|
||||
srid_ = result;
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void postgis_datasource::bind() const
|
|||
if (srid_c != NULL)
|
||||
{
|
||||
int result;
|
||||
if (mapnik::conversions::string2int(srid_c,result))
|
||||
if (mapnik::util::string2int(srid_c,result))
|
||||
srid_ = result;
|
||||
}
|
||||
}
|
||||
|
@ -681,22 +681,22 @@ box2d<double> postgis_datasource::envelope() const
|
|||
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
|
||||
if (rs->next() && !rs->isNull(0))
|
||||
{
|
||||
double lox;
|
||||
double loy;
|
||||
double hix;
|
||||
double hiy;
|
||||
if (mapnik::conversions::string2double(rs->getValue(0),lox) &&
|
||||
mapnik::conversions::string2double(rs->getValue(1),loy) &&
|
||||
mapnik::conversions::string2double(rs->getValue(2),hix) &&
|
||||
mapnik::conversions::string2double(rs->getValue(3),hiy))
|
||||
{
|
||||
extent_.init(lox,loy,hix,hiy);
|
||||
extent_initialized_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::clog << boost::format("Postgis Plugin: warning: could not determine extent from query: %s\n") % s.str() << std::endl;
|
||||
}
|
||||
double lox;
|
||||
double loy;
|
||||
double hix;
|
||||
double hiy;
|
||||
if (mapnik::util::string2double(rs->getValue(0),lox) &&
|
||||
mapnik::util::string2double(rs->getValue(1),loy) &&
|
||||
mapnik::util::string2double(rs->getValue(2),hix) &&
|
||||
mapnik::util::string2double(rs->getValue(3),hiy))
|
||||
{
|
||||
extent_.init(lox,loy,hix,hiy);
|
||||
extent_initialized_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::clog << boost::format("Postgis Plugin: warning: could not determine extent from query: %s\n") % s.str() << std::endl;
|
||||
}
|
||||
}
|
||||
rs->close();
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ feature_ptr postgis_featureset::next()
|
|||
{
|
||||
std::string str = mapnik::sql_utils::numeric2string(buf);
|
||||
double val;
|
||||
if (mapnik::conversions::string2double(str,val))
|
||||
if (mapnik::util::string2double(str,val))
|
||||
feature->put(name,val);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -48,9 +48,9 @@ raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
|
|||
extent_(extent),
|
||||
bbox_(q.get_bbox()),
|
||||
curIter_(policy_.begin()),
|
||||
endIter_(policy_.end())
|
||||
endIter_(policy_.end()),
|
||||
ctx_(boost::make_shared<mapnik::context_type>())
|
||||
{
|
||||
ctx_ = boost::make_shared<mapnik::context_type>();
|
||||
}
|
||||
|
||||
template <typename LookupPolicy>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <boost/make_shared.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
|
||||
using mapnik::datasource;
|
||||
|
|
|
@ -127,7 +127,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
|
|||
|
||||
if (col>=0 && col<num_fields_)
|
||||
{
|
||||
std::string name=fields_[col].name_;
|
||||
std::string const& name=fields_[col].name_;
|
||||
|
||||
switch (fields_[col].type_)
|
||||
{
|
||||
|
|
|
@ -44,15 +44,15 @@ shape_index_featureset<filterT>::shape_index_featureset(filterT const& filter,
|
|||
std::string const& shape_name,
|
||||
int row_limit)
|
||||
: filter_(filter),
|
||||
ctx_(boost::make_shared<mapnik::context_type>()),
|
||||
shape_(shape),
|
||||
tr_(new transcoder(encoding)),
|
||||
row_limit_(row_limit),
|
||||
count_(0)
|
||||
{
|
||||
ctx_ = boost::make_shared<mapnik::context_type>();
|
||||
shape_.shp().skip(100);
|
||||
setup_attributes(ctx_, attribute_names, shape_name, shape_,attr_ids_);
|
||||
|
||||
|
||||
boost::shared_ptr<shape_file> index = shape_.index();
|
||||
if (index)
|
||||
{
|
||||
|
|
|
@ -103,12 +103,12 @@ void shape_io::read_polyline(mapnik::geometry_container & geom)
|
|||
{
|
||||
shape_file::record_type record(reclength_ * 2 - 36);
|
||||
shp_.read_record(record);
|
||||
|
||||
|
||||
int num_parts = record.read_ndr_integer();
|
||||
int num_points = record.read_ndr_integer();
|
||||
if (num_parts == 1)
|
||||
{
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
record.skip(4);
|
||||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
|
@ -132,7 +132,7 @@ void shape_io::read_polyline(mapnik::geometry_container & geom)
|
|||
int start, end;
|
||||
for (int k = 0; k < num_parts; ++k)
|
||||
{
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
start = parts[k];
|
||||
if (k == num_parts - 1)
|
||||
{
|
||||
|
@ -179,11 +179,11 @@ void shape_io::read_polygon(mapnik::geometry_container & geom)
|
|||
{
|
||||
shape_file::record_type record(reclength_ * 2 - 36);
|
||||
shp_.read_record(record);
|
||||
|
||||
|
||||
int num_parts = record.read_ndr_integer();
|
||||
int num_points = record.read_ndr_integer();
|
||||
std::vector<int> parts(num_parts);
|
||||
|
||||
|
||||
for (int i = 0; i < num_parts; ++i)
|
||||
{
|
||||
parts[i] = record.read_ndr_integer();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "sqlite_utils.hpp"
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/wkb.hpp>
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/font_set.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
|
@ -201,16 +201,18 @@ void agg_renderer<T>::end_map_processing(Map const& )
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void agg_renderer<T>::start_layer_processing(layer const& lay)
|
||||
void agg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> const& query_extent)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "start layer processing : " << lay.name() << "\n";
|
||||
std::clog << "datasource = " << lay.datasource().get() << "\n";
|
||||
std::clog << "query_extent = " << query_extent << "\n";
|
||||
#endif
|
||||
if (lay.clear_label_cache())
|
||||
{
|
||||
detector_->clear();
|
||||
}
|
||||
query_extent_ = query_extent;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -246,7 +248,7 @@ void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& mar
|
|||
mtx *= agg::trans_affine_scaling(scale_factor_);
|
||||
// render the marker at the center of the marker box
|
||||
mtx.translate(pos.x+0.5 * marker.width(), pos.y+0.5 * marker.height());
|
||||
|
||||
using namespace mapnik::svg;
|
||||
vertex_stl_adapter<svg_path_storage> stl_storage((*marker.get_vector_data())->source());
|
||||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_renderer<svg_path_adapter,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/agg_pattern_source.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/line_pattern_symbolizer.hpp>
|
||||
|
||||
|
@ -42,6 +43,7 @@
|
|||
#include "agg_span_allocator.h"
|
||||
#include "agg_span_pattern_rgba.h"
|
||||
#include "agg_renderer_outline_image.h"
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -50,7 +52,8 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> renderer_base;
|
||||
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
|
||||
|
@ -74,6 +77,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
|
||||
if (!pat) return;
|
||||
|
||||
box2d<double> ext = query_extent_ * 1.1;
|
||||
renderer_base ren_base(pixf);
|
||||
agg::pattern_filter_bilinear_rgba8 filter;
|
||||
pattern_source source(*(*pat));
|
||||
|
@ -82,15 +86,17 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
// TODO - should be sensitive to buffer size
|
||||
ren.clip_box(0,0,width_,height_);
|
||||
rasterizer_type ras(ren);
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras.add_path(path);
|
||||
if (writer.first) writer.first->add_line(path, *feature, t_, writer.second);
|
||||
//if (writer.first) writer.first->add_line(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
|
||||
|
@ -38,8 +39,8 @@
|
|||
#include "agg_conv_dash.h"
|
||||
#include "agg_renderer_outline_aa.h"
|
||||
#include "agg_rasterizer_outline_aa.h"
|
||||
|
||||
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
#include "agg_conv_smooth_poly1.h"
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
|
@ -51,7 +52,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
|
||||
stroke const& stroke_ = sym.get_stroke();
|
||||
color const& col = stroke_.get_color();
|
||||
|
@ -63,13 +63,15 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4);
|
||||
agg::pixfmt_rgba32_plain pixf(buf);
|
||||
|
||||
box2d<double> ext = query_extent_ * 1.1;
|
||||
if (sym.get_rasterizer() == RASTERIZER_FAST)
|
||||
{
|
||||
typedef agg::renderer_outline_aa<ren_base> renderer_type;
|
||||
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
agg::line_profile_aa profile;
|
||||
//agg::line_profile_aa profile(stroke_.get_width() * scale_factor_, agg::gamma_none());
|
||||
profile.width(stroke_.get_width() * scale_factor_);
|
||||
ren_base base_ren(pixf);
|
||||
renderer_type ren(base_ren, profile);
|
||||
|
@ -81,10 +83,12 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras.add_path(path);
|
||||
}
|
||||
}
|
||||
|
@ -98,97 +102,98 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
ras_ptr->reset();
|
||||
switch (stroke_.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
}
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
set_gamma_method(stroke_, ras_ptr);
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
|
||||
if (stroke_.has_dash())
|
||||
{
|
||||
agg::conv_dash<path_type> dash(path);
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
dash_array::const_iterator end = d.end();
|
||||
for (;itr != end;++itr)
|
||||
if (sym.smooth() > 0.0)
|
||||
{
|
||||
dash.add_dash(itr->first * scale_factor_,
|
||||
itr->second * scale_factor_);
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
smooth_type smooth(path);
|
||||
smooth.smooth_value(sym.smooth());
|
||||
agg::conv_dash<smooth_type> dash(smooth);
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
dash_array::const_iterator end = d.end();
|
||||
for (;itr != end;++itr)
|
||||
{
|
||||
dash.add_dash(itr->first * scale_factor_,
|
||||
itr->second * scale_factor_);
|
||||
}
|
||||
agg::conv_stroke<agg::conv_dash<smooth_type > > stroke(dash);
|
||||
set_join_caps(stroke_,stroke);
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
}
|
||||
|
||||
agg::conv_stroke<agg::conv_dash<path_type > > stroke(dash);
|
||||
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
if ( join == MITER_JOIN)
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
else if( join == MITER_REVERT_JOIN)
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
else if( join == ROUND_JOIN)
|
||||
stroke.generator().line_join(agg::round_join);
|
||||
else
|
||||
stroke.generator().line_join(agg::bevel_join);
|
||||
|
||||
line_cap_e cap=stroke_.get_line_cap();
|
||||
if (cap == BUTT_CAP)
|
||||
stroke.generator().line_cap(agg::butt_cap);
|
||||
else if (cap == SQUARE_CAP)
|
||||
stroke.generator().line_cap(agg::square_cap);
|
||||
else
|
||||
stroke.generator().line_cap(agg::round_cap);
|
||||
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
{
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
agg::conv_dash<path_type> dash(path);
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
dash_array::const_iterator end = d.end();
|
||||
for (;itr != end;++itr)
|
||||
{
|
||||
dash.add_dash(itr->first * scale_factor_,
|
||||
itr->second * scale_factor_);
|
||||
}
|
||||
agg::conv_stroke<agg::conv_dash<path_type > > stroke(dash);
|
||||
set_join_caps(stroke_,stroke);
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
agg::conv_stroke<path_type> stroke(path);
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
if ( join == MITER_JOIN)
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
else if( join == MITER_REVERT_JOIN)
|
||||
stroke.generator().line_join(agg::miter_join);
|
||||
else if( join == ROUND_JOIN)
|
||||
stroke.generator().line_join(agg::round_join);
|
||||
if (sym.smooth() > 0.0)
|
||||
{
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
smooth_type smooth(path);
|
||||
smooth.smooth_value(sym.smooth());
|
||||
agg::conv_stroke<smooth_type> stroke(smooth);
|
||||
set_join_caps(stroke_,stroke);
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
}
|
||||
else
|
||||
stroke.generator().line_join(agg::bevel_join);
|
||||
|
||||
line_cap_e cap=stroke_.get_line_cap();
|
||||
if (cap == BUTT_CAP)
|
||||
stroke.generator().line_cap(agg::butt_cap);
|
||||
else if (cap == SQUARE_CAP)
|
||||
stroke.generator().line_cap(agg::square_cap);
|
||||
else
|
||||
stroke.generator().line_cap(agg::round_cap);
|
||||
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
if (writer.first) writer.first->add_line(path, *feature, t_, writer.second);
|
||||
{
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
agg::conv_stroke<path_type> stroke(path);
|
||||
set_join_caps(stroke_,stroke);
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
}
|
||||
//if (writer.first) writer.first->add_line(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/svg/svg_renderer.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
@ -41,7 +42,7 @@
|
|||
#include "agg_path_storage.h"
|
||||
#include "agg_ellipse.h"
|
||||
#include "agg_conv_stroke.h"
|
||||
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -50,7 +51,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
typedef agg::pixfmt_rgba32_plain pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
||||
|
@ -104,7 +107,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
|
||||
for (unsigned i=0; i<feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
// TODO - merge this code with point_symbolizer rendering
|
||||
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
|
||||
{
|
||||
|
@ -131,7 +134,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
}
|
||||
else
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
markers_placement<path_type, label_collision_detector4> placement(path, extent, *detector_,
|
||||
sym.get_spacing() * scale_factor_,
|
||||
sym.get_max_error(),
|
||||
|
@ -166,6 +171,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
unsigned s_a=col.alpha();
|
||||
double w = sym.get_width();
|
||||
double h = sym.get_height();
|
||||
double rx = w/2.0;
|
||||
double ry = h/2.0;
|
||||
|
||||
arrow arrow_;
|
||||
box2d<double> extent;
|
||||
|
@ -206,7 +213,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
|
||||
for (unsigned i=0; i<feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
//if (geom.num_points() <= 1) continue;
|
||||
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
|
||||
{
|
||||
|
@ -220,7 +227,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
if (sym.get_allow_overlap() ||
|
||||
detector_->has_placement(label_ext))
|
||||
{
|
||||
agg::ellipse c(x, y, w, h);
|
||||
agg::ellipse c(x, y, rx, ry);
|
||||
marker.concat_path(c);
|
||||
ras_ptr->add_path(marker);
|
||||
ren.color(agg::rgba8(r, g, b, int(a*sym.get_opacity())));
|
||||
|
@ -239,7 +246,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
ren.color(agg::rgba8(s_r, s_g, s_b, int(s_a*stroke_.get_opacity())));
|
||||
agg::render_scanlines(*ras_ptr, sl_line, ren);
|
||||
}
|
||||
detector_->insert(label_ext);
|
||||
if (!sym.get_ignore_placement())
|
||||
detector_->insert(label_ext);
|
||||
if (writer.first) writer.first->add_box(label_ext, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +257,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
if (marker_type == ARROW)
|
||||
marker.concat_path(arrow_);
|
||||
|
||||
path_type path(t_,geom,prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
markers_placement<path_type, label_collision_detector4> placement(path, extent, *detector_,
|
||||
sym.get_spacing() * scale_factor_,
|
||||
sym.get_max_error(),
|
||||
|
@ -263,7 +273,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
if (marker_type == ELLIPSE)
|
||||
{
|
||||
// todo proper bbox - this is buggy
|
||||
agg::ellipse c(x_t, y_t, w, h);
|
||||
agg::ellipse c(x_t, y_t, rx, ry);
|
||||
marker.concat_path(c);
|
||||
agg::trans_affine matrix;
|
||||
matrix *= agg::trans_affine_translation(-x_t,-y_t);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/metawriter.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
|
||||
|
@ -38,8 +40,7 @@
|
|||
#include "agg_span_allocator.h"
|
||||
#include "agg_span_pattern_rgba.h"
|
||||
#include "agg_image_accessors.h"
|
||||
|
||||
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -48,7 +49,8 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef agg::wrap_mode_repeat wrap_x_type;
|
||||
typedef agg::wrap_mode_repeat wrap_y_type;
|
||||
|
@ -71,26 +73,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
agg::scanline_u8 sl;
|
||||
ras_ptr->reset();
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
set_gamma_method(sym,ras_ptr);
|
||||
|
||||
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);
|
||||
boost::optional<mapnik::marker_ptr> marker;
|
||||
|
@ -133,9 +116,11 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
if (align == LOCAL_ALIGNMENT)
|
||||
{
|
||||
double x0=0,y0=0;
|
||||
if (num_geometries>0)
|
||||
if (num_geometries>0) // FIXME: hmm...?
|
||||
{
|
||||
path_type path(t_,feature->get_geometry(0),prj_trans);
|
||||
clipped_geometry_type clipped(feature->get_geometry(0));
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
path.vertex(&x0,&y0);
|
||||
}
|
||||
offset_x = unsigned(width_-x0);
|
||||
|
@ -144,15 +129,17 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
span_gen_type sg(img_src, offset_x, offset_y);
|
||||
renderer_type rp(renb,sa, sg);
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<num_geometries;++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 2)
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
//if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
agg::render_scanlines(*ras_ptr, sl, rp);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/polygon_symbolizer.hpp>
|
||||
|
||||
|
@ -34,7 +35,8 @@
|
|||
#include "agg_scanline_u.h"
|
||||
// for polygon_symbolizer
|
||||
#include "agg_renderer_scanline.h"
|
||||
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
#include "agg_conv_smooth_poly1.h"
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
|
@ -45,7 +47,6 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
|
@ -60,40 +61,42 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
unsigned g=fill_.green();
|
||||
unsigned b=fill_.blue();
|
||||
unsigned a=fill_.alpha();
|
||||
renb.clip_box(0,0,width_,height_);
|
||||
//renb.clip_box(0,0,width_,height_);
|
||||
renderer ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
ras_ptr->reset();
|
||||
|
||||
set_gamma_method(sym,ras_ptr);
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
box2d<double> inflated_extent = query_extent_ * 1.1;
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
{
|
||||
geometry_type const& geom=feature->get_geometry(i);
|
||||
geometry_type & geom=feature->get_geometry(i);
|
||||
if (geom.num_points() > 2)
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
if (sym.smooth() > 0.0)
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
smooth_type smooth(path);
|
||||
smooth.smooth_value(sym.smooth());
|
||||
ras_ptr->add_path(smooth);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
}
|
||||
//if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
|
||||
|
|
|
@ -46,7 +46,7 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
|
|||
sym, *feature, prj_trans,
|
||||
width_, height_,
|
||||
scale_factor_,
|
||||
t_, font_manager_, *detector_);
|
||||
t_, font_manager_, *detector_, query_extent_);
|
||||
|
||||
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
|
|||
sym, *feature, prj_trans,
|
||||
width_, height_,
|
||||
scale_factor_,
|
||||
t_, font_manager_, *detector_);
|
||||
t_, font_manager_, *detector_, query_extent_);
|
||||
|
||||
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));
|
||||
|
||||
|
|
20
src/build.py
20
src/build.py
|
@ -73,6 +73,7 @@ if env['THREADING'] == 'multi':
|
|||
if env['RUNTIME_LINK'] == 'static':
|
||||
if 'icuuc' in env['ICU_LIB_NAME']:
|
||||
lib_env['LIBS'].append('icudata')
|
||||
lib_env['LIBS'].append('icui18n')
|
||||
else:
|
||||
if env['INTERNAL_LIBAGG']:
|
||||
lib_env['LIBS'].insert(0, 'agg')
|
||||
|
@ -83,7 +84,7 @@ else:
|
|||
if env['PLATFORM'] == 'Darwin':
|
||||
mapnik_libname = 'libmapnik.dylib'
|
||||
else:
|
||||
mapnik_libname = 'libmapnik.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1]))
|
||||
mapnik_libname = 'libmapnik.so.' + ("%d.%d" % (int(ABI_VERSION[0]),int(ABI_VERSION[1])))
|
||||
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
if env['FULL_LIB_PATH']:
|
||||
|
@ -91,7 +92,7 @@ if env['PLATFORM'] == 'Darwin':
|
|||
else:
|
||||
lib_path = mapnik_libname
|
||||
mapnik_lib_link_flag += ' -Wl,-install_name,%s' % lib_path
|
||||
_d = {'version':env['MAPNIK_VERSION_STRING']}
|
||||
_d = {'version':env['MAPNIK_VERSION_STRING'].replace('-pre','')}
|
||||
mapnik_lib_link_flag += ' -current_version %(version)s -compatibility_version %(version)s' % _d
|
||||
elif env['PLATFORM'] == 'SunOS':
|
||||
if env['CXX'].startswith('CC'):
|
||||
|
@ -105,6 +106,7 @@ source = Split(
|
|||
"""
|
||||
color.cpp
|
||||
conversions.cpp
|
||||
image_compositing.cpp
|
||||
box2d.cpp
|
||||
building_symbolizer.cpp
|
||||
datasource_cache.cpp
|
||||
|
@ -178,6 +180,8 @@ source = Split(
|
|||
text_placements/list.cpp
|
||||
text_placements/simple.cpp
|
||||
text_properties.cpp
|
||||
xml_tree.cpp
|
||||
config_error.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
|
@ -299,7 +303,7 @@ if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
|
|||
env2 = lib_env.Clone()
|
||||
env2.Append(CXXFLAGS = '-DHAVE_LIBXML2')
|
||||
libmapnik_cxxflags.append('-DHAVE_LIBXML2')
|
||||
fixup = ['load_map.cpp','libxml2_loader.cpp']
|
||||
fixup = ['libxml2_loader.cpp']
|
||||
for cpp in fixup:
|
||||
if cpp in source:
|
||||
source.remove(cpp)
|
||||
|
@ -307,6 +311,12 @@ if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
|
|||
source.insert(0,env2.StaticObject(cpp))
|
||||
else:
|
||||
source.insert(0,env2.SharedObject(cpp))
|
||||
else:
|
||||
source += Split(
|
||||
"""
|
||||
rapidxml_loader.cpp
|
||||
"""
|
||||
)
|
||||
|
||||
if env['CUSTOM_LDFLAGS']:
|
||||
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag)
|
||||
|
@ -334,7 +344,7 @@ if env['PLATFORM'] != 'Darwin':
|
|||
|
||||
major, minor, micro = ABI_VERSION
|
||||
|
||||
soFile = "%s.%d.%d.%d" % (os.path.basename(str(mapnik[0])), major, minor, micro)
|
||||
soFile = "%s.%d.%d.%d" % (os.path.basename(str(mapnik[0])), int(major), int(minor), int(micro))
|
||||
target = os.path.join(env['MAPNIK_LIB_BASE_DEST'], soFile)
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
|
@ -345,7 +355,7 @@ if env['PLATFORM'] != 'Darwin':
|
|||
|
||||
|
||||
# Install symlinks
|
||||
target1 = os.path.join(env['MAPNIK_LIB_BASE_DEST'], "%s.%d.%d" % (os.path.basename(str(mapnik[0])),major, minor))
|
||||
target1 = os.path.join(env['MAPNIK_LIB_BASE_DEST'], "%s.%d.%d" % (os.path.basename(str(mapnik[0])),int(major), int(minor)))
|
||||
target2 = os.path.join(env['MAPNIK_LIB_BASE_DEST'], os.path.basename(str(mapnik[0])))
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
if 'install' in COMMAND_LINE_TARGETS:
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/markers_placement.hpp>
|
||||
#include <mapnik/arrow.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
|
@ -50,6 +50,11 @@
|
|||
#include <boost/utility.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
#include "agg_conv_smooth_poly1.h"
|
||||
|
||||
// stl
|
||||
#ifdef MAPNIK_DEBUG
|
||||
#include <iostream>
|
||||
|
@ -249,8 +254,7 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face)
|
|||
}
|
||||
else
|
||||
{
|
||||
entry = cairo_face_ptr(new cairo_face(font_engine_, face));
|
||||
|
||||
entry = boost::make_shared<cairo_face>(font_engine_, face);
|
||||
cache_.insert(std::make_pair(face, entry));
|
||||
}
|
||||
|
||||
|
@ -628,7 +632,7 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Cont
|
|||
: m_(m),
|
||||
context_(context),
|
||||
t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y),
|
||||
font_engine_(new freetype_engine()),
|
||||
font_engine_(boost::make_shared<freetype_engine>()),
|
||||
font_manager_(*font_engine_),
|
||||
face_manager_(font_engine_,font_manager_),
|
||||
detector_(box2d<double>(-m.buffer_size() ,-m.buffer_size() , m.width() + m.buffer_size() ,m.height() + m.buffer_size()))
|
||||
|
@ -696,16 +700,18 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
context_->show_page();
|
||||
}
|
||||
|
||||
void cairo_renderer_base::start_layer_processing(layer const& lay)
|
||||
void cairo_renderer_base::start_layer_processing(layer const& lay, box2d<double> const& query_extent)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "start layer processing : " << lay.name() << "\n";
|
||||
std::clog << "datasource = " << lay.datasource().get() << "\n";
|
||||
std::clog << "query_extent = " << query_extent << "\n";
|
||||
#endif
|
||||
if (lay.clear_label_cache())
|
||||
{
|
||||
detector_.clear();
|
||||
}
|
||||
query_extent_ = query_extent;
|
||||
}
|
||||
|
||||
void cairo_renderer_base::end_layer_processing(layer const&)
|
||||
|
@ -719,24 +725,40 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
|
||||
cairo_context context(context_);
|
||||
|
||||
context.set_color(sym.get_fill(), sym.get_opacity());
|
||||
|
||||
box2d<double> inflated_extent = query_extent_ * 1.1;
|
||||
for (unsigned i = 0; i < feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 2)
|
||||
{
|
||||
path_type path(t_, geom, prj_trans);
|
||||
|
||||
context.add_path(path);
|
||||
context.fill();
|
||||
if (sym.smooth() > 0.0)
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
smooth_type smooth(path);
|
||||
smooth.smooth_value(sym.smooth());
|
||||
context.add_agg_path(smooth);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
context.add_path(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
// fill polygon
|
||||
context.fill();
|
||||
}
|
||||
|
||||
void cairo_renderer_base::process(building_symbolizer const& sym,
|
||||
|
@ -853,35 +875,36 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
cairo_context context(context_);
|
||||
mapnik::stroke const& stroke_ = sym.get_stroke();
|
||||
|
||||
cairo_context context(context_);
|
||||
context.set_color(stroke_.get_color(), stroke_.get_opacity());
|
||||
context.set_line_join(stroke_.get_line_join());
|
||||
context.set_line_cap(stroke_.get_line_cap());
|
||||
context.set_miter_limit(4.0);
|
||||
context.set_line_width(stroke_.get_width());
|
||||
if (stroke_.has_dash())
|
||||
{
|
||||
context.set_dash(stroke_.get_dash_array());
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
cairo_context context(context_);
|
||||
path_type path(t_, geom, prj_trans);
|
||||
//cairo_context context(context_);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
if (stroke_.has_dash())
|
||||
{
|
||||
context.set_dash(stroke_.get_dash_array());
|
||||
}
|
||||
|
||||
context.set_line_join(stroke_.get_line_join());
|
||||
context.set_line_cap(stroke_.get_line_cap());
|
||||
context.set_miter_limit(4.0);
|
||||
context.set_line_width(stroke_.get_width());
|
||||
context.add_path(path);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
void cairo_renderer_base::render_marker(pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity)
|
||||
|
@ -903,7 +926,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
mapnik::path_ptr vmarker = *marker.get_vector_data();
|
||||
|
||||
using namespace mapnik::svg;
|
||||
agg::pod_bvector<path_attributes> const & attributes_ = vmarker->attributes();
|
||||
for(unsigned i = 0; i < attributes_.size(); ++i)
|
||||
{
|
||||
|
@ -1054,8 +1077,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
sym, *feature, prj_trans,
|
||||
detector_.extent().width(), detector_.extent().height(),
|
||||
1.0 /*scale_factor*/,
|
||||
t_, font_manager_, detector_);
|
||||
|
||||
t_, font_manager_, detector_, query_extent_);
|
||||
cairo_context context(context_);
|
||||
|
||||
while (helper.next()) {
|
||||
|
@ -1075,7 +1097,8 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);
|
||||
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true);
|
||||
|
@ -1093,11 +1116,14 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
|
||||
for (unsigned i = 0; i < feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
path_type path(t_, geom, prj_trans);
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
double length(0);
|
||||
double x0(0), y0(0);
|
||||
double x, y;
|
||||
|
@ -1144,7 +1170,8 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform2<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
cairo_context context(context_);
|
||||
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);
|
||||
|
@ -1159,12 +1186,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
|
||||
for (unsigned i = 0; i < feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
|
||||
if (geom.num_points() > 2)
|
||||
{
|
||||
path_type path(t_, geom, prj_trans);
|
||||
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
context.add_path(path);
|
||||
context.fill();
|
||||
}
|
||||
|
@ -1229,10 +1257,11 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
|
||||
for (unsigned i = 0; i < feature->num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature->get_geometry(i);
|
||||
geometry_type & geom = feature->get_geometry(i);
|
||||
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
|
||||
path_type path(t_, geom, prj_trans);
|
||||
|
||||
markers_placement<path_type, label_collision_detector4> placement(path, arrow_.extent(), detector_, sym.get_spacing(), sym.get_max_error(), sym.get_allow_overlap());
|
||||
|
@ -1252,7 +1281,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
text_symbolizer_helper<face_manager<freetype_engine>, label_collision_detector4> helper(sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_);
|
||||
text_symbolizer_helper<face_manager<freetype_engine>, label_collision_detector4> helper(sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_, query_extent_);
|
||||
|
||||
cairo_context context(context_);
|
||||
|
||||
|
|
|
@ -25,11 +25,23 @@
|
|||
// mapnik
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/color_factory.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
// stl
|
||||
#include <sstream>
|
||||
|
||||
// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
|
||||
#if BOOST_VERSION >= 104500
|
||||
#include <mapnik/css_color_grammar.hpp>
|
||||
#else
|
||||
#include <mapnik/css_color_grammar_deprecated.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
color::color( std::string const& css_string)
|
||||
|
@ -81,5 +93,90 @@ std::string color::to_hex_string() const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
void color_factory::init_from_string(color & c, std::string const& css_color)
|
||||
{
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
|
||||
|
||||
css_color_grammar g;
|
||||
iterator_type first = css_color.begin();
|
||||
iterator_type last = css_color.end();
|
||||
// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
|
||||
#if BOOST_VERSION >= 104500
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
c);
|
||||
if (!result)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse color value: ") +
|
||||
"Expected a CSS color, but got '" + css_color + "'");
|
||||
}
|
||||
#else
|
||||
mapnik::css css_;
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
css_);
|
||||
if (!result)
|
||||
{
|
||||
throw config_error(std::string("Failed to parse color value: ") +
|
||||
"Expected a CSS color, but got '" + css_color + "'");
|
||||
}
|
||||
c.set_red(css_.r);
|
||||
c.set_green(css_.g);
|
||||
c.set_blue(css_.b);
|
||||
c.set_alpha(css_.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool color_factory::parse_from_string(color & c, std::string const& css_color,
|
||||
mapnik::css_color_grammar<std::string::const_iterator> const& g)
|
||||
{
|
||||
std::string::const_iterator first = css_color.begin();
|
||||
std::string::const_iterator last = css_color.end();
|
||||
// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
|
||||
#if BOOST_VERSION >= 104500
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
c);
|
||||
return result && (first == last);
|
||||
#else
|
||||
mapnik::css css_;
|
||||
bool result =
|
||||
boost::spirit::qi::phrase_parse(first,
|
||||
last,
|
||||
g,
|
||||
boost::spirit::ascii::space,
|
||||
css_);
|
||||
if (result && (first == last))
|
||||
{
|
||||
c.set_red(css_.r);
|
||||
c.set_green(css_.g);
|
||||
c.set_blue(css_.b);
|
||||
c.set_alpha(css_.a);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
color color_factory::from_string(std::string const& css_color)
|
||||
{
|
||||
color c;
|
||||
init_from_string(c, css_color);
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
55
src/config_error.cpp
Normal file
55
src/config_error.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/xml_tree.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
config_error::config_error(std::string const& what)
|
||||
: what_(what), line_number_(0), file_(), node_name_(), msg_()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
config_error::config_error(std::string const& what, xml_node const& node)
|
||||
: what_(what), line_number_(node.line()), file_(node.filename()), node_name_(node.name()), msg_()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
config_error::config_error(std::string const& what, unsigned line_number, std::string const& filename)
|
||||
: what_(what), line_number_(line_number), file_(filename), node_name_(), msg_()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char const* config_error::what() const throw()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << file_;
|
||||
if (line_number_ > 0) s << " line " << line_number_;
|
||||
if (!node_name_.empty()) s << " in node "<< node_name_;
|
||||
if (line_number_ > 0 || !file_.empty()) s << ": ";
|
||||
s << what_;
|
||||
msg_ = s.str(); //Avoid returning pointer to dead object
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
||||
void config_error::append_context(std::string const& ctx) const
|
||||
{
|
||||
what_ += " " + ctx;
|
||||
}
|
||||
|
||||
void config_error::append_context(std::string const& ctx, xml_node const& node) const
|
||||
{
|
||||
append_context(ctx);
|
||||
append_context(node);
|
||||
}
|
||||
|
||||
void config_error::append_context(xml_node const& node) const
|
||||
{
|
||||
if (!line_number_) line_number_ = node.line();
|
||||
if (node_name_.empty()) node_name_ = node.name();
|
||||
if (file_.empty()) file_ = node.filename();
|
||||
}
|
||||
|
||||
}
|
|
@ -23,21 +23,21 @@
|
|||
// boost
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
||||
#define BOOST_SPIRIT_AUTO(domain_, name, expr) \
|
||||
typedef boost::proto::result_of:: \
|
||||
deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \
|
||||
BOOST_SPIRIT_ASSERT_MATCH( \
|
||||
boost::spirit::domain_::domain, name##_expr_type); \
|
||||
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
|
||||
#define BOOST_SPIRIT_AUTO(domain_, name, expr) \
|
||||
typedef boost::proto::result_of:: \
|
||||
deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \
|
||||
BOOST_SPIRIT_ASSERT_MATCH( \
|
||||
boost::spirit::domain_::domain, name##_expr_type); \
|
||||
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
|
||||
|
||||
|
||||
namespace mapnik { namespace conversions {
|
||||
namespace mapnik { namespace util {
|
||||
|
||||
using namespace boost::spirit;
|
||||
|
||||
BOOST_SPIRIT_AUTO(qi, INTEGER, qi::int_);
|
||||
BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_);
|
||||
BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_);
|
||||
BOOST_SPIRIT_AUTO(qi, INTEGER, qi::int_)
|
||||
BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_)
|
||||
BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_)
|
||||
|
||||
bool string2int(const char * value, int & result)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <mapnik/expression.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
@ -50,8 +51,8 @@ expression_ptr expression_factory::compile(std::string const& str,transcoder con
|
|||
}
|
||||
|
||||
bool expression_factory::parse_from_string(expression_ptr const& expr,
|
||||
std::string const& str,
|
||||
mapnik::expression_grammar<std::string::const_iterator> const& g)
|
||||
std::string const& str,
|
||||
mapnik::expression_grammar<std::string::const_iterator> const& g)
|
||||
{
|
||||
std::string::const_iterator itr = str.begin();
|
||||
std::string::const_iterator end = str.end();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue