Trying to show a nonprofit how Cesium could be used to communicate hazard data. I’m using a NOAA inundation dataset that I generated a TMS from using Global Mapper. I renamed the top level XML file to be tilemapresource.xml since that’s what Cesium was looking for
Here’s the XML
<?xml version="1.0"?>
<tilemap tilemapservice="http://www.osgeo.org/services/tilemapservice.xml" version="1.0.0">
<title>LA Cat3</title>
<abstract></abstract>
<srs>EPSG:900913</srs>
<vsrs></vsrs>
<boundingbox maxx="-9862211.1374665" maxy="3913575.8482010" minx="-10488383.2731786" miny="3287403.7124888">
</boundingbox>
<origin x="-20037508.3427890" y="-20037508.3427890"></origin>
<tileformat extension="png" height="256" mime-type="image/png" width="256">
</tileformat>
<tilesets profile="global-mercator">
<tileset href="C:/Data/GISData/NOAA/LA_Cat3/8" order="8" units-per-pixel="611.4962263"></tileset>
<tileset href="C:/Data/GISData/NOAA/LA_Cat3/9" order="9" units-per-pixel="305.7481131"></tileset>
<tileset href="C:/Data/GISData/NOAA/LA_Cat3/10" order="10" units-per-pixel="152.8740566"></tileset>
<tileset href="C:/Data/GISData/NOAA/LA_Cat3/11" order="11" units-per-pixel="76.4370283"></tileset>
<tileset href="C:/Data/GISData/NOAA/LA_Cat3/12" order="12" units-per-pixel="38.2185141"></tileset>
</tilesets>
</tilemap>
Here’s the code I put into Sandcastle:
const viewer = new Cesium.Viewer("cesiumContainer");
const options = {
camera: viewer.scene.camera,
canvas: viewer.scene.canvas,
screenOverlayContainer: viewer.container,
};
var layers = viewer.scene.imageryLayers;
var noaa = layers.addImageryProvider(new Cesium.TileMapServiceImageryProvider({
url: 'https://tms-server.alphapixel.com/NOAA_LA_Cat3/',
minimumLevel: 8,
maximumLevel: 12,
credit: 'NOAA'
}));
noaa.alpha = 0.75;
It seems to fetch the XML ok and doesn’t overtly complain, but it keeps trying to load levels that it shouldn’t:
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 0 Y: 0 Level: 1.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 0 Y: 0 Level: 0.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 1 Y: 1 Level: 2.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 2 Y: 3 Level: 3.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 1 Y: 3 Level: 3.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 0 Y: 1 Level: 2.
and my browser console confirms this, showing attempts to load files like:
https://tms-server.alphapixel.com/NOAA_LA_Cat3/4/3/9.png
AFAIK, it shouldn’t load until we get to level 8. But, zooming in, the highest level it ever tries to access is 7
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 16 Y: 25 Level: 6.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 16 Y: 26 Level: 6.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 32 Y: 52 Level: 7.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 32 Y: 53 Level: 7.
An error occurred in “TileMapServiceImageryProvider”: Failed to obtain image tile X: 32 Y: 51 Level: 7.
Both my Javascript and my XML say 8-12. What am I missing?
I have CORS headers set up so anyone should be able to try this themselves. You’ll get a CORS error when trying to access missing tiles because of 404s, but the actual XML and PNG files that do exist have CORS headers set properly and work.