/// <summary>
 /// 使用指定的ImageOutputOption对象初始化ImageOutputOption类的新实例。
 /// </summary>
 /// <param name="imageOutputOption">ImageOutputOption对象。</param>
 public ImageOutputOption(ImageOutputOption imageOutputOption)
 {
     if (imageOutputOption == null) return;
     this.ImageOutputFormat = imageOutputOption.ImageOutputFormat;
     this.Transparent = imageOutputOption.Transparent;
     this.ImageReturnType = imageOutputOption.ImageReturnType;
 }
 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;
 }
        public byte[] GetTile(TileInfo tileInfo)
        {
            int iLevel = 0;
            if (!int.TryParse(tileInfo.Index.LevelId, out iLevel)) return null;
            double scale = _scales[iLevel];

            SuperMap.Connector.Utility.TileInfo iserverTileInfo = new SuperMap.Connector.Utility.TileInfo();
            iserverTileInfo.Height = this._tileSize;
            iserverTileInfo.Width = this._tileSize;
            iserverTileInfo.TileIndex = new SuperMap.Connector.Utility.TileIndex();
            iserverTileInfo.TileIndex.ColIndex = tileInfo.Index.Col;
            iserverTileInfo.TileIndex.RowIndex = tileInfo.Index.Row;
            iserverTileInfo.Scale = scale;

            SuperMap.Connector.Utility.ImageOutputOption option = new Utility.ImageOutputOption();
            option.Transparent = false;
            if (mapParameter != null)
            {
                option.Transparent = true;
            }

            Map map = new Map(this._serviceUrl);
            return map.GetTile(this._mapName, iserverTileInfo, option, this.mapParameter).ImageData;
        }
        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;
        }
Beispiel #5
0
 /// <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);
 }
        /// <summary>
        /// 根据资源图片参数获取资源图片。
        /// </summary>
        /// <param name="mapName">地图名称。【比设参数】</param>
        /// <param name="resourceParameter">资源图片参数,如生成的图片的高度、宽度、类型,资源的类型、风格等。【比设参数】</param>
        /// <param name="imageOutputOption">资源图片输出设置。</param>
        /// <returns>资源图片对象。</returns>
        public ResourceImage GetResource(string mapName, ResourceParameter resourceParameter, ImageOutputOption imageOutputOption)
        {
            if (string.IsNullOrEmpty(mapName)) throw new ArgumentNullException("mapName", Resources.ArgumentIsNotNull);
            if (resourceParameter == null) throw new ArgumentNullException("resourceParameter", Resources.ArgumentIsNotNull);
            string strImageFormat = "png";
            bool returnUrl = false;
            if (imageOutputOption != null)
            {
                strImageFormat = imageOutputOption.ImageOutputFormat.ToString().ToLower();
                if (imageOutputOption.ImageReturnType == ImageReturnType.URL)
                {
                    returnUrl = true;
                    strImageFormat = "json";
                }
            }
            string baseUrl = string.Format("{0}/maps/{1}/symbol.{2}?", this._serviceUrl, HttpUtility.UrlEncode(mapName), strImageFormat);
            StringBuilder requestParamBuilder = new StringBuilder();
            requestParamBuilder.Append(baseUrl);
            requestParamBuilder.Append(string.Format("resourceType={0}&", resourceParameter.Type.ToString()));
            if (resourceParameter.Style != null)
            {
                requestParamBuilder.Append(string.Format("style={0}&", JsonConvert.SerializeObject(resourceParameter.Style)));
            }
            requestParamBuilder.Append(string.Format("picWidth={0}&", resourceParameter.Width));
            requestParamBuilder.Append(string.Format("picHeight={0}&", resourceParameter.Height));
            if (imageOutputOption != null)
            {
                requestParamBuilder.Append(string.Format("transparent={0}&", imageOutputOption.Transparent));
            }
            //if (resourceParameter.ForeColor != null)
            //{
            //    requestParamBuilder.Append(string.Format("foreColor={0}&", JsonConvert.SerializeObject(resourceParameter.ForeColor)));
            //}
            //if (resourceParameter.BackColor != null)
            //{
            //    requestParamBuilder.Append(string.Format("backColor={0}&", JsonConvert.SerializeObject(resourceParameter.BackColor)));
            //}
            //进行重定向
            requestParamBuilder.Append(string.Format("redirect={0}&", "true"));
            ResourceImage resourceImage = new ResourceImage();
            if (returnUrl)
            {
                string symbolResult = SynchHttpRequest.GetRequestString(requestParamBuilder.ToString());
                resourceImage.ImageUrl = JsonConvert.DeserializeObject<Dictionary<string, object>>(symbolResult)["resourceImageUrl"].ToString();
            }
            else
            {
                resourceImage.ImageData = SynchHttpRequest.GetRequestBytes(requestParamBuilder.ToString());
            }

            return resourceImage;
        }
Beispiel #7
0
        public void GetOverviewTest_MapParameterISNull()
        {
            Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
            string mapName = "世界地图";

            ImageOutputOption option = new ImageOutputOption();
            option.ImageOutputFormat = ImageOutputFormat.PNG;
            option.ImageReturnType = ImageReturnType.URL;
            Overview image = map.GetOverview(mapName, null, option);
            Assert.IsNotNull(image.ImageUrl);
            Assert.IsNull(image.ImageData);
            Assert.AreEqual(image.Viewer.Height, 256);
            Assert.AreEqual(image.Viewer.Width, 256);
            Assert.IsNotNull(image.LastModified);
            Assert.IsNotNull(image.ViewBounds);
            Assert.AreEqual(image.ViewBounds.LeftBottom.X, 84.30460372171433);
            Assert.AreEqual(image.ViewBounds.LeftBottom.Y, 15.704362017314319);
            Assert.AreEqual(image.MapName, mapName);
        }
        /// <summary>
        /// 根据地图参数、图片输出设置获取地图图片。
        /// </summary>
        /// <param name="mapName">地图名。【必设参数】</param>
        /// <param name="mapParameter">地图参数。【必设参数】</param>
        /// <param name="imageOutputOption">图片输出设置。</param>
        /// <returns>所获取的地图图片对象。</returns>
        public MapImage GetMapImage(string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption, bool returnMapParameter)
        {
            string strImageFormat = "png";
            bool returnUrl = false;
            if (imageOutputOption != null)
            {
                strImageFormat = imageOutputOption.ImageOutputFormat.ToString().ToLower();
                if (returnMapParameter)
                {
                    strImageFormat = "json";
                }
                if (imageOutputOption.ImageReturnType == ImageReturnType.URL)
                {
                    returnUrl = true;
                }
            }
            string url = string.Format("{0}/maps/{1}/image.{2}?", this._serviceUrl, HttpUtility.UrlEncode(mapName), strImageFormat);
            StringBuilder requestParamBuilder = new StringBuilder();

            if (imageOutputOption != null)
            {
                requestParamBuilder.Append(string.Format("transparent={0}&", imageOutputOption.Transparent));
            }
            if (mapParameter != null)
            {
                requestParamBuilder.Append(this.GetMapRequestByMapParameter(mapName, mapParameter, false, false, false, false));
            }
            MapImage mapImage = new MapImage();
            url = url + requestParamBuilder.ToString(); //用GET请求发送。
            if (returnMapParameter)
            {
                string requetResponse = SynchHttpRequest.GetRequestString(url, HttpRequestMethod.GET, "");
                Dictionary<string, object> jsonItems = JsonConvert.DeserializeObject<Dictionary<string, object>>(requetResponse);
                mapImage.ImageUrl = jsonItems["imageUrl"].ToString();
                mapImage.MapParameter = JsonConvert.DeserializeObject<MapParameter>(JsonConvert.SerializeObject(jsonItems["mapParam"]));
                return mapImage;
            }
            else if (returnUrl)
            {
                mapImage.ImageUrl = url;
            }
            else
            {
                mapImage.ImageData = SynchHttpRequest.GetRequestBytes(url);
            }

            return mapImage;
        }
 /// <summary>
 /// 获取地图的全幅显示图片。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="mapParameter">地图参数。</param>
 /// <param name="imageOutputOption">图片输出设置。</param>
 /// <returns>全幅显示图片对象。</returns>
 public MapImage GetEntireImage(string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption)
 {
     return GetEntireImage(mapName, null, mapParameter, imageOutputOption);
 }
Beispiel #10
0
 /// <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);
 }
 /// <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);
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 public void DynicProject()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     MapParameter mapParameter = new MapParameter();
     mapParameter.PrjCoordSys = new PrjCoordSys();
     mapParameter.PrjCoordSys.EpsgCode = 3857;
     mapParameter.Center = new Point2D(0, 0);
     mapParameter.Scale = 0.0000000013138464;
     mapParameter.Viewer = new Utility.Rectangle(0, 0, 256, 256);
     mapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;
     mapParameter.CacheEnabled = false;
     ImageOutputOption option = new ImageOutputOption();
     option.ImageOutputFormat = ImageOutputFormat.PNG;
     option.ImageReturnType = ImageReturnType.BINARY;
     MapImage image = map.GetMapImage("世界地图", mapParameter, option);
     Assert.IsTrue(image != null);
     using (MemoryStream stream = new MemoryStream(image.ImageData))
     {
         Bitmap bmp = (Bitmap)Image.FromStream(stream);
         System.Drawing.Color t = bmp.GetPixel(200, 230);
         Assert.IsTrue(t.A == 255);
         Assert.IsTrue(t.R == 196);
         Assert.IsTrue(t.G == 193);
         Assert.IsTrue(t.B == 225);
     }
 }
Beispiel #14
0
 public void GetResourceTest_LineID()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     string mapName = "世界地图";
     ResourceParameter parameter = new ResourceParameter();
     parameter.Style = new Style();
     parameter.Style.LineSymbolID = 5;
     parameter.Type = ResourceType.SYMBOLLINE;
     ImageOutputOption option = new ImageOutputOption();
     option.ImageOutputFormat = ImageOutputFormat.PNG;
     option.ImageReturnType = ImageReturnType.URL;
     ResourceImage image = map.GetResource(mapName, parameter, option);
     Assert.AreEqual(image.ImageUrl, "http://192.168.116.114:8090/iserver/output/resources/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/SYMBOLLINE/5_781806645.png");
 }
Beispiel #15
0
 public void GetResourceTest_MarkerIDError()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     string mapName = "世界地图";
     ResourceParameter parameter = new ResourceParameter();
     parameter.Style = new Style();
     parameter.Style.MarkerSymbolID = 200;
     parameter.Type = ResourceType.SYMBOLMARKER;
     ImageOutputOption option = new ImageOutputOption();
     option.ImageOutputFormat = ImageOutputFormat.BMP;
     option.ImageReturnType = ImageReturnType.URL;
     ResourceImage image = null;
     try
     {
         image = map.GetResource(mapName, parameter, option);
     }
     catch (ServiceException e)
     {
         Assert.AreEqual(e.Message, "获取资源图片的符号 ID 超出范围。");
     }
 }
Beispiel #16
0
 public void GetResourceTest_Marker()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     string mapName = "世界地图";
     ResourceParameter parameter = new ResourceParameter();
     parameter.Type = ResourceType.SYMBOLMARKER;
     ImageOutputOption option = new ImageOutputOption();
     option.ImageOutputFormat = ImageOutputFormat.PNG;
     option.ImageReturnType = ImageReturnType.URL;
     ResourceImage image = map.GetResource(mapName, parameter, option);
     Assert.AreEqual(image.ImageUrl, "http://192.168.116.114:8090/iserver/output/resources/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/SYMBOLMARKER/0_1160020228.png");
 }
Beispiel #17
0
        public void GetMapImage_CreateThemeGraph()
        {
            ThemeGraph themeGraph = new ThemeGraph();
            themeGraph.Type = ThemeType.GRAPH;
            themeGraph.GraphType = ThemeGraphType.BAR3D;
            themeGraph.GraduatedMode = GraduatedMode.SQUAREROOT;
            themeGraph.AxesDisplayed = true;
            themeGraph.MaxGraphSize = 1;
            themeGraph.MinGraphSize = 0.35;
            themeGraph.GraphTextDisplayed = true;
            themeGraph.GraphTextFormat = GraphTextFormat.VALUE;
            themeGraph.BarWidth = 0.03;

            var item1 = new ThemeGraphItem();
            item1.Caption = "1";
            item1.GraphExpression = "Pop_Rate95";
            var style1 = new SuperMap.Connector.Utility.Style();
            style1.FillForeColor = new SuperMap.Connector.Utility.Color(211, 111, 240);
            item1.UniformStyle = style1;

            var item2 = new ThemeGraphItem();
            item2.Caption = "人口";
            item2.GraphExpression = "Pop_Rate99";
            var style2 = new SuperMap.Connector.Utility.Style();
            style2.FillForeColor = new SuperMap.Connector.Utility.Color(92, 73, 234);
            item2.UniformStyle = style2;

            themeGraph.Items = new ThemeGraphItem[] { item1, item2 };

            UGCThemeLayer themeLayer = new UGCThemeLayer();
            themeLayer.DatasetInfo = new DatasetInfo();
            themeLayer.DatasetInfo.DataSourceName = "Jingjin";
            themeLayer.DatasetInfo.Name = "BaseMap_R";
            themeLayer.DatasetInfo.Type = DatasetType.REGION;
            themeLayer.Description = "动态统计专题图";

            themeLayer.UgcLayerType = UGCLayerType.THEME;
            themeLayer.Type = LayerType.UGC;
            themeLayer.Visible = true;
            themeLayer.Theme = themeGraph;

            MapParameter mapParameter = new MapParameter();
            mapParameter.CacheEnabled = false;
            mapParameter.Center = new Point2D(116.755063, 39.803942);
            mapParameter.Scale = 1.0 / 1589406.44119042;
            mapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;
            mapParameter.Name = "动态统计专题图";
            mapParameter.ColorMode = MapColorMode.DEFAULT;

            mapParameter.Layers = new List<Layer>();
            mapParameter.Layers.Add(themeLayer);
            mapParameter.Viewer = new SuperMap.Connector.Utility.Rectangle(0, 0, 500, 400);

            Map map = new Map("http://" + ip + ":8090/iserver/services/map-jingjin/rest");
            ImageOutputOption imgageOutputOption = new ImageOutputOption();

            MapImage imageResult = map.GetMapImage("京津地区人口分布图_专题图", mapParameter, imgageOutputOption);
            using (MemoryStream memoryStream = new MemoryStream(imageResult.ImageData))
            {
                Bitmap bmp = new Bitmap(memoryStream);
                Assert.IsTrue(bmp.Width == 500);
                Assert.IsTrue(bmp.Height == 400);
                Assert.IsTrue(bmp.GetPixel(309, 293).R == 211);
                Assert.IsTrue(bmp.GetPixel(309, 293).G == 111);
                Assert.IsTrue(bmp.GetPixel(309, 293).B == 240);
            }
        }
Beispiel #18
0
 public void GetMapImage_ReturnUrl()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     MapParameter mapParameter = new MapParameter()
     {
         Center = new Point2D(0, 0),
         Scale = 0.0000000013138464,
         Viewer = new Utility.Rectangle(0, 0, 256, 256)
     };
     ImageOutputOption option = new ImageOutputOption()
     {
         ImageOutputFormat = ImageOutputFormat.GIF,
         ImageReturnType = ImageReturnType.URL
     };
     MapImage mapImage = map.GetMapImage("世界地图", mapParameter, option);
     Assert.IsNotNull(mapImage);
     Assert.IsTrue(!string.IsNullOrWhiteSpace(mapImage.ImageUrl));
     HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(mapImage.ImageUrl);
     HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
     Stream stream = response.GetResponseStream();
     Assert.IsNotNull(stream);
 }
        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;
        }
Beispiel #20
0
 /// <summary>
 /// 根据地图参数、图片输出设置获取地图图片,可设置是否返回当前图片参数信息。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="mapParameter">地图参数。</param>
 /// <param name="imageOutputOption">图片输出设置。</param>
 /// <param name="returnMapParameter">是否返回图片参数信息。</param>
 /// <returns>所获取的地图图片对象。</returns>
 public MapImage GetMapImage(string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption, bool returnMapParameter)
 {
     return _mapProvider.GetMapImage(mapName, mapParameter, imageOutputOption, returnMapParameter);
 }
Beispiel #21
0
 /// <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);
 }
Beispiel #22
0
 /// <summary>
 /// 根据资源图片参数获取资源图片。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="resourceParameter">资源图片参数,如生成的图片的高度、宽度、类型,资源的类型、风格等。</param>
 /// <param name="imageOutputOption">资源图片输出设置。</param>
 /// <returns>资源图片对象。</returns>
 public ResourceImage GetResource(string mapName, ResourceParameter resourceParameter, ImageOutputOption imageOutputOption)
 {
     return _mapProvider.GetResource(mapName, resourceParameter, imageOutputOption);
 }
        /// <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;
        }
Beispiel #24
0
 /// <summary>
 /// 根据查询结果资源ID,获取查询结果高亮图片,图片只支持PNG格式。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="queryResultID">查询结果资源ID。</param>
 /// <param name="style">高亮风格设置。</param>
 /// <param name="mapParameter">地图参数。</param>
 /// <param name="imageOutputOption">图片输出设置。</param>
 /// <returns>高亮图片对象。</returns>
 /// <example>
 /// <code>
 /// ImageOutputOption imageOutputOption = new ImageOutputOption();
 /// imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG;
 /// imageOutputOption.ImageReturnType = ImageReturnType.URL;
 /// MapParameter mapParameter = map1.GetDefaultMapParameter("世界地图");
 /// mapParameter.ViewBounds = new Rectangle2D(-180, -90, 180, 90);
 /// mapParameter.RectifyType = RectifyType.BYVIEWBOUNDS;
 /// Style style = new Style();
 /// style.FillForeColor = new SuperMap.Connector.Utility.Color(0, 255, 0);
 /// Map map1 = new Map("http://localhost:8090/iserver/services/map-world/rest");
 /// //需要获取某次查询结果的queryResultID值
 /// MapImage actualResult = map1.GetHighlightImage("世界地图", queryResultID, style, mapParameter, imageOutputOption);
 /// </code>
 /// </example>
 public MapImage GetHighlightImage(string mapName, string queryResultID, Style style, MapParameter mapParameter, ImageOutputOption imageOutputOption)
 {
     return _mapProvider.GetHighlightImage(mapName, queryResultID, style, mapParameter, imageOutputOption);
 }
        /// <summary>
        /// 获取地图的鹰眼图片。
        /// </summary>
        /// <param name="mapName">地图名称。</param>
        /// <param name="mapParameter">地图参数。</param>
        /// <param name="imageOutputOption">图片输出设置。</param>
        /// <returns>鹰眼对象。</returns>
        public Overview GetOverview(string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption)
        {
            if (string.IsNullOrEmpty(mapName)) throw new ArgumentNullException("mapName", Resources.ArgumentIsNotNull);
            string strImageFormat = "png";
            bool returnUrl = false;
            if (imageOutputOption != null)
            {
                strImageFormat = imageOutputOption.ImageOutputFormat.ToString().ToLower();
                if (imageOutputOption.ImageReturnType == ImageReturnType.URL)
                {
                    returnUrl = true;
                    strImageFormat = "json";
                }
            }
            string url = string.Format("{0}/maps/{1}/overview.{2}?", this._serviceUrl, HttpUtility.UrlEncode(mapName), strImageFormat);
            StringBuilder requestParamBuilder = new StringBuilder();
            if (imageOutputOption != null)
            {
                requestParamBuilder.Append(string.Format("transparent={0}&", imageOutputOption.Transparent));
            }
            if (mapParameter != null)
            {
                requestParamBuilder.Append(GetMapRequestByMapParameter(mapName, mapParameter, true, false, false, false));
            }
            //进行重定向
            //requestParamBuilder.Append(string.Format("redirect={0}&", "true"));
            url = url + requestParamBuilder.ToString();
            Overview overview = new Overview();
            if (returnUrl)
            {
                string requetResponse = SynchHttpRequest.GetRequestString(url);
                Dictionary<string, object> jsonItems = JsonConvert.DeserializeObject<Dictionary<string, object>>(requetResponse);
                overview.ImageUrl = jsonItems["imageUrl"].ToString();
                overview.MapName = JsonConvert.DeserializeObject<string>(JsonConvert.SerializeObject(jsonItems["mapName"]));
                overview.LastModified = JsonConvert.DeserializeObject<long>(JsonConvert.SerializeObject(jsonItems["lastModified"]));
                overview.ViewBounds = JsonConvert.DeserializeObject<Rectangle2D>(JsonConvert.SerializeObject(jsonItems["viewBounds"]));
                overview.Viewer = JsonConvert.DeserializeObject<Rectangle>(JsonConvert.SerializeObject(jsonItems["viewer"]));
            }
            else
            {
                overview.ImageData = SynchHttpRequest.GetRequestBytes(url);
            }

            return overview;
        }
Beispiel #26
0
        //public MapImage GetHighlightImage(string mapName, string highlightTargetSetID, MapParameter mapParameter, ImageOutputOption imageOutputOption)
        //{
        //    return _mapProvider.GetHighlightImage(mapName, highlightTargetSetID, mapParameter, imageOutputOption);
        //}

        /// <summary>
        /// 获取地图的鹰眼图片。
        /// </summary>
        /// <param name="mapName">地图名称。</param>
        /// <param name="mapParameter">地图参数。</param>
        /// <param name="imageOutputOption">图片输出设置。</param>
        /// <returns>鹰眼对象。</returns>
        /// <example>
        /// <code>
        /// Map map1 = new Map("http://localhost:8090/iserver/services/map-world/rest");
        /// ImageOutputOption imageOutputOption = new ImageOutputOption();
        /// imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG;
        /// imageOutputOption.ImageReturnType = ImageReturnType.URL;
        /// imageOutputOption.Transparent = false;
        /// MapParameter mapParameter = map1.GetDefaultMapParameter("世界地图");
        /// Overview actualResult = map1.GetOverview("世界地图", mapParameter, imageOutputOption);
        /// </code>
        /// </example>
        public Overview GetOverview(string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption)
        {
            return _mapProvider.GetOverview(mapName, mapParameter, imageOutputOption);
        }
        /// <summary>
        /// 根据查询结果资源ID,获取查询结果高亮图片,图片只支持PNG格式。
        /// </summary>
        /// <param name="mapName">地图名称。</param>
        /// <param name="queryResultID">查询结果资源ID。</param>
        /// <param name="style">高亮风格设置。</param>
        /// <param name="mapParameter">地图参数。</param>
        /// <param name="imageOutputOption">图片输出设置。</param>
        /// <returns>高亮图片对象。</returns>
        public MapImage GetHighlightImage(string mapName, string queryResultID, Style style, MapParameter mapParameter, ImageOutputOption imageOutputOption)
        {
            if (string.IsNullOrEmpty(mapName)) throw new ArgumentNullException("mapName", Resources.ArgumentIsNotNull);
            if (string.IsNullOrEmpty(queryResultID)) throw new ArgumentNullException("queryResultID", Resources.ArgumentIsNotNull);
            string strImageFormat = "png";
            bool returnUrl = false;
            if (imageOutputOption != null)
            {
                strImageFormat = imageOutputOption.ImageOutputFormat.ToString().ToLower();
                if (imageOutputOption.ImageReturnType == ImageReturnType.URL)
                {
                    returnUrl = true;
                }
            }
            string url = string.Format("{0}/maps/{1}/highlightImage.{2}?", this._serviceUrl, HttpUtility.UrlEncode(mapName), strImageFormat);
            StringBuilder requestParamBuilder = new StringBuilder();
            requestParamBuilder.Append(string.Format("queryResultID={0}&", queryResultID));
            requestParamBuilder.Append(string.Format("style={0}&", JsonConvert.SerializeObject(style)));
            if (imageOutputOption != null)
            {
                requestParamBuilder.Append(string.Format("transparent={0}&", imageOutputOption.Transparent));
            }
            if (mapParameter != null)
            {
                requestParamBuilder.Append(GetMapRequestByMapParameter(mapName, mapParameter, true, false, false, false));
            }
            url = url + requestParamBuilder.ToString();
            MapImage mapImage = new MapImage();
            if (returnUrl)
            {
                mapImage.ImageUrl = url;
            }
            else
            {
                mapImage.ImageData = SynchHttpRequest.GetRequestBytes(url);
            }

            return mapImage;
        }
Beispiel #28
0
 /// <summary>
 /// 根据指定的图层范围获取地图的全幅显示图片。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="layerName">指定图层,以该图层内容的最小外接矩形作为全幅显示的地理范围。</param>
 /// <param name="mapParameter">地图参数。</param>
 /// <param name="imageOutputOption">图片输出设置。</param>
 /// <returns>全幅显示图片对象。</returns>
 public MapImage GetEntireImage(string mapName, string layerName, MapParameter mapParameter, ImageOutputOption imageOutputOption)
 {
     return _mapProvider.GetEntireImage(mapName, layerName, mapParameter, imageOutputOption);
 }
        //public ActionResult Map()
        //{
        //    return View();
        //}
        public ActionResult Map(string actionName)
        {
            ImageOutputOption imageOutputOption = new ImageOutputOption();
            imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG;
            imageOutputOption.ImageReturnType = ImageReturnType.URL;

            MapParameter currentMapParameter = Session["MapParameter"] as MapParameter;
            string url = string.Empty;
            if (currentMapParameter == null)
            {
                MapParameter defaultMapParameter = map.GetDefaultMapParameter(mapName);
                currentMapParameter = new MapParameter();
                currentMapParameter.Scale = defaultMapParameter.Scale;
                currentMapParameter.Center = new Point2D(defaultMapParameter.Center);
                currentMapParameter.ViewBounds = new Rectangle2D(defaultMapParameter.ViewBounds);
                currentMapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;
                currentMapParameter.Name = defaultMapParameter.Name;
                currentMapParameter.Viewer = new Rectangle(0, 0, 800, 600);
            }
            if (string.IsNullOrWhiteSpace(actionName))
            {

            }
            else if ("ZoomIn" == actionName)
            {
                currentMapParameter.Scale = currentMapParameter.Scale * 2;
            }
            else if ("ZoomOut" == actionName)
            {
                currentMapParameter.Scale = currentMapParameter.Scale / 2;
            }
            else if ("LeftPan" == actionName)
            {
                currentMapParameter.Center.X = currentMapParameter.Center.X - ((currentMapParameter.ViewBounds.RightTop.X - currentMapParameter.ViewBounds.LeftBottom.X) / 4);
            }
            else if ("RightPan" == actionName)
            {
                currentMapParameter.Center.X = currentMapParameter.Center.X + ((currentMapParameter.ViewBounds.RightTop.X - currentMapParameter.ViewBounds.LeftBottom.X) / 4);
            }
            else if ("DownPan" == actionName)
            {
                currentMapParameter.Center.Y = currentMapParameter.Center.Y - ((currentMapParameter.ViewBounds.RightTop.Y - currentMapParameter.ViewBounds.LeftBottom.Y) / 4);
            }
            else if ("UpPan" == actionName)
            {
                currentMapParameter.Center.Y = currentMapParameter.Center.Y + ((currentMapParameter.ViewBounds.RightTop.Y - currentMapParameter.ViewBounds.LeftBottom.Y) / 4);
            }
            else if ("" == actionName)
            {

            }
            MapImage image = map.GetMapImage(mapName, currentMapParameter, imageOutputOption);
            if (image != null && image.MapParameter != null && image.MapParameter.ViewBounds != null)
            {
                currentMapParameter.ViewBounds = new Rectangle2D(image.MapParameter.ViewBounds);
            }
            url = image.ImageUrl;
            Session["MapParameter"] = currentMapParameter;
            ViewBag.url = url;
            return View();
        }
Beispiel #30
0
        public void GetOverviewTest_MapNameISNULL()
        {
            Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");

            ImageOutputOption option = new ImageOutputOption();
            option.ImageOutputFormat = ImageOutputFormat.PNG;
            option.ImageReturnType = ImageReturnType.BINARY;
            Overview image = null;
            try
            {
                image = map.GetOverview(string.Empty, new MapParameter(), option);
            }
            catch (ArgumentNullException e)
            {
                Assert.AreEqual(e.Message, "参数不能为空。\r\n参数名: mapName");
            }
        }