${iServerJava6R_ThemeUnique_Title}
${iServerJava6R_ThemeUnique_Description}
internal static ThemeUnique FromJson(JsonObject json) { if (json == null) { return null; } ThemeUnique themeUnique = new ThemeUnique(); if (json["defaultStyle"] != null) { themeUnique.DefaultStyle = ServerStyle.FromJson((JsonObject)json["defaultStyle"]); } if (json["colorGradientType"] != null) { themeUnique.ColorGradientType = (ColorGradientType)Enum.Parse(typeof(ColorGradientType), json["colorGradientType"], true); } else { //这里不处理为空时的情况 } List<ThemeUniqueItem> items = new List<ThemeUniqueItem>(); if (json["items"] != null && json["items"].Count > 0) { for (int i = 0; i < json["items"].Count; i++) { items.Add(ThemeUniqueItem.FromJson((JsonObject)json["items"][i])); } } themeUnique.Items = items; themeUnique.UniqueExpression = json["uniqueExpression"]; return themeUnique; }
void service_ProcessCompleted(object sender, GenerateSpatialDataArgs e) { ThemeUniqueItem item1 = new ThemeUniqueItem(); ServerStyle style1 = new ServerStyle(); style1.FillForeColor = Color.FromArgb(255, 242, 48, 48); style1.LineColor = Color.FromArgb(255, 242, 48, 48); item1.Unique = "拥堵"; item1.Style = style1; ThemeUniqueItem item2 = new ThemeUniqueItem(); ServerStyle style2 = new ServerStyle(); style2.FillForeColor = Color.FromArgb(255, 255, 159, 25); style2.LineColor = Color.FromArgb(255, 255, 159, 25); item2.Unique = "缓行"; item2.Style = style2; ThemeUniqueItem item3 = new ThemeUniqueItem(); ServerStyle style3 = new ServerStyle(); style3.FillForeColor = Color.FromArgb(255, 91, 195, 69); style3.LineColor = Color.FromArgb(255, 91, 195, 69); item3.Unique = "畅通"; item3.Style = style3; ThemeUnique themeUnique = new ThemeUnique(); themeUnique.UniqueExpression = "TrafficStatus"; themeUnique.Items = new List<ThemeUniqueItem>() { item1,item2,item3}; ThemeParameters param = new ThemeParameters(); param.DatasetName = "generateSpatialData"; param.DataSourceName = "Changchun"; param.Themes=new List<Theme>(){themeUnique}; ThemeService themeService = new ThemeService(_mapUrl); themeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeService_ProcessCompleted); themeService.ProcessAsync(param); }
private void compositionTheme_Click(object sender, RoutedEventArgs e) { List<ThemeUniqueItem> items = new List<ThemeUniqueItem> { new ThemeUniqueItem { Caption="A", Unique="1", Style=new ServerStyle { FillForeColor=Colors.Red, }, Visible=true, }, new ThemeUniqueItem { Caption="B", Unique="247", Style=new ServerStyle { FillForeColor=Colors.Blue, }, Visible=true, } }; ThemeUnique themeUnique = new ThemeUnique { Items = items, UniqueExpression = "SmID", DefaultStyle = new ServerStyle { FillOpaqueRate = 100, FillForeColor = Colors.Orange, FillBackOpaque = true, FillBackColor = Colors.Transparent } }; ThemeDotDensity themeDonDensity = new ThemeDotDensity { Value = 10000000, DotExpression = "Pop_1994", Style = new ServerStyle { MarkerSize = 5, } }; ThemeParameters compostionThemeParameters = new ThemeParameters { DatasetName = "World", DataSourceName = "World", Themes = new List<Theme> { themeDonDensity, themeUnique } }; ThemeService compositeService = new ThemeService(url); compositeService.ProcessAsync(compostionThemeParameters); compositeService.Failed += new EventHandler<ServiceFailedEventArgs>(compositeService_Failed); compositeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(compositeService_ProcessCompleted); }
private void ThemeUnique_Click(object sender, RoutedEventArgs e) { List<ThemeUniqueItem> items = new List<ThemeUniqueItem> { new ThemeUniqueItem { Caption="A", Unique="151827600", Style=new ServerStyle { FillForeColor=Colors.Red, MarkerSize=20, MarkerSymbolID=10 }, Visible=true, }, new ThemeUniqueItem { Caption="B", Unique="1128139689", Style=new ServerStyle { FillForeColor=Colors.Blue, MarkerSize=20, MarkerSymbolID=30 }, Visible=true, } }; ThemeUnique themeUnique = new ThemeUnique { Items = items, UniqueExpression = "Pop_1994", DefaultStyle = new ServerStyle { FillOpaqueRate = 100, FillForeColor = Colors.Orange, FillBackOpaque = true, FillBackColor = Colors.Transparent } }; ThemeParameters themeUniqueParameters = new ThemeParameters { Themes = new List<Theme> { themeUnique }, DatasetName = "Capitals", DataSourceName = "World", }; themeUniqueParameters.JoinItems.Add(new JoinItem { ForeignTableName = "Countries", JoinFilter = "Capitals.Capital=Countries.Capital", JoinType = JoinType.LEFTJOIN }); ThemeService themeUniqueService = new ThemeService(url); themeUniqueService.ProcessAsync(themeUniqueParameters); themeUniqueService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeUniqueService_ProcessCompleted); themeUniqueService.Failed += new EventHandler<ServiceFailedEventArgs>(themeUniqueService_Failed); }
private 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 = System.Windows.Media.Color.FromArgb(255, 0, 180, 150), } }; //专题图参数设置 ThemeParameters compostionThemeParameters = new ThemeParameters { DatasetName = "Countries", DataSourceName = "World", Themes = new List<Theme> { themeDotDensity, themeUnique } }; //与服务器交互 ThemeService compositeService = new ThemeService(url); compositeService.ProcessAsync(compostionThemeParameters); compositeService.Failed += new EventHandler<ServiceFailedEventArgs>(compositeService_Failed); compositeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(compositeService_ProcessCompleted); }
//点击生成专题图触发事件 private 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" }; //与服务器交互 ThemeService themeUniqueService = new ThemeService(url); themeUniqueService.ProcessAsync(themeUniqueParameters); themeUniqueService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeUniqueService_ProcessCompleted); themeUniqueService.Failed += new EventHandler<ServiceFailedEventArgs>(themeUniqueService_Failed); }
private static string GetThemeInfoJson(ThemeUnique themeUnique) { if (themeUnique == null) { return null; } string themeInfoJson = "{"; List<string> themeInfoJsonList = new List<string>(); if (themeUnique.Items != null && themeUnique.Items.Count > 0) { themeInfoJsonList.Add(string.Format("\"items\":[{0}]", GetThemeItemsJson(themeUnique.Items))); } else { themeInfoJsonList.Add("\"items\":[]"); } if (!string.IsNullOrEmpty(themeUnique.UniqueExpression)) { themeInfoJsonList.Add(string.Format("\"uniqueExpression\":\"{0}\"", themeUnique.UniqueExpression)); } else { themeInfoJsonList.Add("\"uniqueExpression\":\"\""); } themeInfoJsonList.Add(string.Format("\"colorGradientType\":\"{0}\"", themeUnique.ColorGradientType.ToString())); if (themeUnique.DefaultStyle != null) { themeInfoJsonList.Add(string.Format("\"defaultStyle\":{0}", ServerStyle.ToJson(themeUnique.DefaultStyle))); } else { themeInfoJsonList.Add(string.Format("\"defaultStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); } //添加专题图请求体必须的但不开放给用户的字段 themeInfoJsonList.Add("\"type\":\"UNIQUE\""); if (themeUnique.MemoryData != null) { themeInfoJsonList.Add("\"memoryData\":" + themeUnique.ToJson(themeUnique.MemoryData)); } else { themeInfoJsonList.Add("\"memoryData\":null"); } themeInfoJson += string.Join(",", themeInfoJsonList.ToArray()); themeInfoJson += "}"; return themeInfoJson; }
internal static string ToJson(ThemeUnique themeUnique) { string json = GetThemeInfoJson(themeUnique); return json; }