GithubHelp home page GithubHelp logo

mbtiles in MM about modestmaps-js HOT 14 CLOSED

stamen avatar stamen commented on July 29, 2024
mbtiles in MM

from modestmaps-js.

Comments (14)

shawnbot avatar shawnbot commented on July 29, 2024

I'm confused by the munging of the Y values (pow(2, $z-1) - $y): doesn't MBTiles use the same spherical mercator coordinate system as MM? Invalid Y values would certainly explain more of the vertical world disappearing as you zoom in.

from modestmaps-js.

RandomEtc avatar RandomEtc commented on July 29, 2024

MBTiles uses TMS coordinates which have the origin at the bottom left: http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification

Perhaps $z = $z - 1 and $y = pow(2,$z) - $y would do the trick? In MM zoom level 0 is 1 tile, zoom level 1 is 2x2 tiles, etc, but I think in TMS zoom level 0 is 2x2.

from modestmaps-js.

RandomEtc avatar RandomEtc commented on July 29, 2024

Or maybe $y = pow(2, $z) - 1 - $y - leaving $z as you had it? Sorry for random guesses, it's Friday night :)

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

I changed:
$y = pow(2, $z-1) - $y;
for:
$z = $z - 1;
$y = pow(2, $z) - 1 - $y;
and now it works, thanks!

The next issue I'm trying solve is to continue the map from the dateline onwards. I was able to fit the maps together by:
if($x > 0)
{
$x = $x - 2;
}
if($x < 0)
{
$x = $x + 2;
}
But if you zoom in this creates all sorts of nasty behavior (lower resolution parts next to higher ones, it looks like a mess). Anyone a clue whats going on?

from modestmaps-js.

springmeyer avatar springmeyer commented on July 29, 2024

See the mapbox/wax code, specifically the connectors/mm which provides a customized getTile method to handle the y flip correctly. And then rest assured that mbtiles will switch to the osm/xyz scheme that mm uses soon to avoid the need for this y flip to TMS.

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

Thanks! Am I correct to say that this code from waxconnector.js does what I need?
return this.options.tiles[parseInt(Math.pow(2, coord.zoom) * coord.row + coord.column, 10) %
this.options.tiles.length]
.replace('{z}', coord.zoom.toFixed(0))
.replace('{x}', coord.column.toFixed(0))
.replace('{y}', coord.row.toFixed(0));

I haven't been able to get wax working yet (no examples found) so I figured I try to add what I need into my code.

from modestmaps-js.

tmcw avatar tmcw commented on July 29, 2024

@jhpoosthoek have you seen the Wax manual? It's overflowing with examples.

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

@tmcw, yes I've seen the manual before. I guess I'm used to little example htmls such as created for openlayers and MM. I didn't get the wax examples to work immediately, but now I see that the manual itself also uses wax ;) thanks.

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

I got to it again and the problem is that the wax.mm.connector doesn't seem to work with my tiles: PHP url (the example tiles from mapbox.com on the other hand work perfectly):
var tilejson = {
tilejson: '1.0.0',
scheme: 'tms',
tiles: ['http://www.iivision.com/temp/mb2xyz.php?file=ne2&code={Z}/{X}/{Y}']
};
Anyone an idea why this doesn't seem to work?

from modestmaps-js.

tmcw avatar tmcw commented on July 29, 2024

Hey, so is this the full natural-earth tileset? Regardless of TMS/XYZ, the url http://www.iivision.com/temp/mb2xyz.php?file=ne2&code=0/0/0 should resolve to a worldwide tile if so.

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

@tmcw, yes it is. I commented out the following lines in the PHP:
//$z = $z - 1;
//$y = pow(2, $z) - 1 - $y;
So now 0/0/0 shows the worldwide tile. But it still doesn't work...

from modestmaps-js.

tmcw avatar tmcw commented on July 29, 2024

@jhpoosthoek - this seems to be working fine, are you actually using Wax? http://bl.ocks.org/1149162

from modestmaps-js.

jhpoosthoek avatar jhpoosthoek commented on July 29, 2024

@tmcw, yes it works! Thanks! I downloaded wax from github, but somehow this just didn't work. The PHP also doesn't work on my localhost through XAMPP. But I don't mind, it works!

I'm working to get also other datasets in: http://www.iivision.com/temp/mb2xyz.php?file=mola&code={z}/{x}/{y}, but I guess I need to do a little bit of GDAL work before I can pass it through the gdal2mb script...

from modestmaps-js.

tmcw avatar tmcw commented on July 29, 2024

Great!

from modestmaps-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.