Hi,
I am looking into making the GeoTools rendering subsystem more useful
in a set of maps with legal value where the label positioning has a number
of rules that need to be respected, including linear and polygonal
obstacles,
use of leader lines, and the requirement that all labels must be present in
the
map, no matter what, pushing us to add a number of extra options to make
this possible, including accepting label overlap if all other options are
exhausted.
The amount of changes is large... I'm going to add it all in this mail
using HTML
so give it a bit of structure, but let me know if you prefer a PDF
attachment instead.
-------------------------------------------------------------------------------------------------------------
New modified/vendor options leader
This option will activate the usage of a leader line in case the label was
moved away from its original position. It will play along with
maxDisplacement, which currently allows the label to move away from the
label point without one, and will take into account the leader line itself
to make sure it does not overlap with other labels.
Default leader line:
<VendorOption name=”leader”>true</VendorOption>
Black leader line, 3 px wide:
<VendorOption name=”leader”>#000000,3</VendorOption>
In case of polygons, the leader line will be painted only if the label
does not overlap the polygon.
labelObstacle
The current label obstacle vendor option acts by marking the bounding box
of the obstacle as an obstacle for the labels. This will be modified to use
the actual geometry, plus a buffer to take into account the size of the
symbolizer.
Moreover, obstacles will be classified as obstacles for labels only, and
obstacles for labels and leader lines, defaulting as objstacles for labels
only. The rationale is that we might not want the labels to overlap with
some linework, but it’s ok to have the leader line cross it (this is
especially true if we don’t want polygon labels to cross the polygon
border, but the leader line pointing to a label outside the polygon has no
choice but cross)
Obstacle for labels only:
<VendorOption name=”labelObstacle”>labelsOnly</VendorOption>
Obstacle for labels and leader lines only (backwards compatible setting):
<VendorOption name=”labelObstacle”>true</VendorOption>
<VendorOption name=”labelObstacle”>leaderLabels</VendorOption>
This will require a classification of obstacles in the label cache and
conflict engine.
autoReduce
The new autoReduce vendor option will allow the renderer to reduce the size
of labels up to a certain percentage, with an optional step (default step
reduction value, 10%).
Examples (reduce down to 50%px, down to 50% with steps of 25%)
<VendorOption name=”autoReduce”>0.5</VendorOption>
<VendorOption name=”autoReduce”>0.5,0.25</VendorOption>
autoGoodnessOfFit
This option will allow the labeller to reduce the goodness of fit for
polygon labels, allowing the label to gradually move out of the polygon,
with an optional reduction step (10% by default)
Examples (reduce gof to 0 in steps of 10%, reduce gof to 0 in steps of
25%):
<VendorOption name=”autoGoodnessOfFit”>0</VendorOption>
<VendorOption name=”autoGoodnessOfFit”>0,0.25</VendorOption>
alterationOrder
When all the label movement options are set on points and polygons, they
are applied in the following order:
1.
Simple movement without rotation
2.
Polygon align (ortho, mbr, and go back to step one, moving)
3.
Scale font (and go back to step one, moving and rotating)
4.
Goodness of fit reduction
A new vendor option, alterationOrder, will be used to control in which
order the attempts are made:
<VendorOption
name=”alterationOrder”>maxDisplacement,polygonAlign,autoReduce,autoGoodnessOfFit</VendorOption>
force
When set to true, will force a label to be painted regardless of overlaps,
in the position tested so far that has the least overlap with other labels
and obstacles.
Significant changes to LabelCacheImpl
The internal works of LabelCacheImpl will be modified to allow the label
position/charactesitics alteration in a pluggable system. Each alteration
will be a ItemModifier, which generates an iteration of LabelCacheItem with
some bits being modified:
public interface ItemModifier {
Iterator<LabelCacheItem> modify(LabelCacheItem item);
}
At each step in the iterator the modifier will attempt a different
modification, returning a deep clone of the originalLabelCacheItem. The
first modification will be however exactly the cache item provided in the
modify method (first step is “no modification”).
The label cache item will then feed the modified item to the next modified
in the chain, until all possible combination of modifications are
tested.This can be of course very expensive, depending on the number of
label combinations attempted, so the stop flag will be checked during the
iterations, and not only between one label and the next one.
In order to support the new label obstacle requirements the LabelCache
interface will be modified to allow using a geometry plus an eventual
buffer, and the type of obstable:
enume ObstacleType {FULL, LABEL};
LabelCache.put(Geometry g, int distancePixels, ObstacleType type);
In order to satisfy the requirements of the “force” option a quick way to
compute the overlap area is required, compounded with the need to check two
different types of overlap, and the desire to check two different types of
overlap, will require the LabelIndex class to be re-implemented using a
raster based approach:
-
Two black and white mask images, one for pure leader line obstacles, one
for full obstacles
-
The label bounding rectangle will be tested against these two images for
conflicts, and eventualy painted to the full obstacles one in case there is
no conflict
-
In case the label bounding rectangle is not aligned to the axis, it will
be painted to a third black and white image to identify which pixels fall
inside the area of interest
-
As a memory optimization, the target masks will be split into smaller
tiles that are not allocated in memory when fully empty or fully busy
-------------------------------------------------------------------------------------------------------------------------
If you're wondering why this is not a proposal, it's because the funding is
not secured yet
(which is the main point of proposals, make sure there is full resourcing
to carry it out).
Of course, this would be scheduled for 14.x
Feedback welcomed!
Cheers
Andrea
--
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.
-------------------------------------------------------
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel