Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with compositing two mbtiles #19

Open
t2wu opened this issue Oct 17, 2012 · 2 comments
Open

Problem with compositing two mbtiles #19

t2wu opened this issue Oct 17, 2012 · 2 comments

Comments

@t2wu
Copy link

t2wu commented Oct 17, 2012

This code tries to composite tiles from two mbtiles and make into a composite:

import logging
from landez import MBTilesBuilder, TilesManager

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(filepath="composite_z12_15.mbtiles", mbtiles_file="OSMBrightZ12_15_label_only.mbtiles")  # base layer
overlay = TilesManager(mbtiles_file="watercolor_z12_15.mbtiles")
# if no coverage the bottom layer, but I need this to avoiding running into another landez bug
mb.add_coverage(bbox=(-122.1099,37.4531,-121.8768,37.6107), zoomlevels=range(12,16)) # 12 to 15
mb.add_layer(overlay)
mb.run()

This runs into the error of:

DEBUG:landez.sources:Execute query 'SELECT tile_data FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?;' ((15, 5284, 20081),)
Traceback (most recent call last):
File "./composite.py", line 13, in
mb.run()
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 288, in run
self._gather((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 322, in gather
tilecontent = self.tile((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 155, in tile
output = self.reader.tile(z, x, y)
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/sources.py", line 106, in tile
raise ExtractionError(
("Could not extract tile %s from %s") % ((z, x, y), self.filename))
landez.sources.ExtractionError: Could not extract tile (15, 5284, 12686) from OSMBrightZ12_15_label_only.mbtiles

Where as my previous code (which I mistakenly written with two overlays) ran fine:

logging.basicConfig(level=logging.DEBUG)
mb = MBTilesBuilder(filepath="composite_z12_15.mbtiles")
overlay = TilesManager(mbtiles_file="OSMBrightZ12_15_label_only.mbtiles")
overlay2 = TilesManager(mbtiles_file="watercolor_z12_15.mbtiles")

# if no coverage the bottom layer, but I need this to avoiding running into another landez bug
mb.add_coverage(bbox=(-122.1099,37.4531,-121.8768,37.6107), zoomlevels=range(12,16)) # 12 to 15

mb.add_layer(overlay2)
mb.add_layer(overlay)
mb.run()

I think the first code is grabbing the wrong tile number.

@leplatrem
Copy link
Collaborator

This would basically mean that the coverage you specify is too large or covers unavailable zoom levels.

The explanation about the successful run when using overlays is here :
https://github.com/makinacorpus/landez/blob/master/landez/tiles.py#L178-183

For overlays, we only show a warning if the tile is missing, whereas we raise errors for the base layer.

@t2wu
Copy link
Author

t2wu commented Oct 19, 2012

Thanks. That explains it. That's probably because my add_coverage() call is spanning an area bigger than the tiles are? But that would be weird, giving that the same bbox is used for the base layer which I obtained from TileMill, and the overlay which I obtained using Landez connecting to Stamen's watercolor tiles.

What's the default behavior suppose to be if I don't supply any coverage area?
Right now it would cause exception to throw (please mind that the line number might be different from the trunk)

DEBUG:landez.tiles:Clean-up /tmp/landez/composite_z12_15_2
Traceback (most recent call last):
  File "./composite.py", line 13, in <module>
    mb.run()
  File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 271, in run
    metadata = bottomlayer.reader.metadata()
AttributeError: 'tuple' object has no attribute 'reader'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants