Adding documentation on text layouts. Seperated text layout options from the symbolizer options table.

Jordan Hollinger 2014-02-19 06:10:00 -08:00
parent 43b390478e
commit 87d4441ba1

@ -2,34 +2,38 @@
### Options for whole Symbolizer ### Options for whole Symbolizer
| *parameter* | *values/ type* | *description* | *unit* | *default* | *version* | | *parameter* | *values/ type* | *description* | *unit* | *default* | *version* |
----------------|---------|----------------|-------|------------|---------| ----------------|---------|----------------|-------|------------|---------|
|text-ratio|double| Try to keep a given height to width ratio. Use 0 to disable this feature.|ratio|0|
|wrap-width|double|Length before wrapping long names. Use 0 to disable this feature.|px|0|
|wrap-before|true,false|Wrap text before wrap-width is reached. If this setting is off your lines will always be a bit longer than wrap-width. If this setting is on the lines will usually be a bit shorter, but can be longer if there is a single word that is longer than your current line limit.|||
|spacing|double|Space between repeated labels. If spacing is 0 only one label is placed.|px|0| |spacing|double|Space between repeated labels. If spacing is 0 only one label is placed.|px|0|
|label-position-tolerance|double|Allow labels to be moved from their point in line placement. Lower values indicate that Mapnik tries less positions and generally leads to fewer labels. Higher values lead to Mapnik trying more different positions along a line to find a free spot. If unset or 0, Mapnik sets this value based on the total length of the line to ensure enough labels are placed.|?|0| |label-position-tolerance|double|Allow labels to be moved from their point in line placement. Lower values indicate that Mapnik tries less positions and generally leads to fewer labels. Higher values lead to Mapnik trying more different positions along a line to find a free spot. If unset or 0, Mapnik sets this value based on the total length of the line to ensure enough labels are placed.|?|0|
|force-odd-labels|true, false|Force an odd amount of labels to be generated.|bool|false| |force-odd-labels|true, false|Force an odd amount of labels to be generated.|bool|false|
|max-char-angle-delta|double|Maximum angle (in degrees) between two consecutive characters in a label allowed. The lower the number the fewer labels placed - this is to stop placing labels around sharp corners.|degree|22.5| |max-char-angle-delta|double|Maximum angle (in degrees) between two consecutive characters in a label allowed. The lower the number the fewer labels placed - this is to stop placing labels around sharp corners.|degree|22.5|
|halo-rasterizer|fast, full|(Only for AGG renderer) Choose between good and fast halo rasterizer. Both produce equally good results for halo-radius <= 1.0. Only full rasterizer supports fractional values > 1.0. Other values are truncated by fast rasterizer (e.g. 1.8px = 1px). [Visual comparision](https://raw.github.com/mapnik/mapnik/master/tests/visual_tests/images/text-halo-rasterizer-600-400-1.0-agg-reference.png)||full|git only (2013-04-25)| |halo-rasterizer|fast, full|(Only for AGG renderer) Choose between good and fast halo rasterizer. Both produce equally good results for halo-radius <= 1.0. Only full rasterizer supports fractional values > 1.0. Other values are truncated by fast rasterizer (e.g. 1.8px = 1px). [Visual comparision](https://raw.github.com/mapnik/mapnik/master/tests/visual_tests/images/text-halo-rasterizer-600-400-1.0-agg-reference.png)||full|git only (2013-04-25)|
|dx, dy|double|Displace label by fixed amount on either axis. Actual displacement also depends on vertical-alignment and horizontal-alignment|px|0.0|0.7
|displacement|(x,y)/tuple|Move text position by this many pixels|px|(0,0)|2.1 |displacement|(x,y)/tuple|Move text position by this many pixels|px|(0,0)|2.1
|avoid-edges|true, false|Boolean to avoid labeling near intersection edges|bool|false| |avoid-edges|true, false|Boolean to avoid labeling near intersection edges|bool|false|
|minimum-distance|double|Minimum distance between repeated labels such as street names or shield symbols (works across features)|px|0.0| |minimum-distance|double|Minimum distance between repeated labels such as street names or shield symbols (works across features)|px|0.0|
|allow-overlap|true, false|Allow labels to overlap other labels - Note: you can also clear the label collision cache at the LAYER level to promote more overlap. See 'clear_label_cache' at [[XMLConfigReference]] part layer|bool|false| |allow-overlap|true, false|Allow labels to overlap other labels - Note: you can also clear the label collision cache at the LAYER level to promote more overlap. See 'clear_label_cache' at [[XMLConfigReference]] part layer|bool|false|
|placement|line, point, vertex, interior|"line" to label along lines instead of by point. TODO: Document other options.||point| |placement|line, point, vertex, interior|"line" to label along lines instead of by point. TODO: Document other options.||point|
|vertical-alignment|top, middle, bottom, auto|Position of label relative to point position. "auto" is "middle" for dy=0, "bottom" for dy>0, "top" for dy<0||auto|
|horizontal-alignment|left, middle, right, auto|Position of label relative to point position||auto|
|justify-alignment|left, middle, right, "auto|Justify multi-line text||auto|
|opacity|double|1 is fully opaque while zero is fully transparent and .5 would be 50% transparent||1| |opacity|double|1 is fully opaque while zero is fully transparent and .5 would be 50% transparent||1|
|minimum-padding|double|if >0 helps prevents a label (or shield) from being placed too near the edge of the map.|px|0.0| |minimum-padding|double|if >0 helps prevents a label (or shield) from being placed too near the edge of the map.|px|0.0|
|minimum-path-length|double|place labels only on paths longer than this value.|px|0.0| |minimum-path-length|double|place labels only on paths longer than this value.|px|0.0|
|orientation|double|Rotate text.|degree|0|
|rotate-displacement|true, false|Rotates the displacement around the placement origin by the angle given by "orientation".|bool|false|harfbuzz|
|placement-type|dummy, simple, list|Placement finder algorithm. Currently supported: "dummy" (one placement only), "simple" (automatically create new positions using a simple configuration; see below) and "list" (mapnik >=2.1, see below)|string|dummy|2.0/2.1 |placement-type|dummy, simple, list|Placement finder algorithm. Currently supported: "dummy" (one placement only), "simple" (automatically create new positions using a simple configuration; see below) and "list" (mapnik >=2.1, see below)|string|dummy|2.0/2.1
|placements|string|List of possible placements. Only valid if placement-type="simple" is used. See below for syntax.||"X"|2.0 |placements|string|List of possible placements. Only valid if placement-type="simple" is used. See below for syntax.||"X"|2.0
|upright|left, right, auto, left_only, right_only|Select which way direction is used to place characters upright. The XXX_only variants place text only if more than 50% of all character are upright. Together with placement-type="list" this can be used to implement alternate texts. See below for an example. ||auto|harfbuzz |upright|left, right, auto, left_only, right_only|Select which way direction is used to place characters upright. The XXX_only variants place text only if more than 50% of all character are upright. Together with placement-type="list" this can be used to implement alternate texts. See below for an example. ||auto|harfbuzz
|clip|true, false|If true then the geometry is clipped to the view before doing placements. Improves performance but can cause bad placements when the results are used for tiling|bool|true|2.0.0| |clip|true, false|If true then the geometry is clipped to the view before doing placements. Improves performance but can cause bad placements when the results are used for tiling|bool|true|2.0.0|
|largest_bbox_only|true, false| controls default labeling behavior on multipolygons. The default is `true` and means that only the largest polygon part is labeled. NOTE: this option may change or be renamed in the future|bool|true|2.1| |largest_bbox_only|true, false| controls default labeling behavior on multipolygons. The default is `true` and means that only the largest polygon part is labeled. NOTE: this option may change or be renamed in the future|bool|true|2.1|
### Text layout options
| *parameter* | *values/ type* | *description* | *unit* | *default* | *version* |
----------------|---------|----------------|-------|------------|---------|
|dx, dy|double|Displace label by fixed amount on either axis. Actual displacement also depends on vertical-alignment and horizontal-alignment|px|0.0|0.7
|vertical-alignment|top, middle, bottom, auto|Position of label relative to point position. "auto" is "middle" for dy=0, "bottom" for dy>0, "top" for dy<0||auto|
|horizontal-alignment|left, middle, right, auto|Position of label relative to point position||auto|
|justify-alignment|left, middle, right, "auto|Justify multi-line text||auto|
|text-ratio|double| Try to keep a given height to width ratio. Use 0 to disable this feature.|ratio|0|
|wrap-width|double|Length before wrapping long names. Use 0 to disable this feature.|px|0|
|wrap-before|true,false|Wrap text before wrap-width is reached. If this setting is off your lines will always be a bit longer than wrap-width. If this setting is on the lines will usually be a bit shorter, but can be longer if there is a single word that is longer than your current line limit.|bool|false|
|orientation|double|Rotate text.|degree|0|
|rotate-displacement|true, false|Rotates the displacement around the placement origin by the angle given by "orientation".|bool|false|harfbuzz|
### Character formatting options ### Character formatting options
| *parameter* | *values/ type* | *description* | *unit* | *default* | *version* | | *parameter* | *values/ type* | *description* | *unit* | *default* | *version* |
----------------|---------|----------------|-------|------------|---------| ----------------|---------|----------------|-------|------------|---------|
@ -171,7 +175,7 @@ If some of your text depends on the line direction you need to supply different
</TextSymbolizer> </TextSymbolizer>
``` ```
## New features in HarfBuzz branch ## New features in Mapnik 3.x
* upright="auto/left/right" (See table above) * upright="auto/left/right" (See table above)
* dx is also used for line placements * dx is also used for line placements
* Multi-line support for line placements * Multi-line support for line placements
@ -179,3 +183,18 @@ If some of your text depends on the line direction you need to supply different
* justify-alignment, vertical-alignment, text-ratio, wrap-width, wrap-before supported for line placements * justify-alignment, vertical-alignment, text-ratio, wrap-width, wrap-before supported for line placements
* Line offsets are real offsets instead of fake offsets imitated by calculating the average angle * Line offsets are real offsets instead of fake offsets imitated by calculating the average angle
* If dy!="0" you have to set vertical-alignment="middle" to get the same behavior as in previous versions. * If dy!="0" you have to set vertical-alignment="middle" to get the same behavior as in previous versions.
## Layouts
Additional text layouts can be defined in the contents of text symbolizer. Each of these can be assigned any of the text layout attributes listed above. Rather than being alternate placements, each layout is drawn as part of a single placement. This means that all of the text layouts must fit in order for any of them to be drawn. Different configurations of layout nodes can be specified for each alternate placement. Multiple text layouts are compatible with point and line placements.
A simple XML example:
```xml
<TextSymbolizer face-name="DejaVu Sans Book" size="12" placement="line">
<Layout dy="-5">[LEFT_NAME]</Layout>
<Layout dy="5">[RIGHT_NAME]</Layout>
</TextSymbolizer>
```
The above specifies two offset text layouts to be placed along opposite sides of a line.