Example #1
0
        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);
        }
Example #2
0
        public override bool Open(string fname, out bool memoryIsNotEnough)
        {
            memoryIsNotEnough = false;
            if (!MemoryIsEnoughChecker.MemoryIsEnouggWithMsgBoxForVector(fname))
            {
                memoryIsNotEnough = true;
                return(false);
            }
            bool isSpatial = IsCanAddToView(fname);

            //string mcd = TryGetMcd(fname);//不能在这里用mcd替换
            //if (!string.IsNullOrWhiteSpace(mcd))
            //    fname = mcd;

            if (_session.SmartWindowManager.ActiveViewer is ICanvasViewer && isSpatial)
            {
                AddVectorDataToCanvasViewer(fname, true);
            }
            else if (_session.SmartWindowManager.ActiveViewer is ILayoutViewer)
            {
                AddVectorDataToLayoutViewer(fname, true);
            }
            else
            {
                CanvasViewer cv = new CanvasViewer(OpenFileFactory.GetTextByFileName(fname), _session);
                _session.SmartWindowManager.DisplayWindow(cv);
                IVectorHostLayer host = cv.Canvas.LayerContainer.VectorHost as IVectorHostLayer;
                if (host != null)
                {
                    host.Set(cv.Canvas);
                    AddVectorDataToCanvasViewer(fname, false);
                    CodeCell.AgileMap.Core.IMap         map  = host.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;
                    CoordEnvelope cvEvp = new CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                    cv.Canvas.CurrentEnvelope = cvEvp;
                    cv.Canvas.Refresh(enumRefreshType.All);
                }
            }
            RefreshLayerManager();
            return(true);
        }
Example #3
0
 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);
 }
Example #4
0
        public ISpatialReference GetSpatialRef()
        {
            ISpatialReference spatialRef = null;

            if (canvasHost1.Canvas.PrimaryDrawObject != null)
            {
                spatialRef = SpatialReference.FromWkt(canvasHost1.Canvas.PrimaryDrawObject.SpatialRef, enumWKTSource.GDAL);
            }
            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;
                    if (fetc.SpatialReference != null)
                    {
                        spatialRef = SpatialReference.FromWkt(fetc.SpatialReference.ToWKTString(), enumWKTSource.GDAL);
                    }
                }
            }
            return(spatialRef);
        }
Example #5
0
 public int GetCoordType()
 {
     if (canvasHost1.Canvas.PrimaryDrawObject != null)
     {
         if (canvasHost1.Canvas.PrimaryDrawObject.IsRasterCoord)
         {
             return(0);
         }
         else if (canvasHost1.Canvas.CoordTransform.DataCoordType == enumDataCoordType.Geo)
         {
             return(1);
         }
         else
         {
             return(2);
         }
     }
     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.enumCoordinateType coordType = fetc.OriginalCoordinateType;
             if (coordType == 0)
             {
                 return(1);
             }
             else
             {
                 return(2);
             }
         }
     }
     return(1);
 }