tilemill-project / tilemill

TileMill is a modern map design studio
https://tilemill-project.github.io/tilemill/
BSD 3-Clause "New" or "Revised" License
3.12k stars 527 forks source link

TileMill/mb-util MBTiles export problem when bbox near Greenwich meridian #2256

Open geep999 opened 10 years ago

geep999 commented 10 years ago

I have detected two problems when exporting MBTiles for zoom levels 0 through 15 using TileMill interactively or using mb-util.

When an edge of the bounding box - bbox - is close to the Greenwich meridian (0E) then tiles that should be created are omitted. Yet everything looks OK using the TileMill gui.

To see the examples, I have posted screenshots at my blogger account: http://geep999.blogspot.co.uk/2014_03_01_archive.html

I have three examples of the problem, and a very simple workaround deduced by trial and error. First the magic fix - ensure that the edge of the bbox is at least 0.5 degrees from the Greenwich meridian. i.e. no closer than -0.5 or +0.5

In my three examples Bexley, East Sussex and Hertfordshire, the actual bbox are: Bexley.shp bbox 0.08233 51.40865 0.21594 51.50665 Bexley.shp centre 0.149135 51.45765 East_Sussex.shp bbox -0.13585 50.73553 0.85932 51.14707 East_Sussex.shp centre 0.361735 50.9413 Hertfordshire.shp bbox -0.74573 51.59962 0.18714 52.07947 Hertfordshire.shp centre -0.279295 51.839545

For East Sussex all tiles to the West of Greenwich are missing. For Hertfordshire all tiles to the East of Greenwich are missing. For Bexley only tiles for Zoom level 0 are created. mb-util message thus: DEBUG:mbutil.util:Exporting MBTiles to disk DEBUG:mbutil.util:/media/space5/Documents/MapBox/export/auto_row_Bexley_0_15.mbtiles --> Bexley_0_15 INFO:mbutil.util:1 / 1 tiles exported

When the magic fix is applied to the bounding box all is good. Bexley.shp bbox -0.5 51.40865 0.5 51.50665 Bexley.shp centre 0.0 51.45765 East_Sussex.shp bbox -0.5 50.73553 0.85932 51.14707 East_Sussex.shp centre 0.17966 50.9413 Hertfordshire.shp bbox -0.74573 51.59962 0.5 52.07947 Hertfordshire.shp centre -0.122865 51.839545

Now for Bexley a full tilestack is generated. mb-util message thus: INFO:mbutil.util:941 / 941 tiles exported

And for East Sussex and Hertfordshire no tiles are missing.

Cheers, Peter

springmeyer commented 10 years ago

Interesting, thanks for the report. I feel like @rcoup mentioned to me that he also has seen something like this and may have a fix for it.

rcoup commented 10 years ago

@springmeyer can't recall any issues near 0° Longitude.

@geep999 can you grab the JSON .export file that Tilemill creates during your mbtiles export and attach it? IIRC it includes the interpolated bounds/tile-indexes

geep999 commented 10 years ago

Can only attach images, not txt files. Anyway, the .export file is not in a nice format - seems to be binary. It has lots of "\n" characters which I have massaged away, and some VERY long lines, so I hope this copy and paste has worked. This data relates to Hertfordshire, and the coords are slightly different to those in my first post as the Hertfordshire source data has been updated. (Update - this is weird - when I look at this with Update I can see everything, but as soon as I hit "Update Comment" then a lot of stuff vanishes - must be regarded as markup - have uploaded original file to my website - http://pgg123.co.uk/bugs/auto_row.export and reformatted with JSONLint as http://pgg123.co.uk/bugs/auto_row.export.txt )

{"started":1396379858223,"ended":1396379869718,"from":{"protocol":"mapnik:","slashes":true,"xml":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <!DOCTYPE Map[]> <Map srs=\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over\" background-color=\"rgba(0, 0, 0, 0)\" maximum-extent=\"-20037508.34,-20037508.34,20037508.34,20037508.34\">

-0.7457,51.5996,0.1871,52.0795 -0.2815,51.8626,6 png 0 15 1 2 1396379813000

<Style name=\"footpath\" filter-mode=\"first\">

<Layer name=\"footpath\" srs=\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\">

footpath
<Datasource>
   <Parameter name=\"file\"><![CDATA[/home/dad/Documents/MapBox/project/auto_row/layers/footpath/Footpath.shp]]></Parameter>
   <Parameter name=\"type\"><![CDATA[shape]]></Parameter>
</Datasource>

<Style name=\"bridleway\" filter-mode=\"first\">

<Layer name=\"bridleway\" srs=\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\">

bridleway
<Datasource>
   <Parameter name=\"file\"><![CDATA[/home/dad/Documents/MapBox/project/auto_row/layers/bridleway/Bridleway.shp]]></Parameter>
   <Parameter name=\"type\"><![CDATA[shape]]></Parameter>
</Datasource>

<Style name=\"boat\" filter-mode=\"first\">

<Layer name=\"boat\" srs=\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\">

boat
<Datasource>
   <Parameter name=\"file\"><![CDATA[/home/dad/Documents/MapBox/project/auto_row/layers/boat/BOAT.shp]]></Parameter>
   <Parameter name=\"type\"><![CDATA[shape]]></Parameter>
</Datasource>

<Style name=\"restrictedbyway\" filter-mode=\"first\">

<Layer name=\"restrictedbyway\" srs=\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\">

restrictedbyway
<Datasource>
   <Parameter name=\"file\"><![CDATA[/home/dad/Documents/MapBox/project/auto_row/layers/restrictedbyway/Restricted Byway.shp]]></Parameter>
   <Parameter name=\"type\"><![CDATA[shape]]></Parameter>
</Datasource>

<Style name=\"db_unitary_region\" filter-mode=\"first\">

1500000 100000

<Layer name=\"db_unitary_region\" status=\"off\" srs=\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\">

db_unitary_region
<Datasource>
   <Parameter name=\"file\"><![CDATA[/home/dad/Documents/MapBox/project/auto_row/layers/db_unitary_region/district_borough_unitary_region.wgs84.shp]]></Parameter>
   <Parameter name=\"id\"><![CDATA[db_unitary_region]]></Parameter>
   <Parameter name=\"project\"><![CDATA[auto_row]]></Parameter>
   <Parameter name=\"srs\"><![CDATA[]]></Parameter>
   <Parameter name=\"type\"><![CDATA[shape]]></Parameter>
</Datasource>

","mml":{"bounds":[-0.7457,51.5996,0.1871,52.0795],"center":[-0.2815,51.8626,6],"format":"png","interactivity":false,"minzoom":0,"maxzoom":15,"srs":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over","Stylesheet":[{"data":"Map { background-color: transparent; }

bridleway {

line-width:2; line-color:#00ff00; }

footpath {

line-width:2; line-color:#ff00ff; }

boat {

line-width:2; line-color:#800000; }

restrictedbyway {

line-width:2; line-color:#ff0000; }

county_region {

line-width: 1; line-color: limegreen; [zoom>9]{text-name: [FILE_NAME]; text-face-name: 'DejaVu Sans Book'; text-halo-radius: 1; text-halo-fill: limegreen; text-allow-overlap: true; text-size: 8;} }

//Extent: -8.650007, 49.864636, 1.768912, 60.860766 //Centre: -3.44054753072 55.3627013519

db_unitary_region {

line-width: 1; line-color: blue; [zoom>8][zoom<13]{text-name: [FILE_NAME] + \"\ \" + [NAME]; text-face-name: 'DejaVu Sans Book'; text-halo-radius: 2; text-fill: brown; text-halo-fill: white; text-allow-overlap: true; text-wrap-width: 100; text-wrap-before: true; text-size: 8;} }

db_unitary_ward_region {

line-width: 7; line-color: blue; [zoom>9]{text-name: [FILE_NAME]; /text-name: [NAME];/ text-face-name: 'DejaVu Sans Book'; text-halo-radius: 1; text-halo-fill: blue; text-allow-overlap: true; text-allow-overlap: true;} } ","id":"style.mss"}],"Layer":[{"geometry":"linestring","extent":[-0.76573,51.58308,0.5,52.09947],"id":"footpath","class":"","Datasource":{"file":"/home/dad/Documents/MapBox/project/auto_row/layers/footpath/Footpath.shp","type":"shape"},"srs-name":"autodetect","srs":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","advanced":{},"name":"footpath"},{"geometry":"linestring","extent":[-0.70359,51.57962,0.5,52.08091],"id":"bridleway","class":"","Datasource":{"file":"/home/dad/Documents/MapBox/project/auto_row/layers/bridleway/Bridleway.shp","type":"shape"},"srs-name":"autodetect","srs":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","advanced":{},"name":"bridleway"},{"geometry":"linestring","extent":[-0.70381,51.64279,0.5,52.08235],"id":"boat","class":"","Datasource":{"file":"/home/dad/Documents/MapBox/project/auto_row/layers/boat/BOAT.shp","type":"shape"},"srs-name":"autodetect","srs":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","advanced":{},"name":"boat"},{"geometry":"linestring","extent":[-0.69451, 51.61008,0.5,52.05761],"id":"restrictedbyway","class":"","Datasource":{"file":"/home/dad/Documents/MapBox/project/auto_row/layers/restrictedbyway/Restricted Byway.shp","type":"shape"},"srs-name":"autodetect","srs":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","advanced":{},"name":"restrictedbyway"},{"geometry":"polygon","extent":[-8.650007166993161,49.86463626587962,1.7689121055625716,60.86076643797764],"id":"db_unitary_region","class":"","Datasource":{"file":"/home/dad/Documents/MapBox/project/auto_row/layers/db_unitary_region/district_borough_unitary_region.wgs84.shp","id":"db_unitary_region","project":"auto_row","srs":"","type":"shape"},"srs-name":"autodetect","srs":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","advanced":{},"name":"db_unitary_region","status":"off"}],"scale":1,"metatile":2,"id":"auto_row","_updated":1396379813000,"name":"auto_row","description":"","attribution":"","tilejson":"2.0.0","scheme":"xyz","tiles":["http://localhost:20008/tile/auto_row/{z}/{x}/{y}.png? updated=1396379813000&metatile=2&scale=1"],"grids":["http://localhost:20008/tile/auto_row/{z}/{x}/{y}.grid.json?updated=1396379813000&metatile=2&scale=1"],"template":"","version":"1.0.0"},"pathname":"/home/dad/Documents/MapBox/project/auto_row/auto_row.xml","query":{"metatile":2,"scale":1,"internal_cache":true,"base":"","resolution":4,"bufferSize":128,"tileSize":256},"hash":"bbox=-0.7457,51.5996,0.1871,52.0795","bboxIndex":0},"to":{"protocol":"mbtiles:","pathname":"/home/dad/Documents/MapBox/export/auto_row.mbtiles","query":{"batch":100}},"scheme":{"type":"pyramid","concurrency":8,"minzoom":0,"maxzoom":0,"maxdepth":15,"metatile":2,"bounds":{"0":{"minX":0,"minY":0,"maxX":0,"maxY":0},"1":{"minX":0,"minY":0,"maxX":0,"maxY":0},"2":{"minX":1,"minY":1,"maxX":2,"maxY":1},"3":{"minX":3,"minY":2,"maxX":4,"maxY":2},"4":{"minX":7,"minY":5,"maxX":8,"maxY":5},"5":{"minX":15,"minY":10,"maxX":16,"maxY":10},"6":{"minX":31,"minY":21,"maxX":32,"maxY":21},"7":{"minX":63,"minY":42,"maxX":64,"maxY":42},"8":{"minX":127,"minY":84," maxX":128,"maxY":85},"9":{"minX":254,"minY":168,"maxX":256,"maxY":170},"10":{"minX":509,"minY":337,"maxX":512,"maxY":340},"11":{"minX":1019,"minY":675,"maxX":1025,"maxY":680},"12":{"minX":2039,"minY":1351,"maxX":2050,"maxY":1360},"13":{"minX":4079,"minY":2703,"maxX":4100,"maxY":2720},"14":{"minX":8158,"minY":5406,"maxX":8200,"maxY":5441},"15":{"minX":16316,"minY":10812,"maxX":16401,"maxY":10882}},"stats":{"history":[{"date":1396379860227,"total":8255,"pending":1,"unique":2,"duplicate":0,"failed":0,"skipped":0,"remaining":8253,"processed":2,"speed":1},{"date":1396379861228,"total":8255,"pending":8,"unique":163,"duplicate":0,"failed":0,"skipped":1953,"remaining":6139,"processed":2116,"speed":704},{"date":1396379862234,"total":8255,"pending":8,"unique":495,"duplicate":0,"failed":0,"skipped":2213,"remaining":5547,"processed":2708,"speed":675},{"date":1396379863236,"total":8255,"pending":8,"unique":855,"duplicate":0,"failed":0,"skipped":2289,"remaining":5111,"processed":3144,"speed":627},{"date":1396379864237," total":8255,"pending":9,"unique":1202,"duplicate":0,"failed":0,"skipped":2325,"remaining":4728,"processed":3527,"speed":586},{"date":1396379865238,"total":8255,"pending":8,"unique":1575,"duplicate":0,"failed":0,"skipped":2437,"remaining":4243,"processed":4012,"speed":572},{"date":1396379866238,"total":8255,"pending":8,"unique":1958,"duplicate":0,"failed":0,"skipped":2454,"remaining":3843,"processed":4412,"speed":550},{"date":1396379867238,"total":8255,"pending":9,"unique":2309,"duplicate":0,"failed":0,"skipped":2746,"remaining":3200,"processed":5055,"speed":561},{"date":1396379868239,"total":8255,"pending":8,"unique":2682,"duplicate":0,"failed":0,"skipped":3126,"remaining":2447,"processed":5808,"speed":644},{"date":1396379869240,"total":8255,"pending":8,"unique":3049,"duplicate":0,"failed":0,"skipped":3163,"remaining":2043,"processed":6212,"speed":689},{"date":1396379869713,"total":8255,"pending":0,"unique":3235,"duplicate":0,"failed":0,"skipped":3271,"remaining":1749,"processed":6506,"speed":686},{"date": 1396379869718,"total":8255,"pending":0,"unique":3235,"duplicate":0,"failed":0,"skipped":3271,"remaining":1749,"processed":6506,"speed":685}],"total":8255,"pending":0,"unique":3235,"duplicate":0,"failed":0,"skipped":3271},"pos":false,"stack":[],"box":[],"finished":true,"pending":[],"paused":true}}