コード例 #1
0
        public IRasterDataProvider CreateOutRaster(string outFileName, RasterMaper[] inrasterMaper)
        {
            IRasterDataDriver raster = RasterDataDriver.GetDriverByName("MEM") as IRasterDataDriver;

            GeoDo.RSS.Core.DF.CoordEnvelope outEnv = null;
            foreach (RasterMaper inRaster in inrasterMaper)
            {
                if (outEnv == null)
                {
                    outEnv = inRaster.Raster.CoordEnvelope;
                }
                else
                {
                    outEnv.Union(inRaster.Raster.CoordEnvelope);
                }
            }
            float              resX      = inrasterMaper[0].Raster.ResolutionX;
            float              resY      = inrasterMaper[0].Raster.ResolutionY;
            int                width     = (int)(Math.Round(outEnv.Width / resX));
            int                height    = (int)(Math.Round(outEnv.Height / resY));
            string             mapInfo   = outEnv.ToMapInfoString(new Size(width, height));
            RasterDataProvider outRaster = raster.Create(outFileName, width, height, 1, enumDataType.Int16, mapInfo) as RasterDataProvider;

            return(outRaster);
        }
コード例 #2
0
ファイル: CloudsatProjection.cs プロジェクト: windygu/hispeed
 private void IntersectEnvelope(float[] Latitude, float[] Longtitude, GeoDo.RSS.Core.DF.CoordEnvelope env,
                                ref int count, ref int minIndex, ref int maxIndex)
 {
     minIndex = -1;
     maxIndex = -1;
     for (int i = 0; i < Latitude.Length; i++)
     {
         if (Longtitude[i] >= env.MinX && Longtitude[i] <= env.MaxX && Latitude[i] >= env.MinY && Latitude[i] <= env.MaxY)
         {
             if (minIndex == -1)
             {
                 minIndex = i;
                 maxIndex = i;
             }
             else
             {
                 if (minIndex > i)
                 {
                     minIndex = i;
                 }
                 if (maxIndex < i)
                 {
                     maxIndex = i;
                 }
             }
             count++;
         }
     }
 }
コード例 #3
0
        private void GetAOIArgument(Size maxSize, GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp, float resolution, out string name, out int[] aoi)
        {
            Dictionary <string, int[]> aoiDic = null;

            name = null;
            aoi  = null;
            if (viewGeoEvp == null)
            {
                return;
            }
            using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(maxSize, viewGeoEvp, resolution))
            {
                frm.listView1.MultiSelect = false;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    aoiDic = frm.GetFeatureAOIIndex();
                    if (aoiDic == null)
                    {
                        return;
                    }
                    foreach (string key in aoiDic.Keys)
                    {
                        name = key;
                        aoi  = aoiDic[key];
                        return;
                    }
                }
            }
        }
コード例 #4
0
        public string MutiRegionsClip(string file, GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer aoiContainer, string savePath)
        {
            _aoiContainer = aoiContainer;

            using (IRasterDataProvider raster = GeoDataDriver.Open(file) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope corEnvelope = null;
            corEnvelope = GetGeoRect();      //获取多个aoi的外接矩形
            evp.MaxX    = corEnvelope.MaxX;
            evp.MaxY    = corEnvelope.MaxY;
            evp.MinX    = corEnvelope.MinX;
            evp.MinY    = corEnvelope.MinY;
            BlockDefWithAOI        outEnvelope;
            Size                   size;
            List <BlockDefWithAOI> blockList = new List <BlockDefWithAOI>();

            GetArgs(out outEnvelope, out size);
            envelopes = new BlockDefWithAOI[] { outEnvelope };
            blockList.AddRange(envelopes);
            blockList[0].AOIIndexes = GetIndexes();     //获得多个aoi的Index
            OutDir = savePath;
            string[] put = RasterClipT(file, blockList.ToArray(), OutDir, "Cut");
            return(put[0]);
        }
コード例 #5
0
ファイル: CloudsatProjection.cs プロジェクト: windygu/hispeed
        public void ToRaster(string[] cloudsatfiles, int bandNo, int heightLevel, IRasterDataProvider oraster)
        {
            _cloudsatfiles = cloudsatfiles;
            _bandNo        = bandNo;
            _band          = oraster.GetRasterBand(1);
            _heightLevel   = heightLevel;
            int   ox          = oraster.Width;
            int   oy          = oraster.Height;
            float resolutionx = oraster.ResolutionX;
            float resolutiony = oraster.ResolutionY;
            Size  osize       = new Size(oraster.Width, oraster.Height);

            GeoDo.RSS.Core.DF.CoordEnvelope env = oraster.CoordEnvelope;
            short[] refValues = new short[ox * oy];
            for (int i = 0; i < _cloudsatfiles.Length; i++)
            {
                float[] latitudes;
                float[] longitudes;
                int     h;
                string  fullfilename = _cloudsatfiles[i];
                int     cou, minX, maxX;
                short[] datas = null;
                int     level = _heightLevel;//
                int     xn;
                using (CloudsatDataProvider raster = GeoDataDriver.Open(fullfilename) as CloudsatDataProvider)
                {
                    CloudSatRasterBand band = raster.GetRasterBand(_bandNo) as CloudSatRasterBand;
                    h          = band.Height;//37081
                    latitudes  = raster.ReadVdata("Latitude", null, 0, h) as float[];
                    longitudes = raster.ReadVdata("Longitude", null, 0, h) as float[];
                    cou        = 0;
                    minX       = 0;
                    maxX       = h;
                    IntersectEnvelope(latitudes, longitudes, env, ref cou, ref minX, ref maxX);
                    xn    = maxX - minX + 1;
                    datas = readData(new int[] { minX, level }, new int[] { xn, 1 }, band);
                }
                if (cou > 0 && (minX != 0 || maxX != h))
                {
                    float[] lats  = new float[xn];
                    float[] longs = new float[xn];
                    Buffer.BlockCopy(latitudes, minX * 4, lats, 0, xn * 4);
                    Buffer.BlockCopy(longitudes, minX * 4, longs, 0, xn * 4);
                    latitudes  = lats;
                    longitudes = longs;
                }
                PointProjection.PointToRasterInt16(longitudes, latitudes, datas, env, resolutionx, resolutiony, osize, ref refValues);
            }
            GCHandle handle = GCHandle.Alloc(refValues, GCHandleType.Pinned);

            try
            {
                _band.Write(0, 0, ox, oy, handle.AddrOfPinnedObject(), enumDataType.Int16, ox, oy);
            }
            finally
            {
                handle.Free();
            }
        }
コード例 #6
0
 protected void TrySetEnvelopeAndResolutions()
 {
     double[] coord1 = new double[2];
     _coordTransform.Raster2DataCoord(0, 0, coord1);
     double[] coord2 = new double[2];
     _coordTransform.Raster2DataCoord(_height, _width, coord2);
     _coordEnvelope = new CoordEnvelope(coord1[0], coord2[0], coord2[1], coord1[1]);
 }
コード例 #7
0
        public CoordEnvelope Union(CoordEnvelope a)
        {
            double minX = Math.Min(_minX, a.MinX);
            double minY = Math.Min(_minY, a.MinY);
            double maxX = Math.Max(_maxX, a.MaxX);
            double maxY = Math.Max(_maxY, a._maxY);

            return(new CoordEnvelope(minX, maxX, minY, maxY));
        }
コード例 #8
0
ファイル: RasterDrawing.cs プロジェクト: configare/hispeed
 void IGeoPanAdjust.Start()
 {
     if (!_isGeoPanAdjusting)
     {
         _envelopeBeforeAdjusting     = _dataProvider.CoordEnvelope.Clone();
         _envelopeBeforeAdjustingCopy = _dataProviderCopy.CoordEnvelope.Clone();
         _isGeoPanAdjusting           = true;
         _isHasUnsavedGeoAdjusted     = false;
     }
 }
コード例 #9
0
        public void DisplayAvi(ISmartSession session, string wndName, string[] fnames, string templateName,
                               string subIdentify, out string outputFname)
        {
            string satellite = null;
            string sensor    = null;

            outputFname = GetOutputGxdFileName(fnames, subIdentify, out satellite, out sensor);
            bool isOk = false;

            FileIsSupportable(fnames);
            ILayoutTemplate temp = GetTemplateByArg(templateName);

            if (temp == null)
            {
                return;
            }
            ILayoutViewer viewer = new LayoutViewer(wndName);

            ApplyLayoutTemplate(viewer, ref temp); //在这里应用模板,初始化数据框的dataProvider
            TryApplyVars(temp, subIdentify, satellite, sensor);
            if (viewer.LayoutHost == null)
            {
                return;
            }
            ICanvas canvas = GetCanvasByTemplate(temp);

            if (canvas == null)
            {
                return;
            }
            Size dataSize = Size.Empty;

            GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp = null;
            GeoDo.RSS.Core.DF.CoordEnvelope         viewGeoEvp = null;
            float     resolution = 0;
            int       maxSize    = GetBorderSizeByTemplate(viewer.LayoutHost.LayoutRuntime, temp);
            IAVILayer aviLyr     = AVILayerBuilder.CreatAVILayer(fnames, canvas, maxSize, out dataSize, out viewPrjEvp, out viewGeoEvp, out resolution);

            if (aviLyr == null)
            {
                return;
            }
            aviLyr.OnTicked += new EventHandler(RefreshDataFrame);
            if (_isCustom)
            {
                TryApplyCustom(canvas, dataSize, subIdentify, viewPrjEvp, viewGeoEvp, resolution);
            }
            isOk = TryAddAviLayerToCanvas(canvas, aviLyr, viewPrjEvp);
            if (isOk)
            {
                session.SmartWindowManager.DisplayWindow(viewer);
                _host.ToSuitedSize(_host.LayoutRuntime.Layout);
                TryExportToGIF(session, subIdentify, outputFname);
            }
        }
コード例 #10
0
        public LogicalRasterDataProvider(string fileName, string[] fnames, object tag)
        {
            if (fnames == null || fnames.Length == 0)
            {
                throw new ArgumentNullException("fnames");
            }
            _tag          = tag;
            _fileNames    = new string[fnames.Length + 1];
            _fileNames[0] = fileName;
            int  i       = 1;
            bool isFirst = true;

            foreach (string fname in fnames)
            {
                _fileNames[i++] = fname;
                IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider;
                if (prd == null)
                {
                    continue;
                }
                if (isFirst)
                {
                    _dataType       = prd.DataType;
                    _width          = prd.Width;
                    _height         = prd.Height;
                    _coordEnvelope  = prd.CoordEnvelope;
                    _coordType      = prd.CoordType;
                    _spatialRef     = prd.SpatialRef;
                    _coordTransform = prd.CoordTransform;
                    isFirst         = false;
                }
                else
                {
                    if (_dataType != prd.DataType ||
                        _coordType != prd.CoordType ||
                        !CoordEnvelopeEquals(_coordEnvelope, prd.CoordEnvelope) ||
                        _coordType != prd.CoordType ||
                        _width != prd.Width ||
                        _height != prd.Height ||
                        !_spatialRef.IsSame(prd.SpatialRef)
                        )
                    {
                        continue;
                    }
                }
                for (int b = 0; b < prd.BandCount; b++)
                {
                    IRasterBand band = prd.GetRasterBand(b + 1);
                    band.Description = prd.fileName;
                    _rasterBands.Add(band);
                    band.BandNo = _rasterBands.Count;
                }
                _needDisposeObjects.Add(prd);
            }
        }
コード例 #11
0
        private void button13_Click(object sender, EventArgs e)
        {
            IRasterDrawing drawing = _rasterLayer.Drawing as IRasterDrawing;

            oldEvp = drawing.DataProvider.CoordEnvelope;
            drawing.Start();
            drawing.ApplyAdjust(10d, 10d);
            drawing.Stop(true);
            Evp = drawing.DataProvider.CoordEnvelope;
            _canvas.Refresh(enumRefreshType.All);
        }
コード例 #12
0
        public CoordEnvelope Intersect(CoordEnvelope b)
        {
            if (b.MaxX < _minX || b.MinX > _maxX || b.MinY > _maxY || b.MaxY < _minY)
            {
                return(null);
            }
            double minX = Math.Max(_minX, b.MinX);
            double minY = Math.Max(_minY, b.MinY);
            double maxX = Math.Min(_maxX, b.MaxX);
            double maxY = Math.Min(_maxY, b._maxY);

            return(new CoordEnvelope(minX, maxX, minY, maxY));
        }
コード例 #13
0
        public LogicalRasterDataProvider(string fileName, IRasterBand[] rasterBands, object tag)
        {
            if (rasterBands == null || rasterBands.Length == 0)
            {
                throw new ArgumentNullException("rasterBands");
            }
            _tag       = tag;
            _fileNames = new string[] { fileName };
            List <IRasterBand> bs = new List <IRasterBand>();
            bool isFirst          = true;

            foreach (IRasterBand band in rasterBands)
            {
                if (isFirst)
                {
                    _dataType       = band.DataType;
                    _width          = band.Width;
                    _height         = band.Height;
                    _coordEnvelope  = band.CoordEnvelope;
                    _coordType      = band.RasterDataProvider.CoordType;
                    _spatialRef     = band.SpatialRef;
                    _coordTransform = band.CoordTransform;
                    isFirst         = false;
                }
                else
                {
                    if (_dataType != band.DataType ||
                        _width != band.Width ||
                        _height != band.Height)
                    {
                        continue;
                    }
                    if (_coordType != null && _coordType != band.RasterDataProvider.CoordType)
                    {
                        continue;
                    }
                    if (_coordEnvelope != null && !CoordEnvelopeEquals(_coordEnvelope, band.CoordEnvelope))
                    {
                        continue;
                    }
                    if (_spatialRef != null && !_spatialRef.IsSame(band.SpatialRef))
                    {
                        continue;
                    }
                }
                bs.Add(band);
            }
            _rasterBands.AddRange(bs);
        }
コード例 #14
0
 private void WriteWorldFile(GeoDo.RSS.Core.DF.CoordEnvelope env, Size imgSize, ISpatialReference spatial, string bmpFilename)
 {
     try
     {
         double    minx        = env.MinX;
         double    maxy        = env.MaxY;
         double    resolutionX = env.Width / imgSize.Width;
         double    resolutionY = env.Height / imgSize.Height;
         WorldFile worldFile   = new WorldFile();
         worldFile.CreatWorldFile(resolutionX, -resolutionY, minx, maxy, bmpFilename);
         worldFile.CreatXmlFile(spatial == null ? GeoDo.Project.SpatialReference.GetDefault() : spatial, bmpFilename);
     }
     catch
     {
     }
 }
コード例 #15
0
 public ArrayRasterDataProvider(string name, T[][] bandValues, int xSize, int ySize, CoordEnvelope coordEnvelope, ISpatialReference spatialRef)
 {
     _name          = name;
     _coordEnvelope = coordEnvelope;
     _spatialRef    = spatialRef;
     _width         = xSize;
     _height        = ySize;
     _bandNos       = new int[bandValues.Length];
     for (int i = 0; i < bandValues.Length; i++)
     {
         _bands.Add(new ArrayRasterBand <T>(i + 1, bandValues[i], xSize, ySize, this));
         _bandNos[i] = i + 1;
     }
     _maxBandNo = _bandNos.Length;
     TrySetCoordTypeAndCoordEnvelope();
     TryCreateCoordTransform();
     TrySetEnvelopeAndResolutions();
 }
コード例 #16
0
ファイル: AOIProvider.cs プロジェクト: windygu/hispeed
        /// <summary>
        /// 矢量数据取AOI,
        /// 矢量与栅格坐标不一致时候,转矢量。
        /// </summary>
        /// <param name="feature"></param>
        /// <returns></returns>
        private int[] GetIndexes(Feature feature)
        {
            GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform;
            IRasterDrawing rasterDrawing = _canvas.PrimaryDrawObject as IRasterDrawing;

            GeoDo.RSS.Core.DF.CoordEnvelope coordEvp = rasterDrawing.DataProvider.CoordEnvelope.Clone();
            Size     rasterSize = rasterDrawing.Size;
            Envelope rasterEnv  = new Envelope(coordEvp.MinX, coordEvp.MinY, coordEvp.MaxX, coordEvp.MaxY);

            if (feature.Projected && rasterDrawing.DataProvider.CoordType == enumCoordType.GeoCoord)
            {
                using (ShapePolygon spPrj = ShapePolygonPrjToGeo(feature.Geometry as ShapePolygon))
                {
                    if (spPrj != null)
                    {
                        using (IVectorAOIGenerator gen = new VectorAOIGenerator())
                        {
                            return(gen.GetAOI(new ShapePolygon[] { spPrj }, rasterEnv, rasterSize));
                        }
                    }
                }
            }
            else if (!feature.Projected && rasterDrawing.DataProvider.CoordType == enumCoordType.PrjCoord)
            {
                using (ShapePolygon spPrj = ShapePolygonGeoToPrj(feature.Geometry as ShapePolygon))
                {
                    if (spPrj != null)
                    {
                        using (IVectorAOIGenerator gen = new VectorAOIGenerator())
                        {
                            return(gen.GetAOI(new ShapePolygon[] { spPrj }, rasterEnv, rasterSize));
                        }
                    }
                }
            }
            else
            {
                using (IVectorAOIGenerator gen = new VectorAOIGenerator())
                {
                    return(gen.GetAOI(new ShapePolygon[] { feature.Geometry as ShapePolygon }, rasterEnv, rasterSize));
                }
            }
            return(null);
        }
コード例 #17
0
ファイル: RasterDrawing.cs プロジェクト: configare/hispeed
        private void SetEnvelope()
        {
            GeoDo.RSS.Core.DF.CoordEnvelope evp = _dataProvider.CoordEnvelope;
            switch (_dataProvider.CoordType)
            {
            case enumCoordType.Raster:
            case enumCoordType.PrjCoord:
                if (evp == null)
                {
                    evp = new DF.CoordEnvelope(new DF.CoordPoint(0, 0), _dataProvider.Width, _dataProvider.Height);
                }
                _envelope = new DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                if (_dataProvider.SpatialRef != null)
                {
                    _projectionTransform = ProjectionTransformFactory.GetProjectionTransform(SpatialReference.GetDefault(), _dataProvider.SpatialRef);
                }
                _canvas.CoordTransform.DataCoordType = enumDataCoordType.Prj;
                break;

            case enumCoordType.GeoCoord:
                //这里未处理其他坐标系统//???
                _projectionTransform = ProjectionTransformFactory.GetDefault();
                double[] xs = new double[] { evp.MinX, evp.MaxX };
                double[] ys = new double[] { evp.MinY, evp.MaxY };
                _projectionTransform.Transform(xs, ys);
                _envelope = new DrawEngine.CoordEnvelope(xs[0], xs[1], ys[0], ys[1]);
                _canvas.CoordTransform.DataCoordType = enumDataCoordType.Geo;
                break;
            }
            _originalEnvelope    = _envelope.Clone();
            _originalResolutionX = (float)(_originalEnvelope.Width / _dataProvider.Width);
            _originalResolutionY = (float)(_originalEnvelope.Height / _dataProvider.Height);
            //
            if (_dataProvider.SpatialRef == null)
            {
                _canvas.CoordTransform.SpatialRefOfViewer = new SpatialReference(new GeographicCoordSystem());
            }
            else
            {
                _canvas.CoordTransform.SpatialRefOfViewer = _dataProvider.SpatialRef.Clone();
            }
        }
コード例 #18
0
        private static Core.DrawEngine.CoordEnvelope GetDrawingEnvelop(ICanvas canvas, IRasterDataProvider prd)
        {
            if (prd == null)
            {
                return(null);
            }
            GeoDo.RSS.Core.DF.CoordEnvelope cop  = prd.CoordEnvelope.Clone();
            ICoordinateTransform            tans = canvas.CoordTransform;

            if (prd.CoordType == enumCoordType.PrjCoord)
            {
                return(new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(cop.MinX, cop.MaxX, cop.MinY, cop.MaxY));
            }
            else
            {
                GeoDo.RSS.Core.DrawEngine.CoordEnvelope prjEvp = new Core.DrawEngine.CoordEnvelope(cop.MinX, cop.MaxX, cop.MinY, cop.MaxY);
                tans.Geo2Prj(prjEvp);
                return(prjEvp);
            }
        }
コード例 #19
0
        public static IAVILayer CreatAVILayer(string[] fnames, ICanvas canvas, int maxSize, out Size dataSize,
                                              out GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp,
                                              out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp,
                                              out float resolution)
        {
            Size bmpSize = Size.Empty;

            dataSize   = Size.Empty;
            viewPrjEvp = null;
            viewGeoEvp = null;
            resolution = 0;
            BitmapObject[] bobjs = GetBitmapObjects(fnames, maxSize, canvas, out bmpSize, out dataSize, out viewPrjEvp, out viewGeoEvp, out resolution);
            if (bobjs == null || bobjs.Length == 0)
            {
                return(null);
            }
            IAVILayer aviLyr = new AVILayer(bobjs, 500);

            aviLyr.IsRunning = true;
            return(aviLyr);
        }
コード例 #20
0
        //创建输出删格文件
        protected IRasterDataProvider CreateOutRaster(string outFileName, enumDataType dataType, RasterMaper[] inrasterMaper, float resolution)
        {
            IRasterDataDriver raster = RasterDataDriver.GetDriverByName("MEM") as IRasterDataDriver;

            GeoDo.RSS.Core.DF.CoordEnvelope outEnv = null;
            foreach (RasterMaper inRaster in inrasterMaper)
            {
                if (outEnv == null)
                {
                    outEnv = inRaster.Raster.CoordEnvelope;
                }
                else
                {
                    outEnv = outEnv.Intersect(inRaster.Raster.CoordEnvelope);
                }
            }
            float resX, resY;

            if (resolution != 0f)
            {
                resX = resolution;
                resY = resolution;
            }
            else
            {
                resX = inrasterMaper[0].Raster.ResolutionX;
                resY = inrasterMaper[0].Raster.ResolutionY;
            }
            int    width   = (int)(Math.Round(outEnv.Width / resX));
            int    height  = (int)(Math.Round(outEnv.Height / resY));
            string mapInfo = outEnv.ToMapInfoString(new Size(width, height));

            if (File.Exists(outFileName))
            {
                File.Delete(outFileName);
            }
            RasterDataProvider outRaster = raster.Create(outFileName, width, height, 1, dataType, mapInfo) as RasterDataProvider;

            return(outRaster);
        }
コード例 #21
0
ファイル: AOIProvider.cs プロジェクト: windygu/hispeed
        private GeoDo.RSS.Core.DrawEngine.CoordEnvelope GetGeoRect(GeometryOfDrawed geometryOfDrawed)
        {
            int bRow = int.MaxValue, eRow = int.MinValue, bCol = int.MaxValue, eCol = int.MinValue;

            for (int i = 0; i < geometryOfDrawed.RasterPoints.Length; i++)
            {
                if (geometryOfDrawed.RasterPoints[i].X < bCol)
                {
                    bCol = (int)geometryOfDrawed.RasterPoints[i].X;
                }
                if (geometryOfDrawed.RasterPoints[i].X > eCol)
                {
                    eCol = (int)geometryOfDrawed.RasterPoints[i].X;
                }
                if (geometryOfDrawed.RasterPoints[i].Y < bRow)
                {
                    bRow = (int)geometryOfDrawed.RasterPoints[i].Y;
                }
                if (geometryOfDrawed.RasterPoints[i].Y > eRow)
                {
                    eRow = (int)geometryOfDrawed.RasterPoints[i].Y;
                }
            }
            IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing;
            DataIdentify   id  = rst.DataProvider.DataIdentify;

            if (id != null && id.IsOrbit)
            {
                rst.DataProvider.OrbitProjectionTransformControl.Build();
                GeoDo.RSS.Core.DF.CoordEnvelope evp = rst.DataProvider.OrbitProjectionTransformControl.OrbitProjectionTransform.ComputeEnvelope(bRow, bCol, eRow, eCol);
                return(new Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY));
            }
            else
            {
                double geoX1, geoY1, geoX2, geoY2;
                _canvas.CoordTransform.Raster2Geo(bRow, bCol, out geoX1, out geoY1);
                _canvas.CoordTransform.Raster2Geo(eRow, eCol, out geoX2, out geoY2);
                return(new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(geoX1, geoX2, geoY2, geoY1));
            }
        }
コード例 #22
0
 private void TrySetCoordTypeAndCoordEnvelope()
 {
     if (_coordEnvelope == null)
     {
         _coordEnvelope = new DF.CoordEnvelope(0, _width, 0, _height);
     }
     if (_spatialRef == null)
     {
         _coordType = enumCoordType.Raster;
     }
     else
     {
         if (_spatialRef.ProjectionCoordSystem == null)
         {
             _coordType = enumCoordType.GeoCoord;
         }
         else
         {
             _coordType = enumCoordType.PrjCoord;
         }
     }
 }
コード例 #23
0
        private string GenerateRasterThemeGraphy(string dstFile, string drawFName)
        {
            string          templatName    = GetLayoutTheme("0SDI");
            string          colorTabelName = "colortablename=" + "FLDDBLV";
            ILayoutTemplate t = GetTemplateByArg(templatName);

            if (t == null)
            {
                return(null);
            }
            ILayout layout = t.Layout;
            int     width, height;

            GeoDo.RSS.Core.DF.CoordEnvelope envelope = null;
            using (IRasterDataProvider dataPrd = GeoDataDriver.Open(dstFile) as IRasterDataProvider)
            {
                width    = dataPrd.Width;
                height   = dataPrd.Height;
                envelope = dataPrd.CoordEnvelope;
            }
            FitSizeToTemplateWidth(layout, width, height);
            //生成文档,并应用变量
            TryApplyVars(t, drawFName);
            IGxdDocument  gxdDoc = CreateDocument(t, string.IsNullOrEmpty(colorTabelName) ? null : colorTabelName);
            IGxdDataFrame gxdDf  = gxdDoc.DataFrames.Count > 0 ? gxdDoc.DataFrames[0] : null;

            if (gxdDf != null)
            {
                string[]       arguments = new string[] { string.IsNullOrEmpty(colorTabelName) ? null : colorTabelName };
                IGxdRasterItem rst       = new GxdRasterItem(dstFile, colorTabelName, arguments, colorTabelName);//这里传具体的色标定义标识
                gxdDf.GxdRasterItems.Add(rst);
            }
            TrySetAttributesOfElements(gxdDoc);
            string docFname = GetGxdFilename(dstFile, "0SDI");

            gxdDoc.SaveAs(docFname);
            return(docFname);
        }
コード例 #24
0
ファイル: ExtractRectRegion.cs プロジェクト: windygu/hispeed
        public string ExractRect(string file, GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer aoiContainer, string savePath, string regionName)
        {
            _aoiContainer = aoiContainer;
            using (IRasterDataProvider raster = GeoDataDriver.Open(file) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope corEnvelope = null;
            corEnvelope = GetGeoRect();  //获取多个aoi的外接矩形
            evp.MaxX    = corEnvelope.MaxX + 2.0f;
            evp.MaxY    = corEnvelope.MaxY + 2.0f;
            evp.MinX    = corEnvelope.MinX - 2.0f;
            evp.MinY    = corEnvelope.MinY - 2.0f;
            string filename = ExtractFile(file, 0, evp, regionName, savePath);

            return(filename);
        }
コード例 #25
0
        private void TryApplyCustom(ICanvas canvas, Size size, string subIdentify,
                                    GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp,
                                    GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp, float resolution)
        {
            if (canvas == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(subIdentify))
            {
                return;
            }
            if (subIdentify != "CMED")
            {
                return;
            }
            string name = null;

            int[] aoi = null;
            GetAOIArgument(size, viewGeoEvp, resolution, out name, out aoi);
            if (name == null || aoi == null || aoi.Length == 0)
            {
                return;
            }
            _extInfos = "_";
            _extInfos = _extInfos + name;
            ILayer lry = canvas.LayerContainer.GetByName("蒙板层");

            if (lry == null)
            {
                lry = new MaskLayer();
                canvas.LayerContainer.Layers.Add(lry);
            }
            IMaskLayer mask = lry as IMaskLayer;

            mask.Update(Color.White, size, viewPrjEvp, false, aoi);
        }
コード例 #26
0
        private static Size GetMaxDataSize(ICanvas canvas, Core.DrawEngine.CoordEnvelope viewPrjEvp, IRasterDataProvider prd,
                                           out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp)
        {
            viewGeoEvp = null;
            if (prd == null)
            {
                return(Size.Empty);
            }
            viewGeoEvp = null;
            ICoordinateTransform tans = canvas.CoordTransform;

            viewGeoEvp = PrjToGeoCoordEvp(viewPrjEvp, tans);
            if (prd.CoordType == enumCoordType.PrjCoord)
            {
                return(new Size((int)(viewPrjEvp.Width / prd.ResolutionX), (int)(viewPrjEvp.Height / prd.ResolutionY)));
            }
            else
            {
                double wid = 0;
                double hei = 0;
                tans.Prj2Geo(viewPrjEvp.Width, viewPrjEvp.Height, out wid, out hei);
                return(new Size((int)(wid / prd.ResolutionX), (int)(hei / prd.ResolutionY)));
            }
        }
コード例 #27
0
        public override void Execute(string argument)
        {
            if (string.IsNullOrWhiteSpace(argument) || !Directory.Exists(argument))
            {
                return;
            }
            string fullfilename;
            string maskpng = AppDomain.CurrentDomain.BaseDirectory + @"\SystemData\ProductArgs\CLD\Cloudsat_Overview_withcountry.png";

            fullfilename = argument;
            ICommand cmd = _smartSession.CommandEnvironment.Get(2000);

            if (cmd != null)
            {
                cmd.Execute(maskpng);
            }
            GeoDo.RSS.Core.DF.CoordEnvelope env = TryGetActiveViewerEnv();
            if (env == null)
            {
                env = new RSS.Core.DF.CoordEnvelope(65, 145, 10, 60);
            }
            //如果测试整个影像数据,则输出图像为:0,37081,37081
            int x1    = 0;
            int x2    = 37081;
            int outnx = 2000;
            int h1    = -1;      //# km
            int h2    = 21;      //# km
            int nz    = 400;     //# Number of pixels in the vertical.(这个偏移需要指定)
            int dtnx  = 0;       //125
            int dtny  = 0;       //13000
            int xn    = x2 - x1; //值从1700到2000,要读取的实际横轴方向数据。(最后这个偏移会通过地理范围,或者时间范围,计算出来)
            //return;
            CloudsatDataProvider raster = GeoDataDriver.Open(fullfilename) as CloudsatDataProvider;
            CloudSatRasterBand   band   = raster.GetRasterBand(1) as CloudSatRasterBand;

            dtnx = band.Width;  //层数
            dtny = band.Height; //点数
            sw.Start();
            float[] Latitude   = raster.ReadVdata("Latitude", null, x1, x2) as float[];
            float[] Longtitude = raster.ReadVdata("Longitude", null, x1, x2) as float[];
            sw.Stop();
            elapsed = sw.ElapsedMilliseconds;
            Console.WriteLine("ReadVdata" + elapsed + "毫秒");
            int cou      = 0;
            int minIndex = 0;
            int maxIndex = Latitude.Length;

            IntersectEnvelope(Latitude, Longtitude, env, ref cou, ref minIndex, ref maxIndex);

            Console.WriteLine(cou + "点在指定范围内");
            float[] times = raster.ReadVdata("Profile_time", null, x1, x2) as float[];
            if (cou > 0 && (x1 != minIndex || x2 != maxIndex))
            {
                x1 = minIndex;
                x2 = maxIndex;
                xn = x2 - x1 + 1;
                float[] lats  = new float[xn];
                float[] longs = new float[xn];
                float[] ts    = new float[xn];
                Buffer.BlockCopy(Latitude, x1 * 4, lats, 0, xn * 4);
                Buffer.BlockCopy(Longtitude, x1 * 4, longs, 0, xn * 4);
                Buffer.BlockCopy(times, x1 * 4, ts, 0, xn * 4);
                Latitude   = lats;
                Longtitude = longs;
                times      = ts;
            }
            string   start_time = raster.ReadAttribute("start_time") as string;
            DateTime dt_start_time;

            dt_start_time = DateTime.ParseExact(start_time, "yyyyMMddHHmmss", null);
            List <DateTime> dts = new List <DateTime>();

            foreach (float time in times)
            {
                dts.Add(dt_start_time.AddMinutes(time));                                              //应为AddSeconds()
            }
            short[] heights = readSDS("Height", new int[] { x1, 0 }, new int[] { xn, dtnx }, raster); //p1c1,p1c2,..,p1c125,p2c1,...
            short[] datas   = readData(new int[] { x1, 0 }, new int[] { xn, dtnx }, band);

            float[] X = new float[xn];//原始数据中的数据点号
            for (int i = 0; i < xn; i++)
            {
                X[i] = i + x1;
            }
            //heights数据是x=125,y=100=>Z[100,125]
            float[,] Z = new float[xn, dtnx];                 //每个点的高度xn = 100, dtnx =125;
            for (int i = 0; i < dtnx; i++)                    //heights的列,层数
            {
                for (int j = 0; j < xn; j++)                  //heights的行,点数
                {
                    Z[j, i] = heights[j * dtnx + i] * 0.001f; //m-->km
                }
            }

            short[,] newdata = new short[xn, dtnx];//点数,层数
            var dest = Marshal.UnsafeAddrOfPinnedArrayElement(newdata, 0);

            Marshal.Copy(datas, 0, dest, datas.Length);//将数据的一维数组变化为2维数组
            Marshal.Release(dest);

            short[,] dat = Rote <short>(newdata);//调换数组的行列,dat为层数×点数的数组;

            Bitmap bmp = null;
            IntPtr src;

            outnx             = xn < 4000 ? xn : 4000;
            float[,] dataf    = interp2d_12(newdata, X, Z, x1, x2, outnx, h2, h1, nz); //将数据进行插值
            float[,] newdataf = Rote <float>(dataf);                                   //调换数组的行列,dat为层数×点数的数组;
            int count = newdataf.Length;

            float[] datac = new float[count];
            src = Marshal.UnsafeAddrOfPinnedArrayElement(newdataf, 0);//
            Marshal.Copy(src, datac, 0, newdataf.Length);
            Marshal.Release(dest);
            DisplayLonLat(Latitude, Longtitude, fullfilename);
            //string[] dtimes = new string[dts.Count];
            //for(int i =0;i< dts.Count;i++)
            //{
            //    DateTime dt  = dts[i];
            //    dtimes[i] = dt.ToString("HH:mm:ss");
            //}
            //try
            //{
            //    bmp = ToBitmap(outnx, nz, datac);//点数(宽),层数(高)
            //    if (bmp != null)
            //    {
            //        string bmpfilename = MifEnvironment.GetFullFileName("2B-GEOPROF.Radar_Reflectivity.bmp");
            //        bmp.Save(bmpfilename);
            //        //OpenFileFactory.Open(bmpfilename);

            //        CloudsatPlotWnd wnd = _smartSession.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(_id) as CloudsatPlotWnd;
            //        if (wnd != null)
            //        {
            //            _smartSession.SmartWindowManager.DisplayWindow(wnd, new WindowPosition(System.Windows.Forms.DockStyle.Bottom, false));
            //            wnd.Reset(fullfilename, bmp, x1, x2, h1, h2, dtimes, null);
            //        }

            //        frmPlot frm = new frmPlot();
            //        ucCloudsatPlot plots = frm.plots;
            //        plots.AddYAxis(dtimes);
            //        plots.Reset(fullfilename, bmp, x1, x2, h1, h2, null);
            //        //plots.Rerender();
            //        //frm.Reset(fullfilename, bmp, x1, x2, h1, h2, dtimes, null);
            //        frm.Show();
            //    }
            //}
            //finally
            //{
            //    //if (bmp != null)
            //    //    bmp.Dispose();
            //}
        }
コード例 #28
0
 private string GetMapInfoString(CoordEnvelope coordEnvelope, int width, int height)
 {
     return(coordEnvelope != null?coordEnvelope.ToMapInfoString(new Size(width, height)) : string.Empty);
 }
コード例 #29
0
        private static BitmapObject[] GetBitmapObjects(string[] fnames, int maxSize, ICanvas canvas, out Size bmpSize,
                                                       out Size dataSize, out GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp,
                                                       out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp,
                                                       out float resolution)
        {
            bmpSize    = Size.Empty;
            dataSize   = new Size();
            viewPrjEvp = null;
            viewGeoEvp = null;
            resolution = 0;
            List <BitmapObject> bmpObjs = new List <BitmapObject>();
            BitmapObject        bmpO;

            GeoDo.RSS.Core.DrawEngine.CoordEnvelope drawEvp = null;
            bool isFirst = true;

            foreach (string fname in fnames)
            {
                if (!File.Exists(fname))
                {
                    continue;
                }
                using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
                {
                    IOverviewGenerator ov = prd as IOverviewGenerator;
                    bmpSize = ov.ComputeSize(maxSize);
                    Bitmap         bmp      = new Bitmap(bmpSize.Width, bmpSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                    RasterIdentify identify = new RasterIdentify(fname);
                    object[]       sts      = GetColorTableFunc(prd, identify.ProductIdentify, identify.SubProductIdentify);
                    if (sts != null)
                    {
                        ov.Generate(new int[] { 1, 1, 1 }, sts, ref bmp);
                    }
                    else
                    {
                        int[] bands = prd.GetDefaultBands();
                        if (bands == null || bands.Length == 0)
                        {
                            return(null);
                        }
                        ov.Generate(bands, ref bmp);
                    }
                    drawEvp = GetDrawingEnvelop(canvas, prd);
                    if (isFirst)
                    {
                        viewPrjEvp = drawEvp;
                        ICoordinateTransform tans = canvas.CoordTransform;
                        viewGeoEvp = PrjToGeoCoordEvp(viewPrjEvp, tans);
                        resolution = prd.ResolutionX;
                        dataSize   = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp);
                        isFirst    = false;
                    }
                    else
                    {
                        viewPrjEvp = viewPrjEvp.Union(drawEvp);
                        dataSize   = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp);
                        //如果分辩率不相等则取最大的分辨率
                        if (resolution < prd.ResolutionX)
                        {
                            resolution = prd.ResolutionX;
                        }
                    }
                    bmpO = new BitmapObject(bmp, drawEvp);
                    bmpObjs.Add(bmpO);
                }
            }
            return(bmpObjs.Count != 0 ? bmpObjs.ToArray() : null);
        }