SuperMap.WinRT.Mapping.TiledDynamicRESTLayer.GetTile C# (CSharp) Method

GetTile() public method

${Mapping_TiledDynamicRESTLayer_method_GetTile_D}
public GetTile ( int indexX, int indexY, double resolution, CancellationToken cancellationToken ) : MapImage
indexX int ${Mapping_TiledDynamicRESTLayer_method_GetTile_param_indexX}
indexY int ${Mapping_TiledDynamicRESTLayer_method_GetTile_param_indexY}
resolution double ${Mapping_TiledDynamicRESTLayer_method_GetTile_param_resolution}
cancellationToken System.Threading.CancellationToken ${Mapping_TiledDynamicRESTLayer_method_GetTile_param_cancellationToken}
return MapImage
        public override MapImage GetTile(int indexX, int indexY, double resolution, CancellationToken cancellationToken)
        {
            double scale = ScaleHelper.ScaleConversion(resolution, this.Dpi, this.CRS);
            string str = string.Empty;

            str = string.Format("{0}/tileImage.{1}?scale={2}&x={3}&y={4}&width={5}&height={5}&transparent={6}",
                       Url, ImageFormat.ToLower(), scale.ToString(CultureInfo.InvariantCulture), indexX, indexY, TileSize, Transparent);

            if (!EnableServerCaching)
            {
                str += string.Format("&cacheEnabled={0}&t={1}", EnableServerCaching.ToString().ToLower(), DateTime.Now.Ticks.ToString());
            }

            if (!string.IsNullOrEmpty(LayersID))
            {
                str += string.Format("&layersID={0}", layersID);
            }
            if (ClipRegion != null)
            {
                str += "&clipRegionEnabled=True&";
                str += string.Format("clipRegion={0}", ServerGeometry.ToJson(ClipRegion.ToServerGeometry()));
            }
            if (MaxVisibleVertex != int.MaxValue && MaxVisibleVertex >= 0)
            {
                str += string.Format("&maxVisibleVertex={0}", MaxVisibleVertex);
            }
            if (!Point2D.IsNullOrEmpty(this.Origin))
            {
                // origin={"x":-200,"y":45},
                str += "&origin={" + string.Format("\"x\":{0},\"y\":{1}", this.Origin.X, this.Origin.Y) + "}";
            }
            //iServer tileImage请求中只要存在prjCoordSys参数就会把图片生成到temp目录下,
            //所以如果CRS和服务端一致,就不传这个参数上去了。
            if (this.mapService != null && this.mapService.MapServiceInfo != null
                && this.mapService.MapServiceInfo.PrjCoordSys != null)
            {
                CoordinateReferenceSystem tempCRS = new CoordinateReferenceSystem();
                if (_mapServiceDefault.MapServiceInfo != null)
                {
                    tempCRS.WKID = this._mapServiceDefault.MapServiceInfo.PrjCoordSys.EpsgCode;
                    tempCRS.Unit = this._mapServiceDefault.MapServiceInfo.CoordUnit;
                }
                if (!CoordinateReferenceSystem.Equals(tempCRS, this.CRS, true))
                {
                    if (this.CRS != null && this.CRS.WKID > 0)
                    {
                        str += "&prjCoordSys={\"epsgCode\":" + this.CRS.WKID + "}";
                    }
                }
            }
            str += string.Format("&customParams={0}", CustomParams);
            MapImage mapImage = new MapImage();
            mapImage.MapImageType = MapImageType.Url;
            mapImage.Url = str;
            return mapImage;
        }