Repository navigation
Detailing the prevention of non-deterministic labels - #1588
Conversation
| */ | ||
| public DatabaseRenderer(MapDataStore mapDataStore, GraphicFactory graphicFactory, TileCache tileCache, | ||
| TileBasedLabelStore labelStore, boolean renderLabels, boolean cacheLabels, | ||
| LabelStore labelStore, boolean renderLabels, boolean cacheLabels, |
There was a problem hiding this comment.
@Sublimis Why is this change?
As it is always a TileBasedLabelStore.
There was a problem hiding this comment.
It's not always -- even in the current master it can be null. DatabaseRenderer does not depend on this being a TileBasedLabelStore. Current implementation of processLabels() also does not depend on a particular LabelStore implementation, it only assumes there's a LabelStore that contains some labels, nothing more. It can even run with labelStore == null.
And now that DirectRenderer extends DatabaseRenderer in this PR, LabelStore implementation can also be MapDataStoreLabelStore, so it feels natural to generalize things. If this is really something you want to avoid we can for example create a new interface extending LabelStore that would define the TileBasedLabelStore.storeMapItems(). Otherwise too much code would get duplicated in DirectRenderer (there would be no point in extending DatabaseRenderer if it can only work with TileBasedLabelStore).
|
|
||
| public final double horizontalOffset; | ||
| public final boolean isVisible; | ||
| public final boolean isNotVisible; |
There was a problem hiding this comment.
@Sublimis isVisible is more understandable and already used. Why change it?
There was a problem hiding this comment.
Two reasons: 1) isVisible() was only ever used in negation, cluttering the code, 2) isVisible() returning true doesn't really mean much, and can be misleading, because it does not mean the item is visible like the name implies. Like the javadoc of the superclass method isNotVisible() says: "@return {@code true} if this is definitely not visible; {@code false} if it may or may not be visible"
| private List<List<ShapePaintContainer>> drawingLayers; | ||
| public final List<MapElementContainer> labels; | ||
| public final List<List<List<ShapePaintContainer>>> ways; | ||
| private List<List<ShapePaintContainer>> drawingLayer; |
There was a problem hiding this comment.
First dimension of the three-dimensional ways field is the layers dimension, then levels, and then ShapePaintContainer-s, isn't that so? See the code:
And when one picks an element from the list of layers, it becomes just a single layer
There was a problem hiding this comment.
In fact this is also a typo, it should also be singular
There was a problem hiding this comment.
In fact this is also a typo, it should also be singular
@Sublimis Then we should also change this.
|
By the end of the week we'll also push the latest hill shading improvements, and that should be all from us for the foreseeable future 🙂 |
|
@Sublimis Thanks! |
DirectRenderer, i.e. make labels that are rendered directly on tiles (when usingMapDataStoreLabelStore) deterministic with this one change: Omit drawing labels that span multiple tiles and clash with labels of similar priority.CanvasRasterer.renderContextreference (it's natural, becauseCanvasRastereronly lives insideRenderContext).RenderContextfields encapsulation.LayerUtil.collisionAndContestingFreeOrdered()andLayerUtil.collisionFreeOrdered().After implementing points 1. and 2., not a single label tear was observed when using the
DirectRenderermethod. It seems that the problem with non-deterministic labels has finally been completely solved. Yay!Note that point 1. didn't change the way the current implementation of
DatabaseRendererhandles tile-rendered labels when usingTileBasedLabelStore.We hope you don't mind points 4. and 5. It would be a pity to revert them because they make the code more future-proof and OOP-compliant (and less error-prone).