Пример #1
0
 public void Dispose()
 {
     if (_canvas != null)
     {
         if (_canvas.LayerContainer.VectorHost != null)
         {
             IMap map = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).Map as IMap;
             if (map != null && map.LayerContainer != null)
             {
                 map.LayerContainer.Remove(_layer);
             }
         }
         _canvas = null;
     }
     if (_mapRuntime != null)
     {
         _mapRuntime = null;
     }
     if (_datasource != null)
     {
         _datasource.Dispose();
         _datasource = null;
     }
     if (_labeldef != null)
     {
         _labeldef.Dispose();
         _labeldef = null;
     }
     if (_layer != null)
     {
         _layer.Dispose();
         _layer = null;
     }
     OID = 0;
 }
Пример #2
0
        private void TrySetAsyncDataArrivedNotify()
        {
            if (_provider == null)
            {
                return;
            }
            ICanvas c = _provider.Canvas;

            if (c == null)
            {
                return;
            }
            IVectorHostLayer host = c.LayerContainer.VectorHost;

            if (host == null)
            {
                return;
            }
            IMapRuntime runtime = host.MapRuntime as IMapRuntime;

            if (runtime == null)
            {
                return;
            }
            runtime.AsyncDataArrivedNotify = this;
        }
Пример #3
0
 public MapImageGeneratorDefault(IMapRuntime mapRuntime)
 {
     _mapRuntime = mapRuntime;
     _mapRuntime.ScaleBarArgs.Enabled = false;
     _coordTransfrom = (_mapRuntime as IFeatureRenderEnvironment).CoordinateTransform;
     BuildProjectionTransform();
     SetViewportToDefault();
 }
Пример #4
0
 private void TrySetSpatialRef(ICanvas canvas, IMapRuntime mapRuntime)
 {
     if (canvas.PrimaryDrawObject == null || canvas.PrimaryDrawObject.SpatialRef == null)
     {
         return;
     }
     mapRuntime.CanvasSpatialRef = canvas.PrimaryDrawObject.SpatialRef;
 }
Пример #5
0
 private void CreateMapRuntime()
 {
     _isDisposed = false;
     _renderArgs = new RenderArgs();
     _mapRuntime = new MapRuntime(this);
     _mapRuntime.ScaleBarArgs.Enabled   = false;
     _mapRuntime.AsyncDataArrivedNotify = this;
     _mapRuntime.CanvasSpatialRef       = _canvasSpatialRef;
 }
Пример #6
0
        private Feature[] SelectFeatures(CoordEnvelope evp, ICanvas canvas)
        {
            IVectorHostLayer hostLayer = canvas.LayerContainer.VectorHost as IVectorHostLayer;

            if (hostLayer == null || hostLayer.Map == null)
            {
                return(null);
            }
            IMap        map         = hostLayer.Map as IMap;
            IMapRuntime runtime     = hostLayer.MapRuntime as IMapRuntime;
            Envelope    aoiEnvelope = new Envelope(evp.MinX, evp.MinY, evp.MaxX, evp.MaxY);

            Feature[] features = runtime.HitTestByPrj(aoiEnvelope);
            return(features);
        }
Пример #7
0
 public static CodeCell.AgileMap.Core.IFeatureLayer CreateAndLoadVectorLayerForMicaps(ISmartSession session, ICanvas canvas, string fname, string dataTypeId, params object[] args)
 {
     if (string.IsNullOrEmpty(fname) || !File.Exists(fname))
     {
         return(null);
     }
     using (IVectorFeatureDataReader reader = MicapsDataReaderFactory.GetVectorFeatureDataReader(fname, dataTypeId))
     {
         if (reader == null)
         {
             return(null);
         }
         if (reader.Features != null)
         {
             MemoryDataSource mds      = new MemoryDataSource(fname, reader.ShapeType, enumCoordinateType.Geographic, reader.Envelope, reader.Fields);
             IFeatureClass    fetClass = new FeatureClass(mds);
             mds.AddFeatures(reader.Features);
             CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new FeatureLayer(fname, fetClass);
             TryApplyStyle(fetLayer, dataTypeId);
             IVectorHostLayer host = canvas.LayerContainer.VectorHost as IVectorHostLayer;
             if (host != null)
             {
                 host.Set(canvas);
                 IMapRuntime mapRuntime = host.MapRuntime as IMapRuntime;
                 if (mapRuntime != null)
                 {
                     IMap map = mapRuntime.Map as IMap;
                     if (map != null)
                     {
                         map.LayerContainer.Append(fetLayer);
                         FeatureLayer  fetL  = map.LayerContainer.Layers[0] as FeatureLayer;
                         FeatureClass  fetC  = fetL.Class as FeatureClass;
                         Envelope      evp   = fetC.FullEnvelope.Clone() as Envelope;
                         CoordEnvelope cvEvp = new CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                         canvas.CurrentEnvelope = cvEvp;
                         canvas.Refresh(enumRefreshType.All);
                     }
                 }
                 return(fetLayer);
             }
         }
     }
     return(null);
 }
Пример #8
0
        public SimpleVectorObjectHost(string name, ICanvas canvas, string[] fieldNames)
        {
            if (fieldNames != null)
            {
                _fldNames = fieldNames;
            }
            _canvas     = canvas;
            _mapRuntime = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).MapRuntime as IMapRuntime;
            _datasource = new CodeCell.AgileMap.Core.MemoryDataSource(name, enumShapeType.Polygon, _fldNames);
            CodeCell.AgileMap.Core.IFeatureClass fetClass = new CodeCell.AgileMap.Core.FeatureClass(_datasource);
            CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new CodeCell.AgileMap.Core.FeatureLayer(name, fetClass);
            _layer = fetLayer;
            IMap map = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).Map as IMap;

            if (map != null)
            {
                map.LayerContainer.Append(fetLayer);
            }
            SetLabel(fetLayer);
            SetRenderer(fetLayer);
        }
Пример #9
0
        public static Bitmap GetBitmapUseOriResolution(this ICanvas canvas)
        {
            IVectorHostLayer hostLayer = canvas.LayerContainer.VectorHost;

            if (hostLayer == null)
            {
                return(null);
            }
            IMapRuntime runtime = hostLayer.MapRuntime as IMapRuntime;

            if (runtime == null)
            {
                return(null);
            }
            IPrimaryDrawObject priObj = canvas.PrimaryDrawObject;
            Color oBackcolor          = runtime.Map.MapArguments.BackColor;

            try
            {
                Image bitmap = new Bitmap(priObj.Size.Width, priObj.Size.Height, PixelFormat.Format32bppArgb);
                runtime.Map.MapArguments.BackColor = Color.Transparent;
                Envelope imageGeoEnv         = PrjToGeoEnv(priObj, priObj.OriginalEnvelope.Clone());
                MapImageGeneratorDefault map = new MapImageGeneratorDefault(runtime);
                runtime.Host = map as CodeCell.AgileMap.Core.IMapRuntimeHost;
                map.GetMapImage(map.GeoEnvelope2Viewport(imageGeoEnv), new Size(priObj.Size.Width, priObj.Size.Height), ref bitmap);
                return(bitmap as Bitmap);
            }
            finally
            {
                runtime.Host = hostLayer as CodeCell.AgileMap.Core.IMapRuntimeHost;
                runtime.Map.MapArguments.BackColor = oBackcolor;
            }
            //IRenderLayer renderLayer = layer as IRenderLayer;//GeoGridLayer
            //if (filter(layer) && renderLayer.Visible)
            //{
            //    renderLayer.Render(this, drawArgs);
            //}
        }
Пример #10
0
        private Envelope ToGeoEnvelope(IMapRuntime runtime, Envelope currentExtent)
        {
            ICoordinateTransform coord = runtime as ICoordinateTransform;

            ShapePoint[] pts = currentExtent.Points;
            coord.PrjCoord2GeoCoord(pts);
            double minX = double.MaxValue;
            double minY = double.MaxValue;
            double maxX = double.MinValue;
            double maxY = double.MinValue;

            foreach (ShapePoint pt in pts)
            {
                if (pt.X < minX)
                {
                    minX = pt.X;
                }
                if (pt.Y < minY)
                {
                    minY = pt.Y;
                }
                if (pt.X > maxX)
                {
                    maxX = pt.X;
                }
                if (pt.Y > maxY)
                {
                    maxY = pt.Y;
                }
            }
            Envelope envelope = new Envelope();

            envelope.MinX = minX;
            envelope.MinY = minY;
            envelope.MaxX = maxX;
            envelope.MaxY = maxY;
            return(envelope);
        }
Пример #11
0
 public void Dispose()
 {
     try
     {
         IMapRuntime r = _environment as IMapRuntime;
         if (r != null && r.RuntimeExchanger != null)
         {
             r.RuntimeExchanger.RemoveLayer(this);
         }
         if (_class != null)
         {
             _class.Dispose();
         }
         if (_featureRender != null)
         {
             _featureRender.Dispose();
         }
     }
     finally
     {
         _disposed = true;
     }
 }
Пример #12
0
 public static CodeCell.AgileMap.Core.IFeatureLayer CreateAndLoadVectorLayerForMicaps(ISmartSession session, ICanvas canvas, string fname, Feature[] features)
 {
     if (string.IsNullOrEmpty(fname) || !File.Exists(fname))
     {
         return(null);
     }
     if (features != null)
     {
         MemoryDataSource mds      = new MemoryDataSource(fname, enumShapeType.Polyline);
         IFeatureClass    fetClass = new FeatureClass(mds);
         mds.AddFeatures(features);
         CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new FeatureLayer(fname, fetClass);
         //TryApplyStyle(fetLayer, dataTypeId);
         IVectorHostLayer host = canvas.LayerContainer.VectorHost as IVectorHostLayer;
         if (host != null)
         {
             host.Set(canvas);
             IMapRuntime mapRuntime = host.MapRuntime as IMapRuntime;
             if (mapRuntime != null)
             {
                 IMap map = mapRuntime.Map as IMap;
                 if (map != null)
                 {
                     map.LayerContainer.Append(fetLayer);
                     FeatureLayer fetL = map.LayerContainer.Layers[0] as FeatureLayer;
                     FeatureClass fetC = fetL.Class as FeatureClass;
                     Envelope     evp  = fetC.FullEnvelope.Clone() as Envelope;
                     GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                     canvas.CurrentEnvelope = cvEvp;
                     canvas.Refresh(enumRefreshType.All);
                 }
             }
             return(fetLayer);
         }
     }
     return(null);
 }
Пример #13
0
        public void Render(System.Drawing.Graphics g, QuickTransformArgs quickTransform)
        {
            Envelope currentExtent = _environment.ExtentOfProjectionCoord;

            if (!currentExtent.IsInteractived(_class.FullEnvelope))
            {
                return;
            }
            IMapRuntime        runtime   = _environment as IMapRuntime;
            IRasterDataSource  ds        = _class.DataSource as IRasterDataSource;
            enumCoordinateType coordType = ds.GetCoordinateType();
            Envelope           evp       = null;

            if (coordType == enumCoordinateType.Geographic)
            {
                evp = ToGeoEnvelope(runtime, currentExtent);
            }
            Bitmap bm = ds.Reader.Read(evp, runtime.Host.CanvasSize.Width, runtime.Host.CanvasSize.Height);

            if (bm != null)
            {
                g.DrawImage(bm, 0, 0);
            }
        }
Пример #14
0
 public void Init(IMapRuntime runtime)
 {
     _mapRuntime = runtime;
 }
Пример #15
0
 internal void InternalInit(IProjectionTransform projectionTransform, IFeatureRenderEnvironment environment)
 {
     _mapRuntime     = environment as IMapRuntime;
     _layerContainer = new LayerContainer(projectionTransform, environment);
 }
Пример #16
0
 private void BuildVectorMapRuntime()
 {
     _vectorMapRuntime = new MapRuntime(this);
     _coordTransfrom   = (_vectorMapRuntime as IFeatureRenderEnvironment).CoordinateTransform;
 }
Пример #17
0
 public void Init(IMapRuntime mapruntime)
 {
     _locationSrv       = mapruntime.LocationService;
     _locationIconLayer = mapruntime.LocationIconLayer;
     _maprefresh        = mapruntime.MapRefresh;
 }
Пример #18
0
 public LightLayerContainer(IMapRuntime runtime)
 {
     _runtime = runtime;
 }