private void CalcRasterOffset() { CoordEnvelope oEnvelope = _raster.CoordEnvelope; CoordEnvelope tEnvelope = _vHeader.CoordEnvelope; Size oSize = new Size(_raster.Width, _raster.Height); Size tSize = new Size(_vHeader.Width, _vHeader.Height); float xScale = _raster.ResolutionX / _vHeader.ResolutionX; float yScale = _raster.ResolutionY / _vHeader.ResolutionY; Rectangle rectDst, srcInDst, intInDst, intInSrc; bool isInternal = RasterRectOffset.ComputeBeginEndRowCol( oEnvelope, oSize, new PointF(_raster.ResolutionX, _raster.ResolutionY), tEnvelope, tSize, new PointF(_vHeader.ResolutionX, _vHeader.ResolutionY), out rectDst, out srcInDst, out intInDst, out intInSrc); if (!isInternal) { ;//不相交... } _inOffset = new RasterRectOffset(); _inOffset.rectDst = rectDst; _inOffset.srcInDst = srcInDst; _inOffset.intInDst = intInDst; _inOffset.intInSrc = intInSrc; _inOffset.ResolutionXScale = xScale; _inOffset.ResolutionYScale = yScale; }
protected bool CheckAOIIntersectFileSize(string file, double ratio, out float reslx, out float resly, out int[] dataPos) { dataPos = null; using (IRasterDataProvider dataPrd = GeoDataDriver.Open(file) as IRasterDataProvider) { CoordEnvelope cordenv = dataPrd.CoordEnvelope; reslx = dataPrd.ResolutionX; resly = dataPrd.ResolutionY; if (cordenv != null) { PrjEnvelope filePrj = new PrjEnvelope(cordenv.MinX, cordenv.MaxX, cordenv.MinY, cordenv.MaxY); //dstmainPrj = PrjEnvelope.Intersect(env, filePrj); //if (dstmainPrj != null && dstmainPrj.Width > 0 && dstmainPrj.Height > 0) //{ // int xoffset = (int)((dstmainPrj.MinX - cordenv.MinX) / reslx); // int yoffset = (int)((cordenv.MaxY - dstmainPrj.MaxY) / resly); // int width = (int)(dstmainPrj.Width / reslx); // int height = (int)(dstmainPrj.Height / resly); // dataPos = new int[4] { xoffset, yoffset, width, height }; // return true; //} throw new ArgumentOutOfRangeException(Path.GetFileName(file), "自定义区域与文件不存在相交区域!"); } throw new ArgumentException(Path.GetFileName(file), "文件坐标范围不可用!"); } }
/// <summary> /// 创建LDFRaster /// </summary> /// <param name="outFileName">LDF文件名称</param> /// <param name="inrasterMaper">输入文件参考</param> /// <param name="outbandcount">输出文件波段</param> /// <returns></returns> protected IRasterDataProvider CreateOutLDFRaster(string outFileName, RasterMaper[] inrasterMaper, int outbandcount) { IRasterDataDriver raster = RasterDataDriver.GetDriverByName("LDF") as IRasterDataDriver; 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)); string[] optionString = new string[] { "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + inrasterMaper[0].Raster.SpatialRef == null?"":("SPATIALREF=" + inrasterMaper[0].Raster.SpatialRef.ToProj4String()), "MAPINFO={" + 1 + "," + 1 + "}:{" + outEnv.MinX + "," + outEnv.MaxY + "}:{" + resX + "," + resY + "}" }; RasterDataProvider outRaster = raster.Create(outFileName, width, height, outbandcount, enumDataType.Int16, optionString) as RasterDataProvider; return(outRaster); }
private void DoRender(RenderArgs args) { _isUseDummyMap = _canvas.DummyRenderModeSupport.IsDummyModel; if (_buffer == null || _preSize.Width != _canvas.Container.Width || _preSize.Height != _canvas.Container.Height) { if (_buffer != null) { _buffer.Dispose(); } _buffer = new Bitmap(_canvas.Container.Width, _canvas.Container.Height, PixelFormat.Format32bppArgb); _preSize = _canvas.Container.Size; _isUseDummyMap = false; } if (_isUseDummyMap) { RenderUseDummyMap(args, _buffer, _preEnvelope); } else { using (Graphics g = Graphics.FromImage(_buffer)) { g.Clear(Color.Transparent); Graphics og = args.Graphics; args.BeginRender(g); DirectRender(args); _preEnvelope = _canvas.CurrentEnvelope.Clone(); og.DrawImage(_buffer, 0, 0); } } }
public frmCreatBookMarkGroup(CoordEnvelope envelop) { InitializeComponent(); _evp = envelop; txtName.Focus(); FillGeoRangeControl(); }
public static int[] GetAOI(CoordEnvelope fileCorEnv, AOIContainerLayer aoiContainer, Size fileSize) { int[] retAOI = null, aoi = null; VectorAOIGenerator vg = new VectorAOIGenerator(); Envelope fileEnv = new Envelope(fileCorEnv.MinX, fileCorEnv.MinY, fileCorEnv.MaxX, fileCorEnv.MaxY); foreach (object obj in aoiContainer.AOIs) { try { aoi = vg.GetAOI(new ShapePolygon[] { (obj as Feature).Geometry as ShapePolygon }, fileEnv, fileSize); if (aoi == null) { continue; } if (retAOI == null) { retAOI = aoi; } else { retAOI = GeoDo.RSS.RasterTools.AOIHelper.Merge(new int[][] { retAOI, aoi }); } } catch (System.Exception ex) { continue; } } return(retAOI); }
private PencilToolLayer CreateToolLayer() { PencilToolLayer toolLayer = new PencilToolLayer(); toolLayer.PencilType = enumPencilType.Rectangle; toolLayer.PencilIsFinished = (geometry) => { CoordEnvelope env = GeometryToCoordEnvelope(geometry); if (env == null) { return; } Dictionary <int, CoordPoint> points = GetSelectedPoints(env); if (_maskIsDelete) { _maskLayer.Add(points); } else { _maskLayer.Remove(points); } _labeledPt = _maskLayer.MaskPoints.Count; canvasHost1.Canvas.Refresh(enumRefreshType.All); UpdateMaskText(); }; return(toolLayer); }
public static bool IsInteractived(CoordEnvelope envelopeA, CoordEnvelope envelopeB) { RectangleF a = new RectangleF((float)envelopeA.MinX, (float)envelopeA.MinY, (float)envelopeA.Width, (float)envelopeA.Height); RectangleF b = new RectangleF((float)envelopeB.MinX, (float)envelopeB.MinY, (float)envelopeB.Width, (float)envelopeB.Height); return(a.IntersectsWith(b)); }
private void ResetArgNDVIMaxMin(NDVISettingItem[] settings, ref double ndviMin, ref double dst) { if (settings == null || settings.Length < 1) { return; } CoordEnvelope envelope = _argumentProvider.DataProvider.CoordEnvelope; if (envelope == null) { return; } foreach (NDVISettingItem item in settings) { if (item.Envelope == null) { continue; } if (item.IsUse) { if (envelope.MaxX >= item.Envelope.MaxX && envelope.MinX <= item.Envelope.MinX && envelope.MaxY >= item.Envelope.MaxY && envelope.MinY <= item.Envelope.MinY) { ndviMin = item.MinValue; dst = item.MaxValue - item.MinValue; return; } } } }
private static void SetThemeEnvelope(IThemeGraphGenerator tgg, CoordEnvelope customEnv) { if (customEnv != null) { (tgg as CmaThemeGraphGenerator).SetEnvelope(new Layout.GxdEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY)); } }
private IRasterDataProvider CreateOutRaster(string outFileName, RasterMaper[] rasterMaper) { IRasterDataDriver raster = RasterDataDriver.GetDriverByName("MEM") as IRasterDataDriver; CoordEnvelope outEnv = null; foreach (RasterMaper inRaster in rasterMaper) { if (outEnv == null) { outEnv = inRaster.Raster.CoordEnvelope; } else { outEnv = outEnv.Union(inRaster.Raster.CoordEnvelope); } } float resX = rasterMaper[0].Raster.ResolutionX; float resY = rasterMaper[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); }
private void SetAOIGeometry(CoordEnvelope evp) { if (evp == null) { _aoiContainer.Reset(); } else { double prjX1, prjY1, prjX2, prjY2; GeometryOfDrawed geo = new GeometryOfDrawed(); geo.ShapeType = "Rectangle"; geo.IsPrjCoord = true; canvasHost1.Canvas.CoordTransform.Geo2Prj(evp.MinX, evp.MaxY, out prjX1, out prjY1); canvasHost1.Canvas.CoordTransform.Geo2Prj(evp.MaxX, evp.MinY, out prjX2, out prjY2); geo.RasterPoints = new PointF[] { new PointF((float)prjX1, (float)prjY1), new PointF((float)prjX2, (float)prjY1), new PointF((float)prjX2, (float)prjY2), new PointF((float)prjX1, (float)prjY2) }; geo.Types = new byte[] { 1, 1, 1, 129 }; _aoiContainer.AddAOI(geo); } canvasHost1.Canvas.Refresh(enumRefreshType.All); }
private void TryParseArgs() { if (_args == null || _args.Length == 0) { _threebnds = new string[] { "SD_NorthernDaily_A" }; _spatialRef = SpatialReference.FromProj4("+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m +no_defs"); _coordEnvelope = new CoordEnvelope(-9036842.762, 9036842.762, -9036842.762, 9036842.762); } else { string[] alldatasets = new string[16] { "SD_Flags_NorthernDaily_A", "SD_Flags_NorthernDaily_D", "SD_Flags_SouthernDaily_A", "SD_Flags_SouthernDaily_D", "SD_NorthernDaily_A", "SD_NorthernDaily_D", "SD_SouthernDaily_A", "SD_SouthernDaily_D", "SWE_Flags_NorthernDaily_A", "SWE_Flags_NorthernDaily_D", "SWE_Flags_SouthernDaily_A", "SWE_Flags_SouthernDaily_D", "SWE_NorthernDaily_A", "SWE_NorthernDaily_D", "SWE_SouthernDaily_A", "SWE_SouthernDaily_D" }; string[] arguments = _args as string[]; List <string> datas = new List <string>(); string[] parts; foreach (string set in arguments) { if (set.Contains("NorthernDaily") || set.Contains("SouthernDaily")) { parts = set.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { foreach (string data in alldatasets) { if (data == part) { datas.Add(part); break; } } } } } if (datas.Count == 0) { _threebnds = new string[] { "SD_NorthernDaily_A" }; _spatialRef = SpatialReference.FromProj4("+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m +no_defs"); _coordEnvelope = new CoordEnvelope(-9036842.762, 9036842.762, -9036842.762, 9036842.762); return; } _threebnds = datas.ToArray(); if (_threebnds[0].Contains("NorthernDaily")) { _spatialRef = SpatialReference.FromProj4("+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m +no_defs"); _coordEnvelope = new CoordEnvelope(-9036842.762, 9036842.762, -9036842.762, 9036842.762); } if (_threebnds[0].Contains("SouthernDaily")) { _spatialRef = SpatialReference.FromProj4("+proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m +no_defs "); _coordEnvelope = new CoordEnvelope(-9036842.762, 9036842.762, -9036842.762, 9036842.762); } } }
public MatrixPixelIndexMapper(string name, int width, int height, CoordEnvelope coordEnvelope, ISpatialReference spatialRef) { _name = name; _buffer = new byte[width * height]; _size = new System.Drawing.Size(width, height); _spatialRef = spatialRef; _coordEnvelope = coordEnvelope; }
/// <summary> /// 四周都扩大一点经纬度范围,使选中的分区周围留出边界,看的更加方便 /// </summary> /// <param name="envelop"></param> private void EnlargeEnvelope(ref CoordEnvelope envelop) { if (envelop == null) { return; } envelop = new CoordEnvelope(envelop.MinX - 0.1, envelop.MaxX + 0.1, envelop.MinY - 0.1, envelop.MaxY + 0.1); }
public CoordEnvelope ToEnvelope() { if (_envelope == null) { _envelope = new CoordEnvelope(MinX, MaxX, MinY, MaxY); } return(_envelope); }
public MemPixelIndexMapper(string name, int capacity, Size size, CoordEnvelope coordEnvelope, ISpatialReference spatialRef) { _name = name; _indexes = new List <int>(capacity); _size = size; _spatialRef = spatialRef; _coordEnvelope = coordEnvelope; }
private string EnvelopeToString(CoordEnvelope envelope) { if (envelope == null) { return(""); } return(envelope.MinX.ToString() + "," + envelope.MaxX.ToString() + "," + envelope.MinY.ToString() + "," + envelope.MaxY); }
public InterestedRaster(string fname, Size size, CoordEnvelope coordEnvelope, ISpatialReference spatialRef) { _size = size; _coordEnvelope = coordEnvelope; _spatialRef = spatialRef; _fileName = fname; BuildInternalBuffer(fname); }
public int[,] NewDatArray() { CoordEnvelope envelope = new CoordEnvelope(-180, 180, -90, 90); int height = (int)Math.Ceiling((envelope.MaxY - envelope.MinY) / _resolution); int width = (int)Math.Ceiling((envelope.MaxX - envelope.MinX) / _resolution); return(new int[height, width]); }
public int[,] InitValueArray() { CoordEnvelope envelope = new CoordEnvelope(-180, 180, -90, 90); _datheight = (int)Math.Ceiling((envelope.MaxY - envelope.MinY) / _resolution); _datwidth = (int)Math.Ceiling((envelope.MaxX - envelope.MinX) / _resolution); return(new int[_datheight, _datwidth]); }
public InterestedRaster(string fname, Size size, CoordEnvelope coordEnvelope, int extHeaderSize) { _size = size; _extHeaderSize = extHeaderSize; _coordEnvelope = coordEnvelope; _fileName = fname; BuildInternalBuffer(fname); }
public BinaryBitmapLayer(string name, Bitmap bitmap, CoordEnvelope coordEnvelope, bool isGeoCoord) { _name = name; _bitmap = bitmap; _coordEnvelope = coordEnvelope; _isGeoCoord = isGeoCoord; CreateImageAttributes(); }
public SimpleVectorObject(string name, CoordEnvelope geometry) { if (name != null) { _attributeValues.Add(name); } _geometry = geometry; }
private void GeoRegionChanged(CoordEnvelope region) { ucGeoRangeControl1.MinX = region.MinX; ucGeoRangeControl1.MinY = region.MinY; ucGeoRangeControl1.MaxX = region.MaxX; ucGeoRangeControl1.MaxY = region.MaxY; UpdateSizeByGeoRange(); }
private void ClearOutGeoInfos() { OutGeoRangeControl.MinX = 0; OutGeoRangeControl.MaxX = 0; OutGeoRangeControl.MinY = 0; OutGeoRangeControl.MaxY = 0; _outCoordEnvelope = null; }
public static IExtractResult StatAnaylsisBase(ISmartSession session, string outFileIdentify, string aoiTemplate, string subProductIdentify, string algorithmName, bool isCustom, bool multiSelect) { (session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct(subProductIdentify); GetCommandAndExecute(session, 6602); IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct; if (msp == null) { return(null); } object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles"); if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName)) { return(null); } string[] files = obj as string[]; if (files == null || files.Length == 0) { if (File.Exists(obj.ToString())) { files = new string[] { obj.ToString() } } ; else { return(null); } } CoordEnvelope customEnv = null; if (isCustom && !SetAOIArugment(files, msp, multiSelect, out customEnv)) { return(null); } else if (!isCustom) { msp.ArgumentProvider.SetArg("AOI", string.IsNullOrEmpty(aoiTemplate) ? null : aoiTemplate); } else if (customEnv != null) { RasterProject.PrjEnvelope prjEnvelope = new RasterProject.PrjEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY); msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope); } try { msp.ArgumentProvider.SetArg("FileNameGenerator", (session.MonitoringSession as IMonitoringSession).FileNameGenerator); msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify); IExtractResult result = msp.Make(null); DisplayResultClass.DisplayResult(session, msp, result, false); return(result); } catch { return(null); } }
public frmStatSubRegionTemplates(Size size, CoordEnvelope coordEenvelope, float resolution) { _size = size; _envelope = new Envelope(coordEenvelope.MinX, coordEenvelope.MinY, coordEenvelope.MaxX, coordEenvelope.MaxY); _resolution = resolution; InitializeComponent(); _customVectorRegionFilename = AppDomain.CurrentDomain.BaseDirectory + "CustomVectorRegion.mainfestfile"; InitCategories(); }
/// <summary> /// /// </summary> /// <param name="orbitSize">原数据大小</param> /// <param name="orbitEnvelope">原数据经纬度范围</param> /// <param name="zoom">结果放大倍数</param> /// <param name="prograssTracker">进度条</param> public FY3TouImportSMART(Size orbitSize, CoordEnvelope orbitEnvelope, float zoom, float invaildValue, Action<int, string> prograssTracker) { _prograssTracker = prograssTracker; _width = orbitSize.Width; _height = orbitSize.Height; _coordEnvelope = orbitEnvelope; _zoom = zoom; _inVaildValue = invaildValue; }
private static Envelope PrjToGeoEnv(IPrimaryDrawObject priObj, CoordEnvelope coordEnvelope) { double geoMinX, geoMinY, geoMaxX, geoMaxY; priObj.Prj2Geo(coordEnvelope.MinX, coordEnvelope.MaxY, out geoMinX, out geoMaxY); priObj.Prj2Geo(coordEnvelope.MaxX, coordEnvelope.MinY, out geoMaxX, out geoMinY); return(new Envelope(Math.Min(geoMinX, geoMaxX), Math.Min(geoMinY, geoMaxY), Math.Max(geoMinX, geoMaxX), Math.Max(geoMinY, geoMaxY))); }