Getting a list of rendering rules for a given Way

66 views
Skip to first unread message

Murray Hughes

unread,
May 15, 2015, 8:36:03 AM5/15/15
to mapsfo...@googlegroups.com

I am building a little tool to help build a new theme, I have some code that lets you select a tile on the map and I print out some information about the POI's and Way's in that tile. (from MapReadResult)

I have two questions.

1. Can someone point me in the direction to where I might be able to query the XML Render theme for a list of rules/styles that match a given POI or Way (from the MapReadResult).

2. Given MapReadResult I would like to be able to generate a Bitmap image just for that tile, at the moment I have a full MapView and just change the bounding box but I would like to be able to modify the MapReadResult data at run-time and then render a new bitmap.

Thanks

Emux

unread,
May 15, 2015, 8:52:13 AM5/15/15
to mapsfo...@googlegroups.com
The process is handled a bit differently, based on the visible (or requested) map view tiles, the map file is queried for the included vector elements.

If you're asking for search inside map file, that's not possible. The map file format is optimized for fast live rendering only.

Search inside render theme rules on file level is simple xml parsing and can be done with standard Java (probably outside Mapsforge's scope).

--
Emux
Cruiser - Atlas

Emux

unread,
May 15, 2015, 9:22:53 AM5/15/15
to mapsfo...@googlegroups.com
Digging a bit in the code..

For the bitmap production I suggest to start from DatabaseRenderer.executeJob method.

And for the render theme matches you can check RenderTheme class.

Murray Hughes

unread,
May 16, 2015, 3:31:08 AM5/16/15
to mapsfo...@googlegroups.com

Thanks,

I ended up subclassing the DatabaseRenderer and just added a couple helper methods for generating the job and executing it. This worked well. I also wrote a custom MapResult data that allowed me to select one or more POI's or Ways in a returned database tile to only render parts on the tile so I could debug some issues in my rendering theme.

Additionally I wrote some helpers that for a given way or POI I could log what draw functions got called. It all made it much easier to debug and tweak my theme.

I am also working on a little tool that generates a report on the Map to Theme coverage, see what data is in the map file and not being used. It also gives a breakdown on the memory usage in the Map file, like how much memory is being used by strings or what ways (tags) are taking up the most space.

I have a project that I am attempting to fit the most maps possible in 2-3GB, so every MB counts, I also investigating a slightly modified version of the file format in order to optimise space, I don't need high performance just more maps!

Murray

Emux

unread,
May 16, 2015, 5:11:47 AM5/16/15
to mapsfo...@googlegroups.com
On 16/05/2015 10:31 πμ, Murray Hughes wrote:
I also wrote a custom MapResult data that allowed me to select one or more POI's or Ways in a returned database tile to only render parts on the tile so I could debug some issues in my rendering theme.

Additionally I wrote some helpers that for a given way or POI I could log what draw functions got called. It all made it much easier to debug and tweak my theme.

Is all that a bit over-analyzing?
I mean this can be performed with just comment out some rules in render theme and focus on how specific elements appear.


I am also working on a little tool that generates a report on the Map to Theme coverage, see what data is in the map file and not being used. It also gives a breakdown on the memory usage in the Map file, like how much memory is being used by strings or what ways (tags) are taking up the most space.

I don't know your case, but you can find that info available, what is in the map file is defined in tag-mapping and what is rendered is in render theme.


I have a project that I am attempting to fit the most maps possible in 2-3GB, so every MB counts, I also investigating a slightly modified version of the file format in order to optimise space, I don't need high performance just more maps!

I think these days performance is needed probably more than space (we are not exception here).

Caution is needed with map file format too, for not breaking compatibility.

Murray Hughes

unread,
May 17, 2015, 1:41:55 AM5/17/15
to mapsfo...@googlegroups.com

Maybe it is over analysing, but I guess its my way to study and learn the file format, themes and rendering engine. I know know all 3 in high detail, It didn't take that long and it was fun :-)

I understand in most use cases, especially with modern touch devices performance is more important, in my case I have a dedicated device with no touch screen and slow update frequency, breaking compatibility isn't important since we will have full control over the map files.

Its a great project and its been a lot of fun.

Murray

fzk

unread,
May 19, 2015, 2:27:16 AM5/19/15
to mapsfo...@googlegroups.com
> I am building a little tool to help build a new theme, ...

Could you explain (from the user perspective) in more detail what your tools does?

Klaus

Murray Hughes

unread,
May 19, 2015, 2:38:30 AM5/19/15
to mapsfo...@googlegroups.com


Basically it lets me load a map and theme, when I select a tile I see that tile rendered using the elevate3 theme (on the right). I also get a list of WAY and POI, if i select 1 or more of these they are the only items rendered in 2nd map. The app also monitors the file system to reload the layers if I save my theme file. 

When I started i knew very little about the OSM data so while it has helped with the theme design, it was more about educating myself on the OSM data and the Mapsforge API.


Murray Hughes

unread,
May 19, 2015, 2:40:51 AM5/19/15
to mapsfo...@googlegroups.com
I attached 2 screen shots but they ended up in the quoted text, expand to see them.
Reply all
Reply to author
Forward
0 new messages