2.3.8 - MBTiles support

Showing 1-15 of 15 messages
2.3.8 - MBTiles support Igor Brejc 8/6/12 11:19 AM
Hi everyone,

I've just released a new version which comes with a new command: http://maperitive.net/docs/Commands/GenerateMBTiles.html

Play with it and let me know how it behaves. You can also create a free account at MapBox that lets you upload up to 50 MB of tiles (http://mapbox.com/plans/).

The next thing I'm planning to do is to write my own PNG encoder since I'm not satisfied with the one provided by .NET. Hopefully this encoder will produce smaller PNGs and will also work in Mono.
Although for my demo MapBox map (https://tiles.mapbox.com/breki/map/hiking-demo) I used 8-bit PNGs, this is a far from ideal solution - once you have hillshading, there are many more colors than the 256 palette allows, so everything else is dithered. Since dithering is done per-tile, this produces various artifacts (see the lake tiles, for example). So I want to go with a different solution, if possible.

Enjoy,
Igor
Re: [Maperitive] 2.3.8 - MBTiles support Simone Cortesi 8/6/12 3:25 PM
On Mon, Aug 6, 2012 at 8:19 PM, Igor Brejc <igor....@gmail.com> wrote:

> I've just released a new version which comes with a new command:
> http://maperitive.net/docs/Commands/GenerateMBTiles.html

Thanks Igor,
Any other way of display MBTiles beside using mapbox? any plugin to leaflet?

--
-S
Re: 2.3.8 - MBTiles support tomgiam 8/6/12 7:16 PM
Hi Igor,
 
It's working fine for me.
I was able to generate an MBTiles file from a map of central London.
bounds=-0.214198455810547,51.4633441890216,0.025955810546875,51.5420965495586
minzoom=13
maxzoom=17
 
Number of tiles=5,576
Tiles per second=7.2
File size=187MB
I was able to view it on Windows using MBTilesViewer
I was able to use it in my ios application
 
Comments and observations:
It only used 4 out of my 8 threads on I7 2600k
I have an 8GB Windows 7 64 bit system .  Would more memory help?  It was using about 7.2GB.
Can you provide a 6 bit PNG option?
Have you tried using a PNG optimizer like PNGSlim?
 
Thanks
Tom
Re: [Maperitive] 2.3.8 - MBTiles support Igor Brejc 8/7/12 1:39 AM
Any other way of display MBTiles beside using mapbox? any plugin to leaflet?

This is a server-side thing - the web server that hosts tiles needs to know how to get each tile the browser (user) has requested. In a "normal" map hosting, the tiles are just files on the disk and the web request simply fetches them directly. When using MBTiles, however, the map server has to open the SQLite file, find appropriate tile row and then return the image data.

So there's no Leaflet plugin, no. The browser doesn't really know it's dealing with MBTiles map server and it doesn't need to know.

For the server-side, look at https://github.com/mapbox/mbtiles-spec/wiki/Implementations, I think there is at least this one: https://github.com/mapbox/tilestream

This is why I was asking about MBTiles hosting last week (https://groups.google.com/group/maperitive/browse_thread/thread/304141fe547fce90). I have some ideas on how the MBTiles map serving could be improved even further.

Igor 
Re: [Maperitive] 2.3.8 - MBTiles support Simone Cortesi 8/7/12 1:42 AM
On Tue, Aug 7, 2012 at 10:39 AM, Igor Brejc <igor....@gmail.com> wrote:

>> Any other way of display MBTiles beside using mapbox? any plugin to
>> leaflet?
> This is a server-side thing - the web server that hosts tiles needs to know
> how to get each tile the browser (user) has requested. In a "normal" map
> hosting, the tiles are just files on the disk and the web request simply
> fetches them directly. When using MBTiles, however, the map server has to
> open the SQLite file, find appropriate tile row and then return the image
> data.
>
> So there's no Leaflet plugin, no. The browser doesn't really know it's
> dealing with MBTiles map server and it doesn't need to know.

There seems to be something which works with OL though:
http://projects.bryanmcbride.com/ol_mbtiles/

--
-S
Re: [Maperitive] Re: 2.3.8 - MBTiles support Igor Brejc 8/7/12 1:46 AM

On Tue, Aug 7, 2012 at 4:16 AM, tomgiam <liqui...@gmail.com> wrote:
Comments and observations:
It only used 4 out of my 8 threads on I7 2600k

This is because tile generation currently works on one thread only. Only in cases of contours labeling does it use other threads.
I've implemented an experimental multi-thread tiles generation a while back, but it has some serious issues and it complicates the code a lot, so I've put it on hold for now.
 
I have an 8GB Windows 7 64 bit system .  Would more memory help?  It was using about 7.2GB.

In general, not really. The memory is only an issue if you have a large map.
 
Can you provide a 6 bit PNG option?

There's no 6 bit PNG :). The minimum bitness is 8 bit. But I'm working on a better PNG encoding, which should reduce PNG sizes a lot without loosing the quality.
  
Have you tried using a PNG optimizer like PNGSlim?
 

The problem is that this is too slow. It would be even slower for MBTiles, since I would need to write PNGs as files to disk first, then use an optimizer, and only then store them to MBTiles. Not worth it.

The best way to optimize PNGs is to create them optimized right at the start.

 Igor
Re: [Maperitive] 2.3.8 - MBTiles support Igor Brejc 8/7/12 1:50 AM
On Tue, Aug 7, 2012 at 10:42 AM, Simone Cortesi <sim...@cortesi.com> wrote:

There seems to be something which works with OL though:
http://projects.bryanmcbride.com/ol_mbtiles/


Yes, but this still requires the server side (PHP script):

Create TMS layer with PHP script to fetch images from MBTiles sqlite database file
Re: [Maperitive] 2.3.8 - MBTiles support Simone Cortesi 8/7/12 2:24 AM
On Tue, Aug 7, 2012 at 10:50 AM, Igor Brejc <igor....@gmail.com> wrote:
> On Tue, Aug 7, 2012 at 10:42 AM, Simone Cortesi <sim...@cortesi.com> wrote:
>>
>>
>> There seems to be something which works with OL though:
>> http://projects.bryanmcbride.com/ol_mbtiles/
>
> Yes, but this still requires the server side (PHP script):

Yes, but php comes in pretty much any webhosting system. It is not
such a big prerequisite.

--
-S
Re: [Maperitive] 2.3.8 - MBTiles support Igor Brejc 8/7/12 3:06 AM


On Tue, Aug 7, 2012 at 11:24 AM, Simone Cortesi <sim...@cortesi.com> wrote:

Yes, but php comes in pretty much any webhosting system. It is not
such a big prerequisite.


I agree, although I'm not sure that script is good enough for running it on a production server. Opening the SQLite file for each HTTP request seems to be a bit wasteful for me. 

Re: [Maperitive] Re: 2.3.8 - MBTiles support tomgiam 8/7/12 6:26 AM
There is a 6 bit PNG according to the link below, but I don't know if that is supported widely enough to use in MBTiles.
 
 
Thanks
Tom
 
Re: [Maperitive] Re: 2.3.8 - MBTiles support Igor Brejc 8/7/12 7:00 AM
Most of those improvements are the result of converting their 8-bit .png map tile sample down to 6-bit (64) color, 

This is a bit misleading. Yes, you can reduce the palette to 64 colors or even 1 color, but each pixel still uses the whole byte (8 bits) as an index to that color in the palette. 
So the only real saving you get is the reduced palette (256-64) * 3 = 576 bytes. Given that you loose a lot of colors, I don't see this as a being very worthwhile tradeoff.

There is no other 6bit support in PNG, the specs are pretty strict about that.

Igor
Re: 2.3.8 - MBTiles support Christoph Matthei 8/7/12 7:05 AM
Thanks a lot for this feature. I hope it is going to make map updates much faster. 

Could  anyone post some bit of example code to make a website for testing these mbtiles-files? I would like to test it on my own server and not just on mapbox. Some kind of a slippy map with openlayers?

Thanks. 
Re: [Maperitive] Re: 2.3.8 - MBTiles support Igor Brejc 8/8/12 1:52 AM
This all depends on what web server you have, what kind of access to it etc.
One approach was posted by Simone yesterday. I googled out another, more complicated one: http://nelsonslog.wordpress.com/2011/09/20/serving-mbtiles-tiles-for-slippy-maps/

Re: 2.3.8 - MBTiles support Thomas Langner 8/15/12 8:11 AM
Hallo,

die Nutzung von MBTiles in Mobac 1.9 funktioniert sehr gut. So kann man sehr schön offline Karten mit mehreren Layern erstellen. Siehe folgendes Beispiel:

<localTileSQLite>
         <name>Hybrid MBTiles</name>
         <sourceFile>D:\GPS\Maperitive\Tiles\Overlay.mbtiles</sourceFile>
         <atlasType>MBTiles</atlasType>
         <backgroundColor>#000000</backgroundColor>
</localTileSQLite>

Viele Grüße
Thomas

p.s. hoffentlich meckert jetzt keiner, weil ich auf deutsch geschrieben habe...

Am Montag, 6. August 2012 20:19:06 UTC+2 schrieb Igor Brejc:
Re: [Maperitive] Re: 2.3.8 - MBTiles support Igor Brejc 8/15/12 11:33 PM
Hi Thomas,

Thanks for the info.
If anyone complains about German, they can always Google-translate it ;)
Anyway, here's translation:

Hello,

the use of MBTiles in Mobac 1.9 works very well. So you can create very nice offline maps with multiple layers. See the following example:

<localTileSQLite>
          <name> hybrid MBTiles </ name>
          <sourceFile> D: \ GPS \ Maperitive \ Tiles \ Overlay.mbtiles </ sourcefile>
          <atlasType> MBTiles </ atlas type>
          <backgroundColor> # 000000 </ backgroundColor>
</ localTileSQLite>

regards
Thomas

P.S. I hope no one complains now because I've written in German ...