using createTileMapServiceImageryProvider with gdal2tiles

450 views
Skip to first unread message

Shane Thomas

unread,
Jul 11, 2016, 1:53:44 PM7/11/16
to cesium-dev
I think i was going about getting my geotiffs on cesium all wrong.  I was insisting on using KML but I think I don't need to do that as gdal2tiles seems to write out tms which i believe createTileMapServiceImageryProvider can help with.  The problem is this:

I have a script htat processes some goe tiffs into what I thought was TMS format using gdal2tiles.    The thing is when I try to create a viewer to use this info:



       var l1924 = layers.addImageryProvider(new Cesium.createTileMapServiceImageryProvider({
            url:'myTiles/tiles',
            minimumLevel: 9,
            maximumLevel: 14,
            credit: 'moi'
        }));


I get no errors in the imagery provided layers but it does fail to load a lot of png files from the tileset.  I realize the numbers are just only slightly off than the tile set I have on disk and I cannot figure out what is causing this.

So on my disk my gdal2tiles created this:
Location

10/66/314.png
10/66/315.png

but cesium is looking for it in the 9 directory e.g:


no idea why the diff or how to get them to sync up

The tilemapsource.xml file:

<?xml version="1.0" encoding="utf-8"?>
    <TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
      <Title>Maui.nitf</Title>
      <Abstract></Abstract>
      <SRS>EPSG:4326</SRS>
      <BoundingBox minx="-156.67628904939917" miny="20.55945745641503" maxx="-156.15232902955518" maxy="20.90565525332952"/>
      <Origin x="-156.67628904939917" y="20.55945745641503"/>
      <TileFormat width="256" height="256" mime-type="image/png" extension="png"/>
      <TileSets profile="geodetic">
        <TileSet href="9" units-per-pixel="0.00137329101562" order="9"/>
        <TileSet href="10" units-per-pixel="0.00068664550781" order="10"/>
        <TileSet href="11" units-per-pixel="0.00034332275391" order="11"/>
        <TileSet href="12" units-per-pixel="0.00017166137695" order="12"/>
        <TileSet href="13" units-per-pixel="0.00008583068848" order="13"/>
        <TileSet href="14" units-per-pixel="0.00004291534424" order="14"/>
      </TileSets>
    </TileMap>
    

Shane Thomas

unread,
Jul 11, 2016, 3:18:59 PM7/11/16
to cesium-dev
for completeness I should say that  the loading in the javascript points to myTiles/tiles folder, in reality it is the correct folders as given above that is it pointing too so:

url: 

url: 'static/swsite/images/processed/Maui/kml/test'

jbo023

unread,
Jul 15, 2016, 7:37:43 AM7/15/16
to cesium-dev
Hello Shane, 

i think cesium uses the mercator tilingschema as a default, so your dataset which is in the geodetic profile is not working. 

But you can add the following. 

  var l1924 = layers.addImageryProvider(new Cesium.createTileMapServiceImageryProvider({
            url:'myTiles/tiles',
            tilingScheme : new Cesium.GeographicTilingScheme(), 
            minimumLevel: 9,
            maximumLevel: 14,
            credit: 'moi'
        }));

I hope this will help you

Jannes

Shane Thomas

unread,
Jul 15, 2016, 4:00:50 PM7/15/16
to cesium-dev
Thank you Jannes, I did try both the code and calling 

gdal2tiles.py -p mercator my.nitf

and the results were the same, cesium was looking for file names that existed in wrong folders though.  I did add that snippet of code too, not sure if I did something else noticeably wrong but same result from the above methods.

Shane

b...@benfeist.com

unread,
Oct 7, 2017, 11:40:12 AM10/7/17
to cesium-dev
Sorry to resurrect such an old thread, but I've been struggling with exactly the same problem. My solution was to set "geodetic" profile in gdal2tiles.py with -p, and the -d flag to set "TMS compatible".
Reply all
Reply to author
Forward
0 new messages