/// <summary> /// 初始化TileInfo类的新实例,通过指定的对象初始化新对象的值。 /// </summary> /// <param name="tileInfo">格网图片信息。</param> public TileInfo(TileInfo tileInfo) { if (tileInfo == null) return; this.TileIndex = new TileIndex(tileInfo.TileIndex); this.Height = tileInfo.Height; this.Width = tileInfo.Width; this.Scale = tileInfo.Scale; }
public void GetTileTest_Normal() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); TileInfo tileInfo = new TileInfo(); tileInfo.TileIndex = new TileIndex() { ColIndex = 2, RowIndex = 1 }; tileInfo.Height = 256; tileInfo.Width = 256; tileInfo.Scale = 0.0000002; MapImage mapImage = map.GetTile("世界地图", tileInfo, null); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); System.Drawing.Color systemColor = bmp.GetPixel(136, 48); Assert.IsTrue(systemColor.R == 153); Assert.IsTrue(systemColor.G == 179); Assert.IsTrue(systemColor.B == 204); } }
public MapImage GetTile(string mapName, TileInfo tileInfo, ImageOutputOption imageOutputOption) { int scale = (int)Math.Floor(1 / tileInfo.Scale); string url = string.Format("{0}/output/cache/{1}_{2}x{3}/{4}/{5}/{6}.png", this._serviceUrl, mapName, tileInfo.Width, tileInfo.Height, scale, tileInfo.TileIndex.RowIndex, tileInfo.TileIndex.ColIndex); MapImage mapImage = null; if (imageOutputOption == null || (imageOutputOption != null && imageOutputOption.ImageReturnType == ImageReturnType.URL)) { mapImage = new MapImage() { ImageUrl = url }; } else { byte[] imageData = SynchHttpRequest.GetRequestBytes(url); mapImage = new MapImage() { ImageData = imageData }; } return mapImage; }
/// <summary> /// 根据地图分块信息和地图参数设置,获取格网图片。 /// </summary> /// <param name="mapName">地图名。【必设参数】</param> /// <param name="tileInfo">地图分块信息。【必设参数】</param> /// <param name="imageOutputOption">图片输出设置。</param> /// <param name="mapParameter">地图参数。</param> /// <returns>所获取的格网图片信息。</returns> public MapImage GetTile(string mapName, TileInfo tileInfo, ImageOutputOption imageOutputOption, MapParameter mapParameter) { string strImageFormat = "png"; bool returnUrl = false; if (imageOutputOption != null) { strImageFormat = imageOutputOption.ImageOutputFormat.ToString().ToLower(); if (imageOutputOption.ImageReturnType == ImageReturnType.URL) { returnUrl = true; } } if (tileInfo == null || tileInfo.TileIndex == null) { return null; } string url = string.Format("{0}/maps/{1}/tileImage.{2}?", this._serviceUrl, HttpUtility.UrlEncode(mapName), strImageFormat); StringBuilder requestParamBuilder = new StringBuilder(); requestParamBuilder.Append(string.Format("scale={0}&x={1}&y={2}&width={3}&height={4}", tileInfo.Scale, tileInfo.TileIndex.ColIndex, tileInfo.TileIndex.RowIndex, tileInfo.Width, tileInfo.Height)); if (imageOutputOption != null) { requestParamBuilder.Append(string.Format("&transparent={0}&", imageOutputOption.Transparent)); } if (mapParameter != null) { requestParamBuilder.Append(this.GetMapRequestByMapParameter(mapName, mapParameter, false, true, true, true)); } //进行重定向 MapImage mapImage = new MapImage(); url = url + requestParamBuilder.ToString(); if (returnUrl) { mapImage.ImageUrl = url; } else { mapImage.ImageData = SynchHttpRequest.GetRequestBytes(url); } return mapImage; }
/// <summary> /// 根据地图分块信息,获取格网图片。 /// </summary> /// <param name="mapName">地图名。【必设参数】</param> /// <param name="tileInfo">地图分块信息。【必设参数】</param> /// <param name="imageOutputOption">图片输出设置。</param> /// <returns>所获取的格网图片信息。</returns> public MapImage GetTile(string mapName, TileInfo tileInfo, ImageOutputOption imageOutputOption) { return this.GetTile(mapName, tileInfo, imageOutputOption, null); }
/// <summary> /// 获取SuperMapCloud上默认"quanguo"的格网图片。 /// </summary> /// <param name="tileInfo">地图分块信息。</param> /// <param name="imageOutputOption">图片输出设置。</param> /// <returns>所获取的格网图片信息。</returns> public MapImage GetTile(TileInfo tileInfo, ImageOutputOption imageOutputOption) { return this.GetTile("quanguo", tileInfo, imageOutputOption); }
/// <summary> /// 根据指定地图名及地图分块信息,获取格网图片。 /// </summary> /// <param name="mapName">地图名。</param> /// <param name="tileInfo">地图分块信息。</param> /// <param name="imageOutputOption">图片输出设置。</param> /// <returns>所获取的格网图片信息。</returns> /// <example> /// 以下代码演示了如何访问SuperMap Cloud云地图服务。 /// <code> ///using System; ///using System.Collections.Generic; ///using System.Text; ///using SuperMap.Connector; ///using SuperMap.Connector.Utility; /// ///class Program ///{ /// static void Main(string[] args) /// { /// CloudMap cloudMap = new CloudMap("http://www.supermapcloud.com"); //初始化地图对象 /// TileInfo tileInfo = new TileInfo() //分块索引信息 /// { /// Height = 256, /// Width = 256, /// Scale = 1 / 470000000, /// TileIndex = new TileIndex() /// { /// ColIndex = 0, /// RowIndex = 0 /// } /// }; /// ImageOutputOption option = new ImageOutputOption() /// { /// ImageOutputFormat = ImageOutputFormat.PNG, /// ImageReturnType = ImageReturnType.URL, /// }; /// MapImage mapImage = cloudMap.GetTile(tileInfo, option); //获取地图。 /// } ///} /// </code> /// </example> public MapImage GetTile(string mapName, TileInfo tileInfo, ImageOutputOption imageOutputOption) { return _provider.GetTile(mapName, tileInfo, imageOutputOption); }
private string MakeTileImageUrl(GPoint pos, int zoom, string language) { //double scale = _scales[0]; //if (_scales.Length >= zoom && zoom > 0) //{ // scale = _scales[zoom - 1]; //} double scale = _mapScales[zoom]; SuperMap.Connector.Utility.ImageOutputOption option = new SuperMap.Connector.Utility.ImageOutputOption(); option.ImageReturnType = SuperMap.Connector.Utility.ImageReturnType.URL; option.ImageOutputFormat = SuperMap.Connector.Utility.ImageOutputFormat.PNG; option.Transparent = false; SuperMap.Connector.Utility.TileInfo iserverTileInfo = new SuperMap.Connector.Utility.TileInfo(); iserverTileInfo.Height = TileSize; iserverTileInfo.Width = TileSize; iserverTileInfo.TileIndex = new SuperMap.Connector.Utility.TileIndex(); iserverTileInfo.TileIndex.ColIndex = (int)(pos.X); iserverTileInfo.TileIndex.RowIndex = (int)pos.Y; iserverTileInfo.Scale = scale; return _map.GetTile(this.MapName, iserverTileInfo, option, null).ImageUrl; }
public override string GetTileUrl(int x, int y, double resolution) { Map map = new Map(Url); TileInfo iserverTileInfo = new TileInfo(); iserverTileInfo.Height = Convert.ToUInt32(this.TileSize); iserverTileInfo.Width = Convert.ToUInt32(this.TileSize); ; iserverTileInfo.TileIndex = new SuperMap.Connector.Utility.TileIndex(); iserverTileInfo.TileIndex.ColIndex = x; iserverTileInfo.TileIndex.RowIndex = y; double scale = this._referScale * _referResolution / resolution; iserverTileInfo.Scale = scale; SuperMap.Connector.Utility.ImageOutputOption option = new SuperMap.Connector.Utility.ImageOutputOption(); option.ImageReturnType = SuperMap.Connector.Utility.ImageReturnType.URL; option.ImageOutputFormat = SuperMap.Connector.Utility.ImageOutputFormat.PNG; option.Transparent = false; MapImage img = map.GetTile(MapName, iserverTileInfo, option); System.Diagnostics.Debug.WriteLine(img.ImageUrl); return img.ImageUrl; }
/// <summary> /// 根据地图分块信息和地图参数设置,获取格网图片。 /// </summary> /// <param name="mapName">地图名称。</param> /// <param name="tileInfo">地图分块信息。</param> /// <param name="imageOutputOption">图片输出设置。</param> /// <param name="mapParameter">地图参数。</param> /// <returns>所获取的格网图片信息。</returns> public MapImage GetTile(string mapName, TileInfo tileInfo, ImageOutputOption imageOutputOption, MapParameter mapParameter) { return _mapProvider.GetTile(mapName, tileInfo, imageOutputOption, mapParameter); }
public void GetTileTest_ByTempLayer() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); TileInfo tileInfo = new TileInfo(); tileInfo.Scale = 0.00000002; tileInfo.Height = 512; tileInfo.Width = 512; TileIndex tileIndex = new TileIndex() { RowIndex = 2, ColIndex = 1 }; tileInfo.TileIndex = tileIndex; MapParameter mapParameter = map.GetDefaultMapParameter("世界地图"); List<Layer> tempLayer = new List<Layer>(); tempLayer.Add(mapParameter.Layers[12]); mapParameter.Layers = tempLayer; ImageOutputOption imageOutputOption = new ImageOutputOption(); imageOutputOption.ImageReturnType = ImageReturnType.BINARY; imageOutputOption.Transparent = false; imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG; MapImage mapImage = map.GetTile("世界地图", tileInfo, imageOutputOption, mapParameter); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); Assert.IsTrue(bmp.Width == 512); Assert.IsTrue(bmp.Height == 512); System.Drawing.Color color = bmp.GetPixel(240, 389); Assert.IsTrue(color.R == 242); Assert.IsTrue(color.G == 239); Assert.IsTrue(color.B == 233); } Assert.IsNull(null); }