コード例 #1
0
 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);
     };
 }
コード例 #2
0
ファイル: CommandAddLayer.cs プロジェクト: configare/hispeed
        private void AddData2CanvasViewer(ICanvasViewer cv, string fname)
        {
            ISmartSession        session   = _smartSession;
            ICanvas              canvas    = cv.Canvas;
            RgbStretcherProvider stretcher = null;
            bool isRaster = false;

            TryGetRasterStretcher(fname, out stretcher, out isRaster);
            if (isRaster)
            {
                RasterLayerBuilder.CreateAndLoadRasterLayer(session, canvas, fname, stretcher);
            }
            else
            {
                TryAddAsVector(fname);
            }
        }
コード例 #3
0
ファイル: CommandAddLayer.cs プロジェクト: configare/hispeed
 private void TryGetRasterStretcher(string fname, out RgbStretcherProvider stretcher, out bool isRaster)
 {
     isRaster  = false;
     stretcher = null;
     try
     {
         using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
         {
             if (prd != null)
             {
                 isRaster = true;
             }
             if (prd.BandCount == 1)
             {
                 stretcher = new RgbStretcherProvider();
             }
         }
     }
     catch
     {
         isRaster  = false;
         stretcher = null;
     }
 }