private XElement[] ApplyIcelineLayer(string[] shpFiles, XElement layerElement) { List <XElement> resultElement = new List <XElement>(); XElement tempElement = null; int length = shpFiles.Length; string shpName; XElement uniqueSymbolsEle = layerElement.Element("Renderer").Element("Symbol"); XElement dataSourceEle = layerElement.Element("FeatureClass").Element("DataSource"); _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, _subColorname); for (int i = 0; i < length; i++) { shpName = Path.GetFileNameWithoutExtension(shpFiles[i]); layerElement.Attribute("name").Value = shpName; if (uniqueSymbolsEle != null) { Color itemColor = _colorTable.ProductColors[i].Color; uniqueSymbolsEle.Attribute("color").Value = string.Format("{0},{1},{2},{3}", itemColor.A, itemColor.R, itemColor.G, itemColor.B); } if (dataSourceEle != null) { dataSourceEle.Attribute("name").Value = shpName; dataSourceEle.Attribute("fileurl").Value = shpFiles[i]; } tempElement = new XElement(layerElement); resultElement.Add(tempElement); } return(resultElement.Count == 0 ? null : resultElement.ToArray()); }
private void GetFeatureValueType(Feature[] features, string field) { _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, "ISOT");//ISOT _legendItems.Clear(); foreach (Feature fet in features) { string v = fet.GetFieldValue(field); if (v == null) { continue; } v = v.Trim(); if (!_legendItems.ContainsKey(v)) { ProductColor pc = GetColorByValue(v); if (pc != null) { _legendItems.Add(pc.LableText, pc.Color); } else { _legendItems.Add(v, Color.FromArgb(_random.Next(255), _random.Next(255), _random.Next(255))); } } } }
private void btOPTD_Click(object sender, EventArgs e) { ProductColorTable[] tables = ProductColorTableFactory.GetAllColorTables(); ProductColorTable table = ProductColorTableFactory.GetColorTable("FOG", "TIMS"); ExtractProductIdentify exPro = new ExtractProductIdentify(); exPro.ThemeIdentify = "CMA"; exPro.ProductIdentify = "FOG"; exPro.SubProductIdentify = "OPTD"; ThemeDef theme = MonitoringThemeFactory.GetThemeDefByIdentify("CMA"); ProductDef pro = theme.GetProductDefByIdentify("FOG"); SubProductDef sub = pro.GetSubProductDefByIdentify("OPTD"); AlgorithmDef alg = sub.GetAlgorithmDefByIdentify("OPTDAlgorithm"); IArgumentProvider arg = MonitoringThemeFactory.GetArgumentProvider(exPro, "OPTDAlgorithm", "FY3A", "MERSI"); arg.SetArg("OPTDAlgorithm", alg); IRasterDataProvider prd = GetRasterDataProvider("FOG"); arg.DataProvider = prd; arg.SetArg("CSRFile", @"E:\code\SMARTII\SRC\【控制】监测分析框架\testCN\bin\Release\TEMP\FOG_0CSR_FY3A_MERSI_10M_20120614001422_20120615001422.dat"); arg.SetArg("DBLVFile", @"E:\code\SMARTII\SRC\【控制】监测分析框架\testCN\bin\Release\TEMP\FOG_DBLV_FY3A_MERSI_1000M_20120614005135_20120615005135.dat"); IMonitoringSubProduct bin = new SubProductOPTDFOG(sub); IPixelFeatureMapper <Int16> result = bin.Make(null) as IPixelFeatureMapper <Int16>; result.Dispose(); }
private void GetFeatureValueType(Feature[] features, string field) { _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, "ISOT");//ICE,ISOT _legendItems.Clear(); foreach (Feature fet in features) { string v = fet.GetFieldValue(field); if (string.IsNullOrWhiteSpace(v)) { continue; } v = v.Trim(); ProductColor pc = GetColorByValue(v); if (pc != null && !_legendItems.ContainsKey(v)) { _legendItems.Add(v, pc); } //else if(!_legendItems.ContainsKey(v)) // _legendItems.Add(v, Color.FromArgb(_random.Next(255), _random.Next(255), _random.Next(255))); } //温度按照从大到小排序. KeyValuePair <string, ProductColor>[] orderItems = _legendItems.OrderByDescending((item) => { return(item.Key); }).ToArray(); _legendItems.Clear(); foreach (KeyValuePair <string, ProductColor> v in orderItems) { _legendItems.Add(v.Key, v.Value); } }
public static void Init() { //为数据框注册添加栅格数据的委托 GeoDo.RSS.Layout.DataFrm.DataFrame.AddFileToCanvasViewerExecutor = (fname, argument, canvas, fileOpenargs, colorTableName) => { //IRgbStretcherProvider rgbStretcherpProvider = null; //if (fname.ToUpper().EndsWith(".DAT")) // rgbStretcherpProvider = new RgbStretcherProvider(); IRgbStretcherProvider rgbStretcherpProvider = new RgbStretcherProvider(); if (string.IsNullOrWhiteSpace(colorTableName)) { colorTableName = GetColorTableName(argument);//兼容最早colortablename放在argument中的模式 } else { colorTableName = "colortablename=" + colorTableName; } List <string> options = new List <string>(); if (!string.IsNullOrWhiteSpace(colorTableName)) { options.Add(colorTableName); } if (fileOpenargs != null) { options.AddRange(fileOpenargs); } IRasterDrawing drawing = new RasterDrawing(fname, canvas, rgbStretcherpProvider, options.ToArray()); drawing.SelectedBandNos = GetDefaultBands(drawing); IRasterLayer lyr = new RasterLayer(drawing); canvas.LayerContainer.Layers.Add(lyr); canvas.PrimaryDrawObject = drawing; canvas.CurrentEnvelope = drawing.OriginalEnvelope; drawing.StartLoading(null); TryLoadAOIMaskLayer(canvas, drawing, fname); }; //为栅格图例注册颜色表获取委托 GeoDo.RSS.Layout.RasterLegendElement.RasterLegendItemsGetter = (colorTableName) => { ProductColorTable colorTable = ProductColorTableFactory.GetColorTable(colorTableName); if (colorTable == null) { return(null); } List <LegendItem> items = new List <LegendItem>(); foreach (ProductColor c in colorTable.ProductColors) { if (!c.DisplayLengend) { continue; } string txt = c.LableText; items.Add(new LegendItem(txt, c.Color)); } return(items.Count > 0 ? items.ToArray() : null); }; }
public static Bitmap ToBitmap <T>(T[] buffer, int width, int height, string colorTableName) { //string colorTableName = string.Format("Cloudsat.{0}", "2B-GEOPROF.Radar_Reflectivity"); ProductColorTable productColorTable = ProductColorTableFactory.GetColorTable(colorTableName); if (productColorTable == null) { return(null); } RgbStretcherProvider stretcherProvier = new RgbStretcherProvider(); ColorMapTable <int> colorMapTable = null; Func <T, byte> stretcher = null; IBitmapBuilder <T> builder = null; TypeCode t = Type.GetTypeCode(default(T).GetType()); if (t == TypeCode.Single) { stretcher = stretcherProvier.GetStretcher(enumDataType.Float, productColorTable, out colorMapTable) as Func <T, byte>; builder = BitmapBuilderFactory.CreateBitmapBuilderFloat() as IBitmapBuilder <T>; } else if (t == TypeCode.Int16) { stretcher = stretcherProvier.GetStretcher(enumDataType.Int16, productColorTable, out colorMapTable) as Func <T, byte>; builder = BitmapBuilderFactory.CreateBitmapBuilderInt16() as IBitmapBuilder <T>; } Bitmap bitmap = null; bitmap = new Bitmap(width, height, PixelFormat.Format8bppIndexed); bitmap.Palette = BitmapBuilderFactory.GetDefaultGrayColorPalette(); try { builder.Build(width, height, buffer, stretcher, ref bitmap); if (colorMapTable != null) { ColorPalette plt = BitmapBuilderFactory.GetDefaultGrayColorPalette(); for (int i = 0; i < 256; i++) { plt.Entries[i] = Color.Black; } int idx = 1; foreach (ColorMapItem <int> item in colorMapTable.Items) { for (int v = item.MinValue; v < item.MaxValue; v++) { plt.Entries[idx] = item.Color; } idx++; } bitmap.Palette = plt; } return(bitmap); } finally { } }
private static object[] GetColorTableFunc(IRasterDataProvider prd, string productIdentify, string subIdentify) { if (string.IsNullOrEmpty(productIdentify) || string.IsNullOrEmpty(subIdentify)) { return(null); } ProductColorTable ct = ProductColorTableFactory.GetColorTable(productIdentify + subIdentify); Type dataType = DataTypeHelper.Enum2DataType(prd.DataType); return(GetStretcher(dataType, ct)); }
private void CreateLegendItems(string selectedFileName, string instanceIdentify) { string colorTableName = null; if (instanceIdentify == "ONMI") { colorTableName = "LSTANMI"; } else { RasterIdentify rstIdentify = new RasterIdentify(selectedFileName); string season = GetSeason(rstIdentify); //未能读取到日期时默认设置为春天 if (string.IsNullOrEmpty(season)) { season = "Spring"; } switch (season) { case "Spring": colorTableName = "LSTSP"; break; case "Summer": colorTableName = "LSTSU"; break; case "Autumn": colorTableName = "LSTFA"; break; case "Winter": colorTableName = "LSTWI"; break; } } if (string.IsNullOrEmpty(colorTableName)) { return; } _colorTable = ProductColorTableFactory.GetColorTable(colorTableName); if (_colorTable == null || _colorTable.ProductColors.Length < 1) { return; } _legendItems.Clear(); foreach (ProductColor color in _colorTable.ProductColors) { _legendItems.Add(color); } }
private Color GetBinaryColor(IMonitoringSubProduct subProduct) { if (subProduct == null) { return(Color.Red); } //可使用productColorTableName为产品标识,进行产品判识结果颜色的定义 by chennan 20130930 ProductColorTable colorTable = ProductColorTableFactory.GetColorTable(subProduct.Definition.ProductDef.Identify); if (colorTable != null) { return(colorTable.GetColor(1f).Color); } return(subProduct.Definition.Color); }
private void CreateLegendItems(string selectedFileName, string instanceIdentify) { string colorTableName = null; if (instanceIdentify == "ONMI") { colorTableName = "LSTANMI"; } else { RasterIdentify rstIdentify = new RasterIdentify(selectedFileName); string season = GetSeason(rstIdentify); if (rstIdentify.SubProductIdentify == "DBHL") { season = "SummerHight"; } //未能读取到日期时默认设置为春天 if (string.IsNullOrEmpty(season)) { season = "Spring"; } else if (instanceIdentify == "0SRI") { Set0SRIColorTable(season, ref colorTableName); } else { SetOtherColorTable(season, ref colorTableName); } } if (string.IsNullOrEmpty(colorTableName)) { return; } _colorTable = ProductColorTableFactory.GetColorTable(colorTableName); if (_colorTable == null || _colorTable.ProductColors.Length < 1) { return; } _legendItems.Clear(); foreach (ProductColor color in _colorTable.ProductColors) { _legendItems.Add(color); } }
public new object GetStretcher(string fname, string colorTableName, out ColorMapTable <int> colorMapTable) { colorMapTable = null; ProductColorTable pct = null; if (string.IsNullOrWhiteSpace(colorTableName)) { colorTableName = "Cloudsat.2B-GEOPROF.Radar_Reflectivity"; } pct = ProductColorTableFactory.GetColorTable(colorTableName); switch (colorTableName) { case "Cloudsat.2B-GEOPROF.Radar_Reflectivity": return(base.GetStretcher(RSS.Core.DF.enumDataType.Int16, pct, out colorMapTable)); default: return(base.GetStretcher(RSS.Core.DF.enumDataType.Int16, pct, out colorMapTable)); } }
private void CreateLegendItems(string[] shpFiles) { _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, _subColorname);//ICE,EDGE _legendItems.Clear(); int index = 0; foreach (string file in shpFiles) { index++; RasterIdentify identify = new RasterIdentify(file); DateTime dt = identify.OrbitDateTime; ProductColor pcolor = _colorTable.GetColor(index); if (pcolor == null) { _legendItems.Add(dt.AddHours(8).ToString(), Color.FromArgb(255, 166, 208, 255)); } else { _legendItems.Add(dt.AddHours(8).ToString(), pcolor.Color); } } }
public object GetStretcher(string fname, enumDataType inDataType, string colorTableName, out ColorMapTable <int> colorMapTable) { colorMapTable = null; ProductColorTable pct = null; if (colorTableName == null) { string[] parts = Path.GetFileName(fname).Split('_'); //by chennan 20120819 单通道ldf产品付色 //if (parts.Length < 3 && !fname.ToUpper().EndsWith(".DAT")) if (parts.Length < 3) { return(null); } string productIdentify = parts[0]; string subProductIdentify = parts[1]; pct = ProductColorTableFactory.GetColorTable(productIdentify, subProductIdentify); } else { pct = ProductColorTableFactory.GetColorTable(colorTableName); } if (pct == null) { return(null); } //enumDataType dataType = enumDataType.Atypism; if (inDataType == enumDataType.Atypism) { using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider) { inDataType = prd.DataType; } } return(GetStretcher(inDataType, pct, out colorMapTable)); }
private void button22_Click(object sender, EventArgs e) { ProductColorTable ct = ProductColorTableFactory.GetColorTable("FOG", "DBLV"); object[] sts = ProductColorTableFactory.GetStretcher <UInt16>(ct); }
public static void UpdateLegend(ProductColorTable[] colors, Action <int, string> percentProgress) { string path = System.AppDomain.CurrentDomain.BaseDirectory + "LayoutTemplate"; if (!Directory.Exists(path)) { return; } string[] files = Directory.GetFiles(path, "*.gxt", SearchOption.AllDirectories); if (files == null || files.Length == 0) { return; } for (int i = 0; i < files.Length; i++) { string fname = files[i]; ILayoutTemplate template = LayoutTemplate.LoadTemplateFrom(fname); //LayoutTemplate.LoadTemplateFrom(fname); if (template == null) { return; } if (percentProgress != null) { percentProgress((int)((i + 1) * 100f / files.Length), ""); } ILayout layout = template.Layout; bool haUpdate = false; for (int e = 0; e < layout.Elements.Count; e++) { if (layout.Elements[e] is ILegendElement) { ILegendElement legendEle = layout.Elements[e] as ILegendElement; string colotName = legendEle.ColorTableName; if (!string.IsNullOrWhiteSpace(colotName)) { ProductColorTable colorTable = ProductColorTableFactory.GetColorTable(colotName); if (colorTable != null) { List <LegendItem> items = new List <LegendItem>(); foreach (ProductColor pc in colorTable.ProductColors) { if (!pc.DisplayLengend) { continue; } LegendItem item = new LegendItem(pc.LableText, pc.Color); items.Add(item); } legendEle.LegendItems = items.ToArray(); haUpdate = true; } } } } if (haUpdate) { template.SaveTo(fname); } } }