mapbox / robosat

Semantic segmentation on aerial and satellite imagery. Extracts features such as: buildings, parking lots, roads, water, clouds
MIT License
2.01k stars 382 forks source link

FAILED to serve slippy map dirs visualized by mapbox GL JS #199

Closed dorbodwolf closed 4 years ago

dorbodwolf commented 4 years ago

sorry for disturb. I try to serve my slippy map tiles generated by running this script, but I failed to do it. I cannot understand this:

just serve your slippy map directory via HTTP , and then point any map framework to this endpoint

below are what I tried:

  1. pwd to the tiles dir
    (base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles$ pwd
    /home/tiandeyu/robosat-taipei/robosat-hainan/tiles

this is my tile folders, the image format is webp, and my map.html here:

(base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles$ ls
17  maketiles.ipynb  map.html  raster.html
(base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles$ cd 17
(base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles/17$ ls
105626  105629  105632  105635  105638  105641  105644  105647  105650  105653  105656  105659  105662  105665  105668  105671  105674  105677  105680  105683  105686
105627  105630  105633  105636  105639  105642  105645  105648  105651  105654  105657  105660  105663  105666  105669  105672  105675  105678  105681  105684
105628  105631  105634  105637  105640  105643  105646  105649  105652  105655  105658  105661  105664  105667  105670  105673  105676  105679  105682  105685
(base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles/17$ pwd
/home/tiandeyu/robosat-taipei/robosat-hainan/tiles/17
  1. open the python3 http server in port 8887 and I can check the dir and files in my browser

    (base) tiandeyu@deekongone:~/robosat-taipei/robosat-hainan/tiles$ python -m http.server --bind=127.0.0.1 8887 
    Serving HTTP on 127.0.0.1 port 8887 (http://127.0.0.1:8887/) ...
    127.0.0.1 - - [30/Nov/2019 12:55:29] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [30/Nov/2019 12:55:33] "GET /map.html HTTP/1.1" 200 -
    127.0.0.1 - - [30/Nov/2019 12:55:52] "GET /raster.html HTTP/1.1" 200 -
    127.0.0.1 - - [30/Nov/2019 12:56:14] "GET /18/ HTTP/1.1" 200 -
    127.0.0.1 - - [30/Nov/2019 12:56:32] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [30/Nov/2019 13:01:27] "GET /17/ HTTP/1.1" 200 -
  2. Then I try to visualize the slippy map tiles with Mapbox GL JS API, but I can not find my tiles in the local address:http://127.0.0.1:8887/map.html#17 here is the contents of the map.html:

    
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset='utf-8' />
    <title>Robosat</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.css' rel='stylesheet' />
    <style>
      body { margin:0; padding:0; }
      #map { position:absolute; top:0; bottom:0; width:100%; }
    </style>
    </head>
    <body>


![微信图片_20191130141505](https://user-images.githubusercontent.com/14366375/69896554-e27d7780-137b-11ea-95f4-f68309a5ec87.png)
daniel-j-h commented 4 years ago

Your map asks for tiles at

'http://127.0.0.1:8887/{z}/{x}/{y}.webp'

if you start a http server in your directory it will serve this directory structure.

You can verify this by manually looking at a specific tile, say

/17/400/500.webp

(replace z, x, and y with a tile that is on your disk)

Then make sure you can access that exact same tile via

http://127.0.0.1:8887/17/400/500.webp
daniel-j-h commented 4 years ago

@dorbodwolf any updates here?