ITiledMapServer2 Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IT > ITiledMapServer2 Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Carto)  

ITiledMapServer2 Interface

Provides access to members that serve tiled maps.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

This interface is new at ArcGIS 9.3. It supersedes ITiledMapServer.

Members

Name Description
Method GetCacheControlInfo Gets the cache description information for a given map.
Method GetCacheDescriptionInfo Gets the cache description information for a given map.
Method GetCacheName Gets the cache name for a given layer within a map.
Method GetLayerTile Gets a tile for a given tile location from a given layer.
Method GetLayerTileEx Gets a tile for a given tile location from a given layer.
Method GetMapTile Gets a tile for a given tile location from a given map.
Method GetMapTileEx Gets a tile for a given tile location from a given map.
Method GetTileCacheInfo Gets the cache configuration for a given map.
Method GetTileImageInfo Gets the cache tile image information for a given map.
Method GetVirtualCacheDirectory Gets the virtual cache directory for a given layer within a map.
Method HasLayerCache Indicates if a given layer has a single tile cache.
Method HasSingleFusedMapCache Indicates if a given map has a single fused map tile cache.
Method IsFixedScaleMap Indicates if a given map is a fixed scale map.

Inherited Interfaces

Interfaces Description
ITiledMapServer Provides access to members that serve tiled maps.

CoClasses that implement ITiledMapServer2

CoClasses and Classes Description
MapServer The MapServer component provides programmatic access to the contents of a map document on disk, and creates images of the map contents based on user requests. Designed for use in building map-based web services and web applications.
MapServerIP Map Server Message Proxy.
MapServerLP Map Server LAN Proxy.

Remarks

ITiledMapServer2 allows clients to retrieve information regarding the storage format of images in the cache. This information is needed to construct urls to images in jpeg and other formats. ITiledMapServer2 also has a GetCacheDescriptionInfo method that allows a client to efficiently retrieve information about a tiled map service using fewer round trip calls.

[C#]

Example 1: Print Cache Service's Description Information

/*
 *  The function prints all information coming from ICacheDescriptionInfo
 *  Inputs: a TiledMapServer2 object
 *  a map (dataframe) name
 *  Outputs: all information are printed on .NET Console
 */
private void printCacheInfo(ITiledMapServer2 pTiledMap2, string sMapName)
{
    ICacheDescriptionInfo pCacheDscInfo=pTiledMap2.GetCacheDescriptionInfo(sMapName);
    ICacheControlInfo pCacheCtrlInfo=pCacheDscInfo.CacheControlInfo;
    ILayerCacheInfos pLyrCacheInfos=pCacheDscInfo.LayerCacheInfos;
    ITileCacheInfo pTileCacheInfo=pCacheDscInfo.TileCacheInfo;
    ILODInfos pLODInfos=pTileCacheInfo.LODInfos;
    ITileImageInfo2 pTileImgInfo2=pCacheDscInfo.TileImageInfo as ITileImageInfo2;

    Console.WriteLine("CacheType: " + pCacheDscInfo.CacheType.ToString());
    Console.WriteLine("CacheControlInfo::");
    Console.WriteLine("   ClientCachingAllowed: " + pCacheCtrlInfo.ClientCachingAllowed.ToString());
    Console.WriteLine("LayerCacheInfos::");
    for (int i=0; i < pLyrCacheInfos.Count; i++)
        Console.WriteLine("   ID: " + pLyrCacheInfos.get_Element(i).ID.ToString() + "; HasCache: " + pLyrCacheInfos.get_Element(i).HasCache.ToString());
    Console.WriteLine("TileCacheInfo::");
    Console.WriteLine("   DPI: " + pTileCacheInfo.Dpi.ToString());
    Console.WriteLine("   Origin: " + pTileCacheInfo.Origin.X.ToString() + "," + pTileCacheInfo.Origin.Y.ToString());
    Console.WriteLine("   SRS: " + pTileCacheInfo.SpatialReference.Name);
    Console.WriteLine("   TileCols: " + pTileCacheInfo.TileCols.ToString());
    Console.WriteLine("   TileRows: " + pTileCacheInfo.TileRows.ToString());
    Console.WriteLine("   LODInfos::");
    for (int i=0; i < pLODInfos.Count; i++)
        Console.WriteLine("      LevelID: " + pLODInfos.get_Element(i).LevelID + "; Resolution: " + pLODInfos.get_Element(i).Resolution + "; Scale: " + pLODInfos.get_Element(i).Scale);
    Console.WriteLine("TileImageInfo::");
    Console.WriteLine("   Antialiasing: " + pTileImgInfo2.Antialiasing.ToString());
    Console.WriteLine("   CompressionQuality: " + pTileImgInfo2.CompressionQuality.ToString());
    Console.WriteLine("   Format: " + pTileImgInfo2.Format);
}

 

 

Example 2: Find out map tiles for Single Fused Cached Service that intersects with a map extent at a specific scale

/*
 * The funtion computes tile�s URLs that interects the specified map extent
 * Inputs: a TiledMapServer
 *           map (dataframe) name
 *           sTileHandlerURL: is the endpoint URL for the service can be access from IAGSServerObjectName.URL property
 *           MapExtent for which tiles will be calculated
 *           a CacheDescriptionInfo object
 *           Cached scale
 * Outputs: (1) Prints Static URLs for each tile on .NET Console
 *              (2) Prints URLs for each tile (to be used with TileHandler) on .NET Console
 */
private void getMapTilesURL(ITiledMapServer2 pTileMapServer2, string sMapName, string sTileHandlerURL, IEnvelope pMapExtent, double dScale)
{
    ICacheDescriptionInfo pCacheDescriptionInfo=pTileMapServer2.GetCacheDescriptionInfo(sMapName);
    string sCachedVirtualDirectory=pTileMapServer2.GetVirtualCacheDirectory(sMapName, -1);    //LayerID=-1 for Single Fused Cached

    IPoint pTileOrigin=pCacheDescriptionInfo.TileCacheInfo.Origin;
    double dblOriginX=pTileOrigin.X;
    double dblOriginY=pTileOrigin.Y;

    /***********************
     * Getting cache resolution & levelID for the specified scale
     ***********************/
    ILODInfos pLODInfos=pCacheDescriptionInfo.TileCacheInfo.LODInfos;
    double dLODResolution=-1; int iLevelID=0;
    for (int i=0; i < pLODInfos.Count; i++)
    {
        if (pLODInfos.get_Element(i).Scale == dScale)
        {
            dLODResolution=pLODInfos.get_Element(i).Resolution;
            iLevelID=pLODInfos.get_Element(i).LevelID;
            break;
        }
    }
    if (dLODResolution == -1)
    {
        Exception e=new Exception(String.Format("LOD for Scale:{0} not found!",dScale));
        throw e;
    }


    /***********************
     * Finding the tile that contains map extent's upper-left & lower-right corner
     ***********************/
    //Calculating Tile's width & height in map unit
    double dblTileWidth=pCacheDescriptionInfo.TileCacheInfo.TileCols * dLODResolution;
    double dblTileHeight=pCacheDescriptionInfo.TileCacheInfo.TileRows * dLODResolution;

    IPoint pPntExtentUL, pPntExtentLR;
    pPntExtentUL=pMapExtent.UpperLeft;
    pPntExtentLR=pMapExtent.LowerRight;
   
    // Tile's Row & Column for map's upper-left corner
    int intULTCOL=(int)Math.Floor((pPntExtentUL.X - dblOriginX) / dblTileWidth);
    int intULTROW=(int)Math.Floor((dblOriginY - pPntExtentUL.Y) / dblTileHeight);

    // Tile's Row & Column for map's lower-right corner
    int intLRTCOL=(int)Math.Floor((pPntExtentLR.X - dblOriginX) / dblTileWidth);
    int intLRTROW=(int)Math.Floor((dblOriginY - pPntExtentLR.Y) / dblTileHeight);


    /***********************
     * Generating URL for each tile that intersects with the map extent
     ***********************/
    string sImgExtension="";
    if (pCacheDescriptionInfo.TileImageInfo.Format == "JPEG")
        sImgExtension="jpg";
    else
        sImgExtension="png";

    string url;
    for (int r=intULTROW; r <= intLRTROW; r++)
    {
        for (int c=intULTCOL; c <= intLRTCOL; c++)
        {
            url=string.Format("L{0:D2}/R{1:D8}/C{2:D8}",iLevelID,r,c);
            Console.WriteLine(sCachedVirtualDirectory + "/" + url + "." + sImgExtension);
            Console.WriteLine(sTileHandlerURL + string.Format("?mapname={0}&layer={1}&level={2}&row={3}&column={4}&format={5}", sMapName, "_alllayers", iLevelID, r, c, sImgExtension));
        }
    }
}

 

 

Example 3: Getting image for a specific tile using GetMapTileEx() function for a Single Fused Cached serivce

/*
 * The funtion gets tiles using GetMapTileEx() function and load that on a PictureBox control
 * Inputs: a TiledMapServer
 *   Level Id
 *  Row Id
 *  Column Id
 *  Image format (by using ICacheDescriptionInfo.TileImageInfo.Format property)
 */
private void getMapTileImg(ITiledMapServer2 pTileMapServer2, int l, int r, int c, string format)
{
    int f=0;
    switch (format)
    {
        case "PNG":
            f=0;
            break;
        case "PNG24":
            f=1;
            break;
        case "PNG32":
            f=2;
            break;
        case "JPEG":
            f=3;
            break;
        default:
            f=0;
            break;
    }

    byte[] imgTile;
    try
    {
        imgTile=pTileMapServer2.GetMapTileEx(m_strDefMapName, l, r, c, f);
    }
    catch (Exception)
    {
        MessageBox.Show(String.Format("Problem loading tile for Level:{0}, Row:{1}, Col: {2}", l, r, c), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    MemoryStream ms=new MemoryStream(imgTile);
    Bitmap bmp=new Bitmap(ms);

    pictureBox1.Image=bmp;
}