API changes between v2.0 and v2.1 - plepe/mapnik GitHub Wiki
Removed
- Python pickling support was removed for
map/style/rule/symbolizers/fontset/query- these were poorly maintained and future support for fast, core deepcopy should handle most key use cases - see #1390 (map deepcopy) MetaWriter- disabled in 2.1.x series - may be re-enabled in future releasesPointDatasource- UseMemoryDatasourceinstead. PointDatasource was an incomplete wrapper around MemoryDatasource, and is obsolete now thatFeatureobjects can leverage WKB and WKT to create geometries and features can be added to MemoryDatasources.GlyphSymbolizer- functionality can now be achieved with theTextSymbolizerMarkersSymbolizermarker-typeis removed, built in ellipse and arrow types now can be referenced likefile="shape://ellipse"andfile="shape://arrow"- although this interface is unstable and may continue to change.ShieldSymbolizerattributeno_text- Simply leave the text empty if you don't want any text to be rendered.- Removed
XML DTDinutils/xmlsince it was unmaintained: https://github.com/mapnik/mapnik/issues/1402 RasterSymbolizermodedivide(see below)
Changed
MarkersSymbolizer- default
marker-placementis nowpointinstead ofline- meaning if you want your symbols (like arrows) to be oriented along lines you now need to specifyplacement=line, whereas previously this was the default. This changes reflects the goal of making the MarkersSymbolizer default behavior more reasonable for any geometry type, including points, lines, and polygons and to make it consistent with theTextSymbolizerandShieldSymbolizerwhich also default topointplacement. widthandheightare now optional expressions rather than raw floats and their values represent diameter in pixels not radii. If not set they will beNone, but the default ellipse has aradiusof10meaning that if you setwidth="20"andheight="20"then there will be no change in the rendering size of the ellipse. The arrow default dimensions can be roughly maintained withwidth="15" height="10". But to get the exact rendering of the Mapnik 2.0.x arrow use this svg file. Altering width or height will build a newellipsesvg marker internally by default if no custom file type is provided. For non-ellipse types settingwidthandheightwill proportionally scale the marker, but ideally you should use `transform="scale(x,y)" instead.- A new
fill-opacitysetting is available and nowopacityreverse to a new overall opacity that will be multiplied against thefill-opacityorstroke-opacity- this is to match how svg behaves.
- default
- In Python a mapnik.Feature now expects a mapnik.Context() as a first argument and a feature id as the second argument, which stores all attribute names (previously mapnik.Feature only needed a single argument of the feature id and redundantly stored feature attribute names per feature) #834.
Added
-
MarkersSymbolizer -
fill-opacityis new. -
opacityvalue now works to set the alpha of bitmap images. -
Expression- you can now use the built in keyword of[mapnik::geometry_type]to filter features by geometry type either by name or integer key. The mapping is0:no geometry,1:point,2:linestring,3:polygon, and4:collection. A collection indicates that theFeaturehas more than one geometry of different types. So aFeaturewith three linestrings will be reported aslinestringbut aFeaturewith a point and a linestring will be reported as acollection. - for more details see #546 -
To All symbolizers (in most cases)
comp-op- All symbolizers now support compositing in the AGG and Cairo renderersclip- All(most) symbolizers - boolean of whether to clip geometries before rendering (defaults totrue)smooth- bezier smooth value - 0-1, 0 (default) means no smoothing, 1 means fully smoothed, higher values create wild loopbacks
-
LineSymbolizeroffset- offset lines either in positive (right side) or negative (left side)strokemiterlimitadded (https://developer.mozilla.org/en-US/docs/SVG/Attribute/stroke-miterlimit)
-
- New placement alogrithm:
list - Text formatting
Changes documented in TextSymbolizer documentation
- New placement alogrithm:
-
Python Bindings:
mapnik.Image.get_pixel()- get unsigned int value representing the rgba value, useful for fast pixel comparisonsmapnik.Grid.get_pixel()- get int value representing the feature id encoded in the grid pixels- bindings for text placement and formatting work
Deprecated
-
TextSymbolizer- most attributes moved to eitherformatorplacementspropertiesproperties:- label-placement
- horizontal-alignment
- justify-alignment
- vertical-alignment
- orientation
- displacement
- label-spacing
- label-position-tolerance
- avoid-edges
- minimum-distance
- minimum-padding
- minimum-path-length
- maximum-angle-char-delta
- force-odd-labels
- allow-overlap
- largest-bbox-only
- text-ratio
- wrap-width
format:- face_name
- fontset
- text-size
- character-spacing
- line-spacing
- text-opacity
- wrap-char
- wrap-before
- text-transform
- fill
- halo-fill
- halo-radius
Backward compatibility is preserved by python wrappers, however a warning message is printed if the old name is used.
-
RasterSymbolizermodeis deprecated, now usecomp-opwhich supports many more compositing modes- The new mapping from
modetocomp-opis:normal->src_overgrain_mergeandgrain_merge2->grain-mergemultiply->multiplyscreen->screenhard_light->hard-lightdivideanddivide-> Not supported anymore, see: https://github.com/mapnik/mapnik/issues/1432
scaling=fastis deprecated. It has always been a synonym fornear, useneargoing forwardscalingis now exposed in python as enumerations ofmapnik.scaling_methodnot as bare strings