/// <summary>${WP_mapping_CloudLayer_method_GetTileUrl_D}</summary> public override MapImage GetTile(int indexX, int indexY, int level, CancellationToken cancellationToken) { MapImage image = new MapImage(); image.MapImageType = MapImageType.Url; image.Url=String.Format(System.Globalization.CultureInfo.InvariantCulture,this.Url, this.MapName, this.type, indexX, indexY, level); return image; }
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>${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_D}</summary> /// <returns>${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_return}</returns> /// <param name="indexX">${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_param_indexX}</param> /// <param name="indexY">${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_param_indexY}</param> /// <param name="resolution">${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_param_resolution}</param> /// <param name="cancellationToken">${WP_Mapping_TiledDynamicRESTLayer_method_GetTileUrl_param_cancellationToken}</param> public override MapImage GetTile(int indexX, int indexY, double resolution, CancellationToken cancellationToken) { double scale = 0; scale = ScaleHelper.ScaleConversion(resolution, this.Dpi, this.CRS); string str = string.Empty; str = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}/tileImage.{1}?scale={2}&x={3}&y={4}&width={5}&height={5}&transparent={6}&t={7}", Url, ImageFormat.ToLower(), scale.ToString(CultureInfo.InvariantCulture), indexX, indexY, TileSize, Transparent, _randomKey); if (!EnableServerCaching) { str += string.Format("&cacheEnabled={0}", EnableServerCaching.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()); } if (!string.IsNullOrEmpty(LayersID)) { str += string.Format("&layersID={0}", layersID); } if (ClipRegion != null) { str += "&clipRegionEnabled=True&"; str += string.Format("clipRegion={0}", JsonConvert.SerializeObject(ClipRegion.ToServerGeometry())); } if (MaxVisibleVertex != int.MaxValue && MaxVisibleVertex >= 0) { str += string.Format(System.Globalization.CultureInfo.InvariantCulture, "&maxVisibleVertex={0}", MaxVisibleVertex); } if (!Point2D.IsNullOrEmpty(this.Origin)) { // origin={"x":-200,"y":45}, str += "&origin={" + string.Format(CultureInfo.InvariantCulture, "\"x\":{0},\"y\":{1}", this.Origin.X, this.Origin.Y) + "}"; } //iServer tileImage请求中只要存在prjCoordSys参数就会把图片生成到temp目录下, //所以如果CRS和服务端一致,就不传这个参数上去了。 if (this.mapService != null && this.mapService.LastResult != null && this.mapService.LastResult.PrjCoordSys != null) { CoordinateReferenceSystem tempCRS = new CoordinateReferenceSystem(); if (_mapServiceDefault.LastResult != null) { tempCRS.WKID = this._mapServiceDefault.LastResult.PrjCoordSys.EpsgCode; tempCRS.Unit = this._mapServiceDefault.LastResult.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 image = new MapImage(); image.MapImageType = MapImageType.Url; image.Url = str; return image; }
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; }