You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The caching of labels for the LabelLayer is complex and increases memory consumption as the LabelStore needs to be maintained. The suggestion is to implement a solution that reads POI data directly from a MapDataStore instead.
This requires a change so that POI data only can be read for the set of tiles covering the viewport.
Further changes to separate out the RenderTheme matching from the caching etc currently in the DatabaseRenderer.
The problem is that the POI API is so different in the way the data is returned. In many ways the POI API is much better as there is much higher selectivity, but rendering with the RenderTheme works the other way around.
I have started by adding a readPoiData method for a rectangular set of Tiles to the MapDataStore interface. Currently testing, nothing checked in yet.
I think it's best for now to be careful with mixing the two API (besides core module) - Map API is mature, POI is alpha.
At least until we decide how the POI DB should be finalized (e.g. I'm not sure yet for #737).
But any improvement in LabelLayer is certainly most welcomed.
BTW I find it very CPU intensive, besides memory as you mentioned.
Making the LabelLayer read directly from MapDataStore requires more than
just the interface change.
In the current implementation the reading, storing and rendering of data is
pretty much entangled, I am a bit detangling this right now. #741 is connected, but not exactly a duplicate.
I will mention both issues in my commit.
I have made changes to the MapDataStore API and the MapFile implementation so that only POIs can be extracted for an area of tiles. This works well because the amount of data that needs to be retrieved is much smaller, so retrieving it for a number of tiles is not a problem. Since we never need to read the way section of the MapFile, performance is also not bad.
However, if we need to get road and area labels, we will need to read the entire way part of the MapFile as well. That makes reading it much more expensive, both memory and CPU wise.
Possible solutions:
split the labels further so road and area labels are drawn onto tiles. The the LabelLayer draws the POI labels on top. Collision detection will not be possible as these are two layers.
the area label problem can additionally be solved by separately computing points for area labels in the writer process. So area labels would become POIs. (That would also solve the problem of having the area labels repeated again and again, which people have rightly complained about). A lake would then have only one label.
way labels could be extracted by reading the way sections, then discarding those elements that do not have a name tag. Would cut down on memory.
Collision detection already has issues, even with display and priority directives enabled, so I would avoid complicating it further as much as I can. We should review road labels anyway too.
I find 2nd suggestion the best and I vote for it. Let's make map-writer do the hard work and have the client with just the rendering part (even if that involves map file new version). Like in POI API, JTS can be extremely useful in geometry calculations.
Re 2. I would suggest resurrecting the area2points osmosis plug-in. I have a working version somewhere, I remember that for some reason the plug-in was somehow discontinued, but I could never find a reason why.
We could put a working version of this plug-in on our downloads page, then it would be simply a question of putting the plug-in in the osmosis chain. No change in mapfile format required.
The only change required would be in renderthemes: labels for areas would now be labels for pois.
Re 3. We would probably end up with a slightly better road name rendering as we do not have to consider tile boundaries any more, so more road names should show up.
Ok, but I'd still prefer instead an optional flag to map-writer, so to not have many external dependencies which we cannot control their outcome and fix things.
My understanding is that osmconvert drops areas etc if requested, area2point adds a point with the same tag as the area to the input, but the area remains intact (we cannot drop entire areas, as we still need to draw the polygons).
Commit 351f1d4 has a new LabelLayer implementation that utilizes the enhanced MapDataStore interface (see #741).
The LabelLayer is implemented by using a new MapDataStoreLabelStore implementing the LabelStore interface. This class does not store any data, but reads from the MapDataStore the data required. Compared to the old caching mechanism, this is very simple.
A bit of refactoring has been done to reduce code duplication. The implementation of the RenderCallback that was previously an intricate part of the DatabaseRenderer has been factored out into a StandardRenderer class. This is reused in the new LabelLayer to layout and render the labels. The DatabaseRenderer keeps its responsibilities of Tile caching etc. I think there is more potential for cleanup there. Some classes have been changed to reflect that we now also need to layout data for more than one tile, e.g. making sure that polyline data is not clipped at tile boundaries, but only at the boundaries of the tile area.
There is a new LabelLayerUsingMapDataStoreMapViewer which illustrates the use.
I added a threaded version of the LabelLayer that displays old data (if the area still overlaps) and retrieves new data on a background thread. See Samples app.
Activity
devemux86 commentedon Dec 27, 2015
👍
Does it involve a connection with POI API via #742 or for start we should stay with regular Map API ?
ludwigb commentedon Dec 27, 2015
The problem is that the POI API is so different in the way the data is returned. In many ways the POI API is much better as there is much higher selectivity, but rendering with the RenderTheme works the other way around.
I have started by adding a readPoiData method for a rectangular set of Tiles to the MapDataStore interface. Currently testing, nothing checked in yet.
devemux86 commentedon Dec 27, 2015
I think it's best for now to be careful with mixing the two API (besides
coremodule) - Map API is mature, POI is alpha.At least until we decide how the POI DB should be finalized (e.g. I'm not sure yet for #737).
But any improvement in
LabelLayeris certainly most welcomed.BTW I find it very CPU intensive, besides memory as you mentioned.
devemux86 commentedon Dec 27, 2015
Also I had opened #741 with your proposal a while ago, should we mark it as duplicate of this one?
ludwigb commentedon Dec 27, 2015
Making the LabelLayer read directly from MapDataStore requires more than
just the interface change.
In the current implementation the reading, storing and rendering of data is
pretty much entangled, I am a bit detangling this right now.
#741 is connected, but not exactly a duplicate.
I will mention both issues in my commit.
On 27 December 2015 at 17:34, Emux [email protected] wrote:
ludwigb commentedon Dec 28, 2015
Little stumbling block: road and area labels.
I have made changes to the MapDataStore API and the MapFile implementation so that only POIs can be extracted for an area of tiles. This works well because the amount of data that needs to be retrieved is much smaller, so retrieving it for a number of tiles is not a problem. Since we never need to read the way section of the MapFile, performance is also not bad.
However, if we need to get road and area labels, we will need to read the entire way part of the MapFile as well. That makes reading it much more expensive, both memory and CPU wise.
Possible solutions:
Other ideas?
devemux86 commentedon Dec 28, 2015
displayandprioritydirectives enabled, so I would avoid complicating it further as much as I can. We should review road labels anyway too.ludwigb commentedon Dec 28, 2015
Re 2. I would suggest resurrecting the area2points osmosis plug-in. I have a working version somewhere, I remember that for some reason the plug-in was somehow discontinued, but I could never find a reason why.
We could put a working version of this plug-in on our downloads page, then it would be simply a question of putting the plug-in in the osmosis chain. No change in mapfile format required.
The only change required would be in renderthemes: labels for areas would now be labels for pois.
Re 3. We would probably end up with a slightly better road name rendering as we do not have to consider tile boundaries any more, so more road names should show up.
devemux86 commentedon Dec 28, 2015
Ok, but I'd still prefer instead an optional flag to map-writer, so to not have many external dependencies which we cannot control their outcome and fix things.
Also do we need that plugin, how is this different than current Osmconvert method?
http://wiki.openstreetmap.org/wiki/Osmconvert#Dispose_of_Ways_and_Relations_and_Convert_them_to_Nodes
ludwigb commentedon Dec 28, 2015
My understanding is that osmconvert drops areas etc if requested, area2point adds a point with the same tag as the area to the input, but the area remains intact (we cannot drop entire areas, as we still need to draw the polygons).
LabelLayer: new implementation that reads data out of MapDataStore in…
ludwigb commentedon Dec 30, 2015
Commit 351f1d4 has a new LabelLayer implementation that utilizes the enhanced MapDataStore interface (see #741).
The LabelLayer is implemented by using a new MapDataStoreLabelStore implementing the LabelStore interface. This class does not store any data, but reads from the MapDataStore the data required. Compared to the old caching mechanism, this is very simple.
A bit of refactoring has been done to reduce code duplication. The implementation of the RenderCallback that was previously an intricate part of the DatabaseRenderer has been factored out into a StandardRenderer class. This is reused in the new LabelLayer to layout and render the labels. The DatabaseRenderer keeps its responsibilities of Tile caching etc. I think there is more potential for cleanup there. Some classes have been changed to reflect that we now also need to layout data for more than one tile, e.g. making sure that polyline data is not clipped at tile boundaries, but only at the boundaries of the tile area.
There is a new LabelLayerUsingMapDataStoreMapViewer which illustrates the use.
LabelLayer: adding threaded version ThreadedLabelLayer #763
ludwigb commentedon Jan 7, 2016
I added a threaded version of the LabelLayer that displays old data (if the area still overlaps) and retrieves new data on a background thread. See Samples app.
devemux86 commentedon Jan 7, 2016
👍
The improvement is remarkable.
Should we keep the non threaded option in the long run?
ludwigb commentedon Jan 7, 2016
Probably not, I left it in for a fair comparison and in case it somehow causes trouble.
devemux86 commentedon Jan 7, 2016
Also shouldn't we terminate for safety the thread service in layer's
onDestroy?ThreadedLabelLayer: thread clean-up, minor speed improvement, code cl…
LabelLayer: fix separate draw when no cached labels #787, #763
devemux86 commentedon Mar 12, 2016
I think we can close this and handle any side effects at their respective issues.