${REST_ThemeParameters_Title}

${REST_ThemeParameters_Description}

Exemplo n.º 1
0
        /// <summary>${REST_ThemeService_method_ProcessAsync_param_Parameters}</summary>
        public async Task<ThemeResult> ProcessAsync(ThemeParameters themeParameters)
        {
            ValidationUrlAndParametres(themeParameters);
            CombineAbsolutePath();

            var result = await base.SubmitRequest(base.Url, GetDictionaryParameters(themeParameters), true, false, true);
            return ThemeResult.FromJson(result);
        }
Exemplo n.º 2
0
        private System.Collections.Generic.Dictionary<string, string> GetDictionaryParameters(ThemeParameters themeParameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("type", "\"UGC\"");

            dictionary.Add("subLayers", ThemeParameters.ToJson(themeParameters));
            dictionary.Add("name", "\"" + serviceMapName + "\"");

            return dictionary;
        }
Exemplo n.º 3
0
        private void ValidationUrlAndParametres(ThemeParameters themeParameters)
        {
            if (themeParameters == null)
            {
                throw new ArgumentNullException("请求服务参数为空!");
            }

            if (string.IsNullOrEmpty(this.Url))
            {
                throw new InvalidOperationException(ExceptionStrings.InvalidUrl);
            }
        }
Exemplo n.º 4
0
        internal static string ToJson(ThemeParameters param)
        {
            string json = "{";
            List<string> themeList = new List<string>();
            json += "\"layers\":[";
            if (param.Themes != null && param.Themes.Count > 0)
            {
                foreach (var item in param.Themes)
                {
                    themeList.Add(GetThemeLayer(item, param));
                }
            }

            json += string.Join(",", themeList.ToArray());
            json += "]}";
            return json;
        }
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            ThemeLabel labelTheme = new ThemeLabel
            {
                BackSetting = new ThemeLabelBackSetting
                {
                    BackStyle = new ServerStyle
                    {
                        FillForeColor = new Color
                        {
                            R = 124,
                            G = 193,
                            B = 225
                        },
                        LineWidth = 0.1,
                        MarkerSize = 1,
                    },
                },

                Flow = new ThemeFlow
                {
                    FlowEnabled = true,
                    LeaderLineDisplayed = false,
                },
                LabelExpression = "Capital",
                LabelOverLengthMode = LabelOverLengthMode.NONE,
                Offset = new ThemeOffset
                {
                    OffsetX = "0.1",
                    OffsetY = "0.1",
                    OffsetFixed = false,
                },

                Text = new ThemeLabelText
                {
                    UniformStyle = new ServerTextStyle
                    {
                        Align = SuperMap.WinRT.REST.TextAlignment.MIDDLECENTER,
                        FontHeight = 4,
                        FontWidth = 0,
                        FontWeight = 10,
                    }
                },
            };
            //专题图参数设置
            ThemeParameters themeLabelParam = new ThemeParameters
            {
                //数据集名称
                DatasetName = "Countries",
                //数据源名称
                DataSourceName = "World",
                Themes = new List<Theme> { labelTheme }
            };
            //与服务器交互
            try
            {
                ThemeService themeLableService = new ThemeService(url);
                var result = await themeLableService.ProcessAsync(themeLabelParam);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            //设置专题图子项
            List<ThemeRangeItem> themeRangeItems = new List<ThemeRangeItem>
            {
                new ThemeRangeItem
                {
                    Start = 0.0,
                    End = 59973,
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=216,G=244,B=254},
                        LineWidth = 0.1,
                    }
                },
                
                new ThemeRangeItem
                {
                    Start = 59973,
                    End = 1097234,
                    Visible = true ,
                    Style = new ServerStyle 
                    {
                         FillForeColor = new Color {R=131,G=232,B=252},
                         LineWidth = 0.1 ,
                    }
                },

                new ThemeRangeItem
                {
                    Start = 1097234,
                    End = 5245515,
                    Visible = true ,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=112,G=212,B=243},
                        LineWidth = 0.1,
                    }
                },
                 
                new ThemeRangeItem
                {
                    Start = 5245515,
                    End = 17250390,
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=23,G=198,B=238},
                        LineWidth = 0.1,
                    }
                },

                new ThemeRangeItem
                {
                    Start = 17250390,
                    End = 894608700,
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=0,G=187,B=236},
                        LineWidth = 0.1 ,
                    }
                },

                new ThemeRangeItem
                {
                    Start = 894608700,
                    End =  12E+8,
                    Visible = true ,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=0,G=133,B=236},
                        LineWidth = 0.1 ,
                    }
                }
            };
            //设置范围分段专题图字段、分段模式、分段参数和子项数组
            ThemeRange themeRange = new ThemeRange
            {
                RangeExpression = "Pop_1994",
                RangeMode = RangeMode.EQUALINTERVAL,
                RangeParameter = 6,
                Items = themeRangeItems
            };
            //设置专题图参数
            ThemeParameters themeRangeParams = new ThemeParameters
            {
                //数据集名称
                DatasetName = "Countries",
                //数据源名称
                DataSourceName = "World",
                Themes = new List<Theme> { themeRange }
            };
            //与服务器交互
            try
            {
                ThemeService themeRangeServie = new ThemeService(url);
                var result = await themeRangeServie.ProcessAsync(themeRangeParams);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            ThemeGraduatedSymbol themeGraduatedSymbol = new ThemeGraduatedSymbol
            {
                BaseValue = 1128139680,
                GraduatedMode = GraduatedMode.SQUAREROOT,
                Flow = new ThemeFlow
                {
                    FlowEnabled = true,
                },
                Expression = "Pop_1994",
                Style = new ThemeGraduatedSymbolStyle
                {
                    PositiveStyle = new ServerStyle
                    {
                        LineColor = Colors.White,
                        MarkerSize = 20,
                        MarkerSymbolID = 5
                    }

                }
            };
            //专题图参数设置
            ThemeParameters themeGraduatedSymbolParams = new ThemeParameters
            {
                //数据集名称
                DatasetName = "Countries",
                //数据源名称
                DataSourceName = "World",
                Themes = new List<Theme> { themeGraduatedSymbol }
            };
            //与服务器交互
            try
            {
                ThemeService themeGraduatedSymbolService = new ThemeService(url);
                var result = await themeGraduatedSymbolService.ProcessAsync(themeGraduatedSymbolParams);

                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            //专题图子项数组
            List<ThemeUniqueItem> items = new List<ThemeUniqueItem> 
            {
                //专题图子项
                 new ThemeUniqueItem
                 {
                     //SmID字段值
                     Unique="1", 
                     Style=new ServerStyle
                     {
                         FillForeColor = new Color {R=1,G=128,B=171},
                         LineWidth = 0.1                       
                     },
                     Visible=true,
                 },
                 new ThemeUniqueItem
                 {
                     //SmID字段值
                     Unique="247",
                     Style=new ServerStyle
                     {
                         FillForeColor= new Color {R=192,G=214,B=54},
                         LineWidth = 0.1
                     },
                     Visible=true,
                 }
            };
            //设置其他 SmID 字段显示风格
            ThemeUnique themeUnique = new ThemeUnique
            {
                Items = items,
                UniqueExpression = "SmID",
                DefaultStyle = new ServerStyle
                {
                    FillOpaqueRate = 100,
                    FillForeColor = new Color { R = 250, G = 237, B = 195 },
                    LineWidth = 0.1,
                    FillBackOpaque = true,
                    FillBackColor = Colors.Transparent
                }
            };

            ThemeDotDensity themeDotDensity = new ThemeDotDensity
            {
                //专题图中每一个点所代表的数值
                Value = 10000000,
                //1994年人口字段
                DotExpression = "Pop_1994",
                Style = new ServerStyle
                {
                    //设置点符号
                    MarkerSize = 2,
                    MarkerSymbolID = 1,
                    FillForeColor = Color.FromArgb(255, 0, 180, 150),
                }
            };
            //专题图参数设置
            ThemeParameters compostionThemeParameters = new ThemeParameters
            {
                DatasetName = "Countries",
                DataSourceName = "World",
                Themes = new List<Theme> { themeDotDensity, themeUnique }
            };
            // //与服务器交互成功
            try
            {
                ThemeService compositeService = new ThemeService(url);
                var result =  await compositeService.ProcessAsync(compostionThemeParameters);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
               
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } 
        }
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            ThemeDotDensity themeDotDensity = new ThemeDotDensity
            {
                //专题图中每一个点所代表的数值
                Value = 10000000,
                //1994年人口字段
                DotExpression = "Pop_1994",
                Style = new ServerStyle
                {
                    //设置点符号
                    MarkerSize = 2,
                    MarkerSymbolID = 1,
                    FillForeColor = Color.FromArgb(255, 0, 180, 150),

                }
            };
            //专题图参数设置
            ThemeParameters dotDensityParams = new ThemeParameters
            {
                //数据集名称
                DatasetName = "Countries",
                //数据源名称
                DataSourceName = "World",
                Themes = new List<Theme> 
                {
                    themeDotDensity
                }
            };
            //与服务器交互成功
            try
            {
                ThemeService dotDensityService = new ThemeService(url);
                var result = await dotDensityService.ProcessAsync(dotDensityParams);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;

                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 10
0
        private static string GetThemeLayer(Theme theme, ThemeParameters param)
        {
            string themeLayerJson = "{";

            List<string> themeLayerList = new List<string>();
            List<string> joinItemsList = new List<string>();

            if (theme is ThemeUnique)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeUnique.ToJson((ThemeUnique)theme)));
            }
            else if (theme is ThemeRange)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeRange.ToJson((ThemeRange)theme)));
            }
            else if (theme is ThemeDotDensity)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeDotDensity.ToJson((ThemeDotDensity)theme)));
            }
            else if (theme is ThemeGraduatedSymbol)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeGraduatedSymbol.ToJson((ThemeGraduatedSymbol)theme)));
            }
            else if (theme is ThemeGraph)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeGraph.ToJson((ThemeGraph)theme)));
            }
            else if (theme is ThemeLabel)
            {
                themeLayerList.Add(string.Format("\"theme\":{0}", ThemeLabel.ToJson((ThemeLabel)theme)));
            }
            //else if (theme is ThemeGridRange)
            //{
            //themeLayerList.Add(string.Format("\"theme\":{0}", ThemeGridRange.ToJson((ThemeGridRange)theme)));
            //}
            //else if (theme is ThemeGridUnique)
            //{
            //themeLayerList.Add(string.Format("\"theme\":{0}", ThemeGridUnique.ToJson((ThemeGridUnique)theme)));
            //}
            else
            {
                themeLayerList.Add("\"theme\":null");
            }

            themeLayerList.Add("\"type\":\"UGC\"");
            themeLayerList.Add("\"ugcLayerType\":\"THEME\"");
            //themeLayerList.Add(string.Format("\"name\":\"{0}\"", param.Name));

            themeLayerList.Add(string.Format("\"datasetInfo\":{0}",
                GetDatasetInfo(param.DatasetName, param.DataSourceName)));

            foreach (var item in param.JoinItems)
            {
                joinItemsList.Add(JoinItem.ToJson(item));
            }

            string joinItemsStr = string.Join(",", joinItemsList);
            themeLayerList.Add(string.Format("\"joinItems\":[{0}]", joinItemsStr));
            themeLayerJson += string.Join(",", themeLayerList.ToArray());
            themeLayerJson += "}";
            return themeLayerJson;
        }
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            //专题图子项数组
            List<ThemeUniqueItem> items = new List<ThemeUniqueItem>
            {
                //专题图子项
                new ThemeUniqueItem
                {
                    Unique = "城市",
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=157,G=127,B=255},
                        LineWidth = 0.05   
                    }
                },

                new ThemeUniqueItem
                {
                    Unique = "旱地",
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=250,G=237,B=195},
                        LineWidth = 0.05
                    }
                },

                new ThemeUniqueItem
                {
                    Unique="水浇地",
                    Visible=true,
                    Style=new ServerStyle 
                    {
                        FillForeColor = new Color {R=59,G=188,B=230},
                        LineWidth = 0.05
                    }
                },

                new ThemeUniqueItem
                {
                    Unique = "湖泊水库",
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=1,G=128,B=171},
                        LineWidth = 0.05
                    }
                },

                new ThemeUniqueItem
                {
                    Unique = "水田",
                    Visible = true ,
                    Style = new ServerStyle 
                    {
                       FillForeColor = new Color {R=167,G=219,B=232},
                       LineWidth = 0.05
                    }
                },

                new ThemeUniqueItem
                {
                    Unique = "草地",
                    Visible = true,
                    Style = new ServerStyle 
                    {
                        FillForeColor = new Color {R=192,G=214,B=54},
                        LineWidth = 0.05
                    }
                },
            };
            //设置其他土地利用类型显示风格
            ThemeUnique themeUnique = new ThemeUnique
            {
                Items = items,
                UniqueExpression = "LandType",
                DefaultStyle = new ServerStyle
                {
                    FillOpaqueRate = 100,
                    FillForeColor = new Color
                    {
                        R = 80,
                        G = 130,
                        B = 255
                    },
                    FillBackOpaque = true,
                    LineWidth = 0.05,

                }
            };
            //专题图参数对象
            ThemeParameters themeUniqueParameters = new ThemeParameters
            {
                Themes = new List<Theme> { themeUnique },
                //数据集名称
                DatasetName = "Landuse_R",
                //数据源名称
                DataSourceName = "Jingjin"
            };

            //与服务器交互
            try
            {
                ThemeService themeUniqueService = new ThemeService(url);
                var result = await themeUniqueService.ProcessAsync(themeUniqueParameters);

                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }

            }
            //交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }