Working with MapTiler

Oct 9, 2011 at 4:52 PM
Edited Oct 9, 2011 at 4:52 PM

I'm trying to use the Mapsui.Wpf sample in order to load tiles produced by MapTiler.

The following XML was produced by MapTiler for my raster (sorry for the long snippets):

 

<?xml version="1.0" encoding="utf-8"?>
<TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
  <Title>Tiles</Title>
  <Abstract></Abstract>
  <SRS>GEOGCS["WGS 84",
DATUM["WGS_1984",
	SPHEROID["WGS 84",6378137,298.2572235630016,
		AUTHORITY["EPSG","7030"]],
	AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]</SRS>
  <BoundingBox minx="31.16034092155990" miny="34.11524000000000" maxx="33.00347000000000" maxy="35.94797999995200"/>
  <Origin x="31.16034092155990" y="34.11524000000000"/>
  <TileFormat width="256" height="256" mime-type="image/png" extension="png"/>
  <TileSets profile="raster">
	<TileSet href="0" units-per-pixel="0.00852437209280" order="0"/>
	<TileSet href="1" units-per-pixel="0.00426218604640" order="1"/>
	<TileSet href="2" units-per-pixel="0.00213109302320" order="2"/>
	<TileSet href="3" units-per-pixel="0.00106554651160" order="3"/>
	<TileSet href="4" units-per-pixel="0.00053277325580" order="4"/>
	<TileSet href="5" units-per-pixel="0.00026638662790" order="5"/>
  </TileSets>
</TileMap>

I've modified the MapTilerTileSource to conform to the above XML:
class MapTilerTileSource : ITileSource
{
    public MapTilerTileSource()
    {
        Schema = GetTileSchema();
        Provider = GetTileProvider();
    }

    public ITileSchema Schema { get; private set; }
    public ITileProvider Provider { get; private set; }

    public static ITileProvider GetTileProvider()
    {
        return new FileTileProvider(new FileCache(@"C:\Path\To\Tiles", "png"));
    }

    public static ITileSchema GetTileSchema()
    {
        var schema = new TileSchema();

        schema.Resolutions.Clear();

        schema.Resolutions.Add(new Resolution { Id = "0", UnitsPerPixel = 0.00852437209280 });
        schema.Resolutions.Add(new Resolution { Id = "1", UnitsPerPixel = 0.00426218604640 });
        schema.Resolutions.Add(new Resolution { Id = "2", UnitsPerPixel = 0.00213109302320 });
        schema.Resolutions.Add(new Resolution { Id = "3", UnitsPerPixel = 0.00106554651160 });
        schema.Resolutions.Add(new Resolution { Id = "4", UnitsPerPixel = 0.00053277325580 });
        schema.Resolutions.Add(new Resolution { Id = "5", UnitsPerPixel = 0.00026638662790 });

        schema.OriginX = 31.16034092155990;
        schema.OriginY = 34.11524000000000;
        schema.Extent = new Extent(31.16034092155990, 34.11524000000000, 33.00347000000000, 35.94797999995200);
        schema.Width = 256;
        schema.Height = 256;
        schema.Format = "png";

        schema.Axis = AxisDirection.InvertedY;
        
        schema.Srs = 
@"GEOGCS[""WGS 84"",
DATUM[""WGS_1984"",
    SPHEROID[""WGS 84"",6378137,298.2572235630016,
        AUTHORITY[""EPSG"",""7030""]],
    AUTHORITY[""EPSG"",""6326""]],
PRIMEM[""Greenwich"",0],
UNIT[""degree"",0.0174532925199433],
AUTHORITY[""EPSG"",""4326""]]";

        return schema;
    }
}

 

However, after setting this tile source in MapTilerClick, the UI hangs. What am I missing here? is there anything else I should do in order to load the tiles?

Thanks in advance