${mapping_MapImage_Title}
/// <summary>${mapping_CloudLayer_method_GetTileUrl_D}</summary> public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { MapImage mapImage = new MapImage(); mapImage.Url = String.Format(this.Url, this.MapName, this.type, indexX, indexY, level); mapImage.MapImageType = MapImageType.Url; return mapImage; }
public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { string subDomain = subDomains[(indexX + indexY + level) % subDomains.Length]; MapImage mapImage = new MapImage(); mapImage.MapImageType = MapImageType.Url; mapImage.Url=string.Format(this.Url, subDomain, level, indexX, indexY); return mapImage; }
public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { StringBuilder keyBuilder = new StringBuilder(); for (int i = level; i >= 0; i--) { int num2 = ((int)1) << i; int num = ((indexX & num2) >> i) | (((indexY & num2) != 0) ? 2 : 0); keyBuilder.Append(num); } int num3 = ((indexY & 1) << 1) | (indexX & 1); MapImage mapImage = new MapImage(); mapImage.MapImageType = MapImageType.Url; mapImage.Url = string.Format(this.Url, num3, keyBuilder); return mapImage; }
public async Task<byte[]> ImageReadAsync(int width, int height, double resolution, int level, int column, int row) { MapImage image = new MapImage(); image.MapImageType = MapImageType.Data; try { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(MBTilesPath); AsyncTableQuery<MBTilesData> table = connection.Table<MBTilesData>(); MBTilesData data = await table.Where(c => c.Column == column && c.Resolution == resolution && c.Row == row).FirstOrDefaultAsync(); if (data != null) { image.Data = data.Data; } return image.Data; } catch(Exception ex) { return null; } finally { } }
/// <summary>${mapping_TiledDynamicLayer_method_GetTile_D}</summary> /// <returns>${mapping_TiledDynamicLayer_method_GetTile_param_return}</returns> /// <param name="indexX">${mapping_TiledDynamicLayer_method_GetTile_param_indexX}</param> /// <param name="indexY">${mapping_TiledDynamicLayer_method_GetTile_param_indexY}</param> /// <param name="resolution">${mapping_TiledDynamicLayer_method_GetTile_param_resolution}</param> /// <param name="cancellationToken">${mapping_TiledDynamicLayer_method_GetTile_param_cancellationToken_D}</param> public override MapImage GetTile(int indexX, int indexY, double resolution, CancellationToken cancellationToken) { Rectangle2D bounds = this.GetBBox(resolution, indexY, indexX); if (CRS == null) { throw new ArgumentNullException(ExceptionStrings.CRSIsNull); } int wkid = CRS.WKID; StringBuilder imgURL = new StringBuilder(); imgURL.Append(ProxyUrl + Url); imgURL.Append("?service=WMS&request=GetMap"); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&width={0}", TileSize); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&height={0}", TileSize); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&format=image/{0}", ImageFormat); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&layers={0}", new object[] { (this.Layers == null) ? "" : String.Join(",", Layers) }); imgURL.Append("&styles="); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&bgcolor={0}", BgColor); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&transparent={0}", Transparent); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&version={0}", Version); if (this.LowerThan13Version()) { imgURL.AppendFormat(CultureInfo.InvariantCulture, "&SRS=EPSG:{0}", wkid); imgURL.AppendFormat(CultureInfo.InvariantCulture, "&bbox={0},{1},{2},{3}", bounds.Left, bounds.Bottom, bounds.Right, bounds.Top); } else { imgURL.AppendFormat(CultureInfo.InvariantCulture, "&CRS=EPSG:{0}", wkid); if (isInRange(wkid)) { imgURL.AppendFormat(CultureInfo.InvariantCulture, "&bbox={0},{1},{2},{3}", bounds.Bottom, bounds.Left, bounds.Top, bounds.Right); } else { imgURL.AppendFormat(CultureInfo.InvariantCulture, "&bbox={0},{1},{2},{3}", bounds.Left, bounds.Bottom, bounds.Right, bounds.Top); } } MapImage mapImage = new MapImage(); mapImage.MapImageType = MapImageType.Url; mapImage.Url = imgURL.ToString(); return mapImage; }
/// <summary>${mapping_TiledWMTSLayer_method_GetTileUrl_D}</summary> public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { MapImage mapImage = new MapImage(); mapImage.MapImageType = MapImageType.Url; if (tileMatrixIdentifiers == null) { mapImage.Url = string.Format(this.Url, tileMatrixs[level].Name, indexY, indexX); return mapImage; } else { int index = findMatrixLevel(this.Resolution); if (index == -1) { return null; } string name = string.Empty; if (tileMatrixs != null) { name = tileMatrixs[index].Name; if (!CheckMatrix(name)) { name = string.Empty; } } else { name = tileMatrixIdentifiers[index]; } //string index = tileMatrixIdentifiers[]; if (string.IsNullOrEmpty(name)) { return null; } else { mapImage.Url = string.Format(this.Url, name, indexY, indexX); return mapImage; } } }
public static async Task<MapImage> GetTile(string path, int column, int row, double resolution) { MapImage image = new MapImage(); image.MapImageType = MapImageType.Data; try { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(path); AsyncTableQuery<MBTilesData> table = connection.Table<MBTilesData>(); MBTilesData data = await table.Where(c => c.Column == column && c.Resolution == resolution && c.Row == row).FirstOrDefaultAsync(); if (data != null) { image.Data = data.Data; } } catch { } return image; }
//重写返回Url函数 public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { MapImage mapImage = new MapImage(); mapImage.MapImageType = MapImageType.Url; level += this.levelOffset; string serverURL = TileTDTMapsLayer.URL; string lt = this.layerType; if (this.isLabel) { if (lt == "vec") lt = "cva"; if (lt == "img") lt = "cia"; if (lt == "ter") lt = "cta"; } Random random = new Random(); serverURL = serverURL.Replace("{subdomain}", Math.Round(random.NextDouble() * 7).ToString()); serverURL = serverURL.Replace("{tileX}", indexX.ToString()); serverURL = serverURL.Replace("{tileY}", indexY.ToString()); serverURL = serverURL.Replace("{level}", level.ToString()); serverURL = serverURL.Replace("{proj}", this.proj); serverURL = serverURL.Replace("{layerType}", lt); mapImage.Url = serverURL; return mapImage; }
/// <summary>${Mapping_TiledDynamicRESTLayer_method_GetTile_D}</summary> /// <returns>${Mapping_TiledDynamicRESTLayer_method_GetTile_return}</returns> /// <param name="indexX">${Mapping_TiledDynamicRESTLayer_method_GetTile_param_indexX}</param> /// <param name="indexY">${Mapping_TiledDynamicRESTLayer_method_GetTile_param_indexY}</param> /// <param name="resolution">${Mapping_TiledDynamicRESTLayer_method_GetTile_param_resolution}</param> /// <param name="cancellationToken">${Mapping_TiledDynamicRESTLayer_method_GetTile_param_cancellationToken}</param> 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; }