public GeoDo.RSS.Core.DrawEngine.CoordEnvelope GetMinGeoRect() { IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing; if (rst == null) { return(null); } GeoDo.RSS.Core.DrawEngine.CoordEnvelope retRect = GetGeoRect(); if (retRect == null) { return(null); } GeoDo.RSS.Core.DrawEngine.CoordEnvelope envelope = null; GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform; if (rst.DataProvider.CoordType == enumCoordType.GeoCoord) { envelope = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(rst.DataProvider.CoordEnvelope.MinX, rst.DataProvider.CoordEnvelope.MaxX, rst.DataProvider.CoordEnvelope.MinY, rst.DataProvider.CoordEnvelope.MaxY); } else if (rst.DataProvider.CoordType == enumCoordType.PrjCoord) { double geoX1, geoY1, geoX2, geoY2; tran.Prj2Geo(rst.DataProvider.CoordEnvelope.MinX, rst.DataProvider.CoordEnvelope.MaxY, out geoX1, out geoY1); tran.Prj2Geo(rst.DataProvider.CoordEnvelope.MaxX, rst.DataProvider.CoordEnvelope.MinY, out geoX2, out geoY2); envelope = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(geoX1, geoX2, geoY2, geoY1); } double minX = envelope.MinX > retRect.MinX ? envelope.MinX : retRect.MinX; double maxX = envelope.MaxX < retRect.MaxX ? envelope.MaxX : retRect.MaxX; double minY = envelope.MinY > retRect.MinY ? envelope.MinY : retRect.MinY; double maxY = envelope.MaxY < retRect.MaxY ? envelope.MaxY : retRect.MaxY; return(new Core.DrawEngine.CoordEnvelope(minX, maxX, minY, maxY)); }
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]); }
public System.Drawing.Rectangle GetRasterRect() { IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing; if (rst == null) { return(Rectangle.Empty); } GeoDo.RSS.Core.DrawEngine.CoordEnvelope retRect = null; foreach (object obj in _aoiContainer.AOIs) { GeoDo.RSS.Core.DrawEngine.CoordEnvelope rect = null; if (obj is GeometryOfDrawed) { rect = GetRasterRect(obj as GeometryOfDrawed); } else if (obj is Feature) { rect = GetRasterRect(obj as Feature); } if (rect == null) { continue; } if (retRect == null) { retRect = rect; } else { retRect = retRect.Union(rect); } } return(new Rectangle((int)retRect.MinX, (int)retRect.MinY, (int)retRect.Width, (int)retRect.Height)); }
public AOIItem[] GetAOIItems() { IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing; if (rst == null) { return(null); } List <AOIItem> aoiItems = new List <AOIItem>(); foreach (object obj in _aoiContainer.AOIs) { string name = string.Empty; GeoDo.RSS.Core.DrawEngine.CoordEnvelope rect = null; if (obj is GeometryOfDrawed) { rect = GetGeoRect(obj as GeometryOfDrawed); } else if (obj is Feature) { rect = GetGeoRect(obj as Feature, out name); } if (rect == null) { continue; } aoiItems.Add(new AOIItem(name, rect)); } return(aoiItems.Count > 0 ? aoiItems.ToArray() : null); }
private void button8_Click(object sender, EventArgs e) { Size size = new System.Drawing.Size(10, 10); Int16[] data = new Int16[size.Width * size.Height]; for (int r = 0; r < size.Height; r++) { for (int c = 0; c < size.Width; c++) { data[r * size.Width + c] = 0; } } Dictionary <Int16, Color> colormap = new Dictionary <short, Color>(); colormap.Add(0, Color.FromArgb(64, 0, 0, 255)); // GeoDo.RSS.Core.DrawEngine.CoordEnvelope evp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope( 117.66, 118.66, 47.80, 48.80); MemoryRaster <Int16> raster = new MemoryRaster <short>("FIRE", data, size, 2, evp, true); MemoryBitmapLayer <Int16> layer = new MemoryBitmapLayer <short>(raster, colormap); // _canvas.LayerContainer.Layers.Add(layer); _canvas.Refresh(enumRefreshType.All); //layer.Update(); //layer.UpdateColorMap(Dictionary<Int16,Color> }
public int[] GetBitmapIndexes(Feature feature) { IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing; GeoDo.RSS.Core.DrawEngine.CoordEnvelope coordEvp = rst.Envelope; Envelope evp = null; if (feature.Projected) { evp = new Envelope(coordEvp.MinX, coordEvp.MinY, coordEvp.MaxX, coordEvp.MaxY); } else { if (rst.DataProvider.DataIdentify != null && rst.DataProvider.DataIdentify.IsOrbit) { rst.DataProvider.OrbitProjectionTransformControl.Build(); } GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform; double geoX1, geoY1, geoX2, geoY2; tran.Prj2Geo(coordEvp.MinX, coordEvp.MaxY, out geoX1, out geoY1); tran.Prj2Geo(coordEvp.MaxX, coordEvp.MinY, out geoX2, out geoY2); evp = new Envelope(geoX1, geoY2, geoX2, geoY1); } Size size = rst.Bitmap.Size; using (IVectorAOIGenerator gen = new VectorAOIGenerator()) { return(gen.GetAOI(new ShapePolygon[] { feature.Geometry as ShapePolygon }, evp, size)); } }
private void SetAOIGeometry(GeoDo.RSS.Core.DrawEngine.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 bool TryAddAviLayerToCanvas(ICanvas canvas, IAVILayer aviLyr, GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp) { canvas.LayerContainer.Layers.Add(aviLyr); canvas.CurrentEnvelope = viewPrjEvp; canvas.Refresh(enumRefreshType.All); return(true); }
/// <summary> /// 相交 /// </summary> /// <param name="rect"></param> /// <returns></returns> public bool IntersectsWith(CoordEnvelope rect) { return(_minX < rect.MaxX && _maxX > rect.MinX && _minY < rect.MaxY && _maxY > rect.MinY); }
private void AddVectorLayer(string strVecName) { if (_vectorHostLayer == null) { return; } if (canvasHost1.Canvas.IsRasterCoord) { return; } IRasterDrawing drawing = canvasHost1.Canvas.PrimaryDrawObject as IRasterDrawing; if (drawing != null) { drawing.TryCreateOrbitPrjection(); } string extName = Path.GetExtension(strVecName).ToUpper(); if (extName == ".SHP") { _vectorHostLayer.AddData(strVecName, null); CodeCell.AgileMap.Core.IMap map = _vectorHostLayer.Map as CodeCell.AgileMap.Core.IMap; CodeCell.AgileMap.Core.FeatureLayer fetL = map.LayerContainer.Layers[0] as CodeCell.AgileMap.Core.FeatureLayer; CodeCell.AgileMap.Core.FeatureClass fetc = fetL.Class as CodeCell.AgileMap.Core.FeatureClass; CodeCell.AgileMap.Core.Envelope evp = fetc.FullEnvelope.Clone() as CodeCell.AgileMap.Core.Envelope; GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY); canvasHost1.Canvas.CurrentEnvelope = cvEvp; } canvasHost1.Canvas.Refresh(enumRefreshType.All); }
private void CreateFirstBitmap(Action <int, int> progress) { int w = _canvas.Container.Width; int h = _canvas.Container.Height; float sx = w / (float)_dataProviderCopy.Width; float sy = h / (float)_dataProviderCopy.Height; sx = Math.Min(sx, sy); w = (int)(_dataProviderCopy.Width * sx); h = (int)(_dataProviderCopy.Height * sx); if (_firstBitmap != null) { _firstBitmap.Dispose(); } _firstBitmap = _tileBitmapProvider.DataProviderReader.GetOverview(_dataProviderCopy, w, h, _selectedBandNos, (p) => { if (progress != null) { progress(_selectedBandNos.Length * h, p); } }); _bitmap = _firstBitmap.Clone() as Bitmap; _envelope = _originalEnvelope; }
public NearestTilesLocator(IRasterDataProvider dataProvider, GeoDo.RSS.Core.DrawEngine.CoordEnvelope originalEnvelope, float originalResolutionX, float originalResolutionY) { _envelope = originalEnvelope; _dataProvider = dataProvider; _originalResolutionX = originalResolutionX; _originalResolutionY = originalResolutionY; }
/// <summary> /// /// </summary> /// <param name="argument">格式"*#*"冒号前面部分表示文件名称,冒号后面部分表示所选投影坐标的Wkt格式字符串</param> public override void Execute(string argument) { try { string fileName = ""; ISpatialReference proj = null; AOIItem[] aois; fileName = TryGetInfoFromActiveView(out aois); proj = SpatialReference.GetDefault(); List <PrjEnvelopeItem> lstEnvelope = new List <PrjEnvelopeItem>(); for (int i = 0; i < aois.Length; i++) { AOIItem aoi = aois[i]; GeoDo.RSS.Core.DrawEngine.CoordEnvelope env = aoi.GeoEnvelope; if (env.IsEmpty()) { throw new Exception("获得的感兴趣区域是空值:" + aoi.ToString()); } PrjEnvelope prjEnv = new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY); lstEnvelope.Add(new PrjEnvelopeItem("AOI", prjEnv)); } if (string.IsNullOrWhiteSpace(fileName)) { throw new Exception("无法从参数中解析出文件名:" + argument); } Project(fileName, proj, lstEnvelope == null || lstEnvelope.Count == 0 ? null : lstEnvelope.ToArray()); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 包含 /// </summary> /// <param name="ext"></param> /// <returns></returns> public bool Contains(CoordEnvelope ext) { Contract.Requires(ext != null); return((this.MinX <= ext.MinX) && ((ext.MaxX) <= (this.MaxX)) && (this.MinY <= ext.MinY) && ((ext.MaxY) <= (this.MaxY))); }
private Envelope GetEnvelope() { if (_canvas.PrimaryDrawObject == null) { return(null); } GeoDo.RSS.Core.DrawEngine.CoordEnvelope evp = _canvas.PrimaryDrawObject.OriginalEnvelope.Clone(); return(new Envelope(evp.MinX, evp.MinY, evp.MaxX, evp.MaxY)); }
private PrjEnvelope TryGetFirstAOI() { GeoDo.RSS.Core.DrawEngine.CoordEnvelope env = TryGetInfoFromActiveView(); if (env == null || env.IsEmpty()) { return(null); } return(new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY)); }
private void DrawByTiles(IDrawArgs drawArgs) { LevelDef nearestLevel; Rectangle rect; int bRow, bCol, rows, cols; TileIdentify[] tiles = _tileBitmapProvider.GetVisibleTiles(out nearestLevel, out rect, out bRow, out bCol, out rows, out cols); if (_isFirst || tiles == null) { _isFirst = false; return; } if (rows == 0 || cols == 0) { return; } if (tiles != null) { //compute envelope DrawEngine.CoordPoint location = new DrawEngine.CoordPoint(_originalEnvelope.MinX + _originalResolutionX * rect.X, _originalEnvelope.MinY + _originalResolutionY * (_dataProvider.Height - (rect.Y + rect.Height))); _envelope = new DrawEngine.CoordEnvelope(location, _originalResolutionX * rect.Width, _originalResolutionY * rect.Height); //build empty bitmap int tileSize = _tileBitmapProvider.TileComputer.TileSize; int powerOf2 = _tileSetting.PowerOf2; int w = cols << powerOf2; //cols * tileSize int h = rows << powerOf2; //rows * tileSize if (_bitmap != null && (_preHeight != h || _preWidth != w)) { _bitmap.Dispose(); _bitmap = null; } if (_bitmap == null) { _bitmap = new Bitmap(w, h, PixelFormat.Format24bppRgb); } _preWidth = w; _preHeight = h; // using (Graphics g = Graphics.FromImage(_bitmap)) { foreach (TileIdentify t in tiles) { TileBitmap tb = _tileBitmapProvider.GetTileBitmap(t); if (tb.IsEmpty()) { continue; } int x = (t.Col - bCol) << powerOf2; //(t.Col - bCol) * tileSize int y = (t.Row - bRow) << powerOf2; //(t.Row - bRow) * tileSize; //tb.Bitmap.Save("f:\\x" + t.Row.ToString() + "_" + t.Col.ToString()+".bmp", ImageFormat.Bmp); g.DrawImage(tb.Bitmap, x, y); } } } }
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)); }
public void To(ILinkableViewer fromViewer, GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewport) { foreach (ILinkableViewer v in _viewers) { if (!v.Equals(fromViewer)) { v.To(viewport.Clone()); } } }
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); } }
private void CorrectCoordEnvelope(float scale) { double resX = _coordEnvelope.Width / (scale * _rasterSize.Width); double resY = _coordEnvelope.Height / (scale * _rasterSize.Height); double minX = _coordEnvelope.MinX; double maxY = _coordEnvelope.MaxY; double maxX = minX + _bitmap.Width * resX; double minY = maxY - _bitmap.Height * resY; _coordEnvelope = new CoordEnvelope(minX, maxX, minY, maxY); }
public void SetCurrentGCPPos(int index) { if (_aoiContainer.AOIs.Count() == 1) { //GeometryOfDrawed geometry = _aoiContainer.FirstAOI as GeometryOfDrawed; //canvasHost1.Canvas.CurrentViewControl = _aoiContainer as IControlLayer; //_aoiContainer.AddAOI(geometry); //_aoiContainer.IsAllowEdit = true; if ((_aoiContainer.AOIs.ElementAt(0) is GeometryOfDrawed) && (_aoiGCPContainer.AOIs.ElementAt(index) is GeometryOfDrawed)) { float distanceX = (_aoiGCPContainer.AOIs.ElementAt(index) as GeometryOfDrawed).RasterPoints[0].X - (_aoiContainer.AOIs.ElementAt(0) as GeometryOfDrawed).RasterPoints[0].X; float distanceY = (_aoiGCPContainer.AOIs.ElementAt(index) as GeometryOfDrawed).RasterPoints[0].Y - (_aoiContainer.AOIs.ElementAt(0) as GeometryOfDrawed).RasterPoints[0].Y; int length = (_aoiGCPContainer.AOIs.ElementAt(index) as GeometryOfDrawed).RasterPoints.Length; for (int i = 0; i < length; i++) { (_aoiContainer.AOIs.ElementAt(0) as GeometryOfDrawed).RasterPoints[i].X += distanceX; (_aoiContainer.AOIs.ElementAt(0) as GeometryOfDrawed).RasterPoints[i].Y += distanceY; } } UpdateDrawedAOI(); if (AOIIsChanged != null) { AOIIsChanged(this, null); } double drawedX, drawedY; if (canvasHost1.Canvas.CoordTransform.DataCoordType == enumDataCoordType.Geo) { canvasHost1.Canvas.CoordTransform.Geo2Prj(_drawedAOI.X, _drawedAOI.Y, out drawedX, out drawedY); } else { drawedX = _drawedAOI.X; drawedY = _drawedAOI.Y; } if ((drawedX > canvasHost1.Canvas.CurrentEnvelope.MinX) && (drawedX < canvasHost1.Canvas.CurrentEnvelope.MaxX) && (drawedY > canvasHost1.Canvas.CurrentEnvelope.MinY) && (drawedY < canvasHost1.Canvas.CurrentEnvelope.MaxY)) { } else { double dWidth = canvasHost1.Canvas.CurrentEnvelope.Width; double dHeight = canvasHost1.Canvas.CurrentEnvelope.Height; GeoDo.RSS.Core.DrawEngine.CoordEnvelope temp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(drawedX - dWidth / 2, drawedX + dWidth / 2, drawedY - dHeight / 2, drawedY + dHeight / 2); canvasHost1.Canvas.CurrentEnvelope = temp; } canvasHost1.Canvas.Refresh(enumRefreshType.All); } }
public CoordEnvelope Intersect(CoordEnvelope a) { if (a.MaxX < _minX || a.MinX > _maxX || a.MinY > _maxY || a.MinY < _minY) { return(null); } double minX = Math.Max(_minX, a.MinX); double minY = Math.Max(_minY, a.MinY); double maxX = Math.Min(_maxX, a.MaxX); double maxY = Math.Min(_maxY, a._maxY); return(new CoordEnvelope(minX, maxX, minY, maxY)); }
public void AddShpLayer(string strVecName) { _shpFileHostLayer.AddData(strVecName, null); CodeCell.AgileMap.Core.IMap map = _shpFileHostLayer.Map as CodeCell.AgileMap.Core.IMap; CodeCell.AgileMap.Core.FeatureLayer fetL = map.LayerContainer.Layers[0] as CodeCell.AgileMap.Core.FeatureLayer; _curShpLayerName = fetL.Name; SimpleMarkerSymbol sym = new SimpleMarkerSymbol(masSimpleMarkerStyle.Circle); sym.Size = new System.Drawing.Size(4, 4); fetL.Renderer = new SimpleFeatureRenderer(sym); CodeCell.AgileMap.Core.FeatureClass fetc = fetL.Class as CodeCell.AgileMap.Core.FeatureClass; CodeCell.AgileMap.Core.Envelope evp = fetc.FullEnvelope.Clone() as CodeCell.AgileMap.Core.Envelope; GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY); this.canvasHost1.Canvas.CurrentEnvelope = cvEvp; this.canvasHost1.Canvas.Refresh(enumRefreshType.All); }
public unsafe void Update(Color maskColor, Size rasterSize, CoordEnvelope coordEnvelope, bool isGeoCoord, int[] visibleRegion) { if (rasterSize.Width < _bitmapSize.Width) { _bitmapSize.Width = rasterSize.Width; } if (rasterSize.Height < _bitmapSize.Height) { _bitmapSize.Height = rasterSize.Height; } _maskColor = maskColor; _rasterSize = rasterSize; _coordEnvelope = coordEnvelope; _isGeoCoord = isGeoCoord; BuildBitmap(); float scaleX = _bitmap.Width / (float)_rasterSize.Width; float scaleY = _bitmap.Height / (float)_rasterSize.Height; float scale = Math.Min(scaleX, scaleY); CorrectCoordEnvelope(scale); BitmapData bdata = _bitmap.LockBits(new Rectangle(0, 0, _bitmap.Width, _bitmap.Height), ImageLockMode.ReadWrite, _bitmap.PixelFormat); try { IntPtr scan0 = bdata.Scan0; int stride = bdata.Stride; Reset(bdata); byte *ptr0 = (byte *)scan0.ToPointer(); byte *ptr = ptr0; int count = visibleRegion.Length; int r = 0, c = 0; int w = _rasterSize.Width; for (int i = 0; i < count; i++) { r = visibleRegion[i] / w; c = visibleRegion[i] % w; r = (int)(r * scale); c = (int)(c * scale); ptr = ptr0 + r * stride + c; *ptr = 1;//true value } } finally { _bitmap.UnlockBits(bdata); } }
private string CheckActiverFile() { ICanvasViewer canViewer = _session.SmartWindowManager.ActiveCanvasViewer; if (canViewer == null) { throw new Exception("未获得激活的数据窗口"); } IAOIProvider aoiProvider = canViewer.AOIProvider; if (aoiProvider == null) { throw new Exception("未从激活的数据窗口中获取感兴趣区域"); } GeoDo.RSS.Core.DrawEngine.CoordEnvelope geoEnvelope = aoiProvider.GetGeoRect(); if (geoEnvelope == null) { _hasAOI = false; } else { _hasAOI = true; } AOIItem[] aoiItems = aoiProvider.GetAOIItems(); if (aoiItems == null || aoiItems.Length == 0) { _hasBlock = false; } else { _hasBlock = true; } IRasterDrawing rd = canViewer.ActiveObject as IRasterDrawing; if (rd == null) { throw new Exception("未从激活的数据窗口中获取数据提供者"); } IRasterDataProvider rdp = rd.DataProvider; if (rdp == null) { throw new Exception("未从激活的数据窗口中获取数据提供者"); } return(rdp.fileName); }
public CoordEnvelope Intersect(CoordEnvelope a) { double minX = Math.Max(_minX, a.MinX); double minY = Math.Max(_minY, a.MinY); double maxX = Math.Min(_maxX, a.MaxX); double maxY = Math.Min(_maxY, a._maxY); if (minX > maxX) { return(null); } if (minY > maxY) { return(null); } return(new CoordEnvelope(minX, maxX, minY, maxY)); }
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(); } }
private void ImgFullMap_Click(object sender, EventArgs e) { if (canvasHost1.Canvas.PrimaryDrawObject is IRasterDrawing) { canvasHost1.Canvas.CurrentEnvelope = (canvasHost1.Canvas.PrimaryDrawObject as IRasterDrawing).OriginalEnvelope; } else { CodeCell.AgileMap.Core.IMap map = _vectorHostLayer.Map as CodeCell.AgileMap.Core.IMap; if ((map.LayerContainer.Layers != null) && (map.LayerContainer.Layers.Length > 0)) { CodeCell.AgileMap.Core.FeatureLayer fetL = map.LayerContainer.Layers[0] as CodeCell.AgileMap.Core.FeatureLayer; CodeCell.AgileMap.Core.FeatureClass fetc = fetL.Class as CodeCell.AgileMap.Core.FeatureClass; CodeCell.AgileMap.Core.Envelope evp = fetc.FullEnvelope.Clone() as CodeCell.AgileMap.Core.Envelope; GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY); canvasHost1.Canvas.CurrentEnvelope = cvEvp; } } //canvasHost1.Canvas.SetToFullEnvelope(); canvasHost1.Canvas.Refresh(enumRefreshType.All); }
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); }