private void btnThemeUnique_Click(object sender, EventArgs e)
        {
            UGCThemeLayer ugcThemeLayer = new UGCThemeLayer();
            ugcThemeLayer.Type = LayerType.UGC;
            ugcThemeLayer.Visible = true;
            ugcThemeLayer.UgcLayerType = UGCLayerType.THEME;
            ugcThemeLayer.DatasetInfo = new DatasetInfo();
            ugcThemeLayer.DatasetInfo.DataSourceName = "Jingjin";
            ugcThemeLayer.DatasetInfo.Name = "BaseMap_R";
            ugcThemeLayer.DatasetInfo.Type = DatasetType.REGION;

            //theme.graduatedMode = SuperMap.Web.iServerJava6R.GraduatedMode.SQUAREROOT;
            //theme.graphAxes.axesDisplayed = true;
            //theme.graphSize.maxGraphSize = 1;
            //theme.graphSize.minGraphSize = 0.35;
            //theme.graphText.graphTextDisplayed = true;
            //theme.graphText.graphTextFormat = SuperMap.Web.iServerJava6R.ThemeGraphTextFormat.VALUE;
            //theme.graphType = SuperMap.Web.iServerJava6R.ThemeGraphType.BAR3D;

            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.Theme = themeGraph;
            SuperMap.Connector.Map map = new SuperMap.Connector.Map("http://localhost:8090/iserver/services/map-jingjin");
            MapParameter defaultMapParameter = map.GetDefaultMapParameter("京津地区人口分布图_专题图");
            List<SuperMap.Connector.Utility.Layer> layers = new List<SuperMap.Connector.Utility.Layer>();
            layers.Add(ugcThemeLayer);
            //layers.Add(defaultMapParameter.Layers[11]);
            //layers.Add(defaultMapParameter.Layers[12]);
            MapParameter requestMapParameter = new MapParameter();
            requestMapParameter.Name = "京津地区人口分布图_专题图";
            requestMapParameter.Bounds = new SuperMap.Connector.Utility.Rectangle2D(defaultMapParameter.Bounds);
            requestMapParameter.CacheEnabled = false;
            requestMapParameter.ColorMode = MapColorMode.DEFAULT;
            requestMapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;

            requestMapParameter.CoordUnit = Unit.METER;
            requestMapParameter.OverlapDisplayed = true;
            requestMapParameter.PaintBackground = true;
            //requestMapParameter.MaxVisibleVertex = 3600000;
            requestMapParameter.Layers = layers;

            double defaultScale = defaultMapParameter.Scale;
            double[] scales = new double[] {defaultScale/16,defaultScale/14,defaultScale/12,defaultScale/10,
                defaultScale/8,defaultScale/6,defaultScale/4,defaultScale/2, defaultScale,defaultScale*2,
            defaultScale*4,defaultScale*6,defaultScale*8,defaultScale*10,defaultScale*12,defaultScale*14,defaultScale*16};
            SuperMapTileSource tileSource =
                new SuperMapTileSource("http://localhost:8090/iserver/services/map-jingjin", "京津地区人口分布图_专题图",
                256, "png", scales, requestMapParameter);
            TileLayer layer = new TileLayer(tileSource);
            layer.LayerName = "京津地区人口分布图_专题图1";

            mapControl.Map = CreateMap(layer);
        }
Esempio n. 2
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);
            }
        }