Ejemplo n.º 1
0
        // 添加卫星模型图元
        private bool AddModel2Earth(Model3D model)
        {
            var layer = mapLogic.AddLayer(model.LayerName);

            if (layer == null)
            {
                Log4Allen.WriteLog(typeof(ArcGlobeBusiness), "创建卫星模型失败:添加图层失败。");
                return(false);
            }

            Kml kml = new Kml();

            kml.Placemark.Name = model.ModelName;
            KmlModel3d modelKml = new KmlModel3d();

            modelKml.ModelFilePath = model.ModelPath;
            modelKml.Description   = model.ModelName;
            modelKml.Position      = model.Coordinate;
            modelKml.Scale         = model.Scale;
            modelKml.Azimuth       = model.Azimuth;
            kml.Placemark.Graph    = modelKml;

            MapFrame.Core.Interface.IMFElement element = null;
            var ret = layer.AddElement(kml, out element);

            if (ret)
            {
                EventPublisher.PublishElementAddEvent(this, new ElementAddEventArgs(model.LayerName, model.ModelName));
            }

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建图元
        /// </summary>
        /// <param name="kml">模型的kml</param>
        /// <param name="layer">模型所在的图层</param>
        /// <returns></returns>
        public IMFElement CreateElement(Kml kml, ILayer layer)
        {
            KmlModel3d modelkml = kml.Placemark.Graph as KmlModel3d;

            if (modelkml == null)
            {
                return(null);
            }
            if (modelkml.Position == null)
            {
                return(null);
            }
            if (!File.Exists(modelkml.ModelFilePath))
            {
                return(null);
            }
            int index = -1;

            //图层
            IGlobeGraphicsLayer graphicLayer = layer as IGlobeGraphicsLayer;

            if (graphicLayer == null)
            {
                return(null);
            }

            //实例化图元
            Model3d_ArcGlobe modelElement = null;

            //添加图元
            this.Dosomething((Action) delegate()
            {
                IImport3DFile import3Dfile = null;
                if (!filePathDic.ContainsKey(modelkml.ModelFilePath))
                {
                    import3Dfile = new Import3DFileClass();
                    import3Dfile.CreateFromFile(modelkml.ModelFilePath);
                    filePathDic.Add(modelkml.ModelFilePath, import3Dfile);
                }
                else//模型已创建
                {
                    import3Dfile = filePathDic[modelkml.ModelFilePath];
                }

                modelElement = new Model3d_ArcGlobe(graphicLayer, modelkml, import3Dfile);

                //设置属性
                GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass();
                properties.Rasterize = modelkml.Rasterize;

                graphicLayer.AddElement(modelElement, properties, out index);
                modelElement.Index       = index;
                modelElement.ElementName = kml.Placemark.Name;
            }, true);

            return(modelElement);
        }
Ejemplo n.º 3
0
        // 绘制设备服务
        public void DrawDeviceRanage(DataTable dt)
        {
            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }

            foreach (DataRow row in dt.Rows)
            {
                DeviceData device = new DeviceData(row);

                IMFLayer layer = mapLogic.AddLayer("设备服务图层");
                if (layer == null)
                {
                    continue;
                }

                // 绘制设备(基站)
                Kml modelKml = new Kml();
                modelKml.Placemark.Name = device.DeviceNumber;

                KmlModel3d kml3d = new KmlModel3d();
                kml3d.ModelFilePath      = Application.StartupPath + "\\ModelFile\\station.3DS";
                kml3d.Description        = "";
                kml3d.Position           = new MapLngLat(device.Lng, device.Lat, device.Alt);
                kml3d.Scale              = 10000;
                kml3d.Azimuth            = 0;
                modelKml.Placemark.Graph = kml3d;
                layer.AddElement(modelKml);

                // 绘制服务范围(面)
                List <MapLngLat> pointListCover = new List <MapLngLat>();

                for (double tempAngle = -180; tempAngle <= 180; tempAngle = tempAngle + 4)
                {
                    var p = Utils.GetPointByDistanceAndAngle((float)device.RangeRadius, new MapLngLat(device.Lng, device.Lat, device.Alt), tempAngle);
                    if (p != null)
                    {
                        pointListCover.Add(new MapLngLat(p.Lng, p.Lat, 100000));
                    }
                }

                Kml polygonCover = new Kml();
                polygonCover.Placemark.Name  = device.DeviceNumber + "polygon";
                polygonCover.Placemark.Graph = new KmlPolygon()
                {
                    Description = device.DeviceNumber + "polygon", PositionList = pointListCover, OutLineColor = Color.Red, FillColor = Color.FromArgb(20, Color.Blue), OutLineSize = 2
                };
                layer.AddElement(polygonCover);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_graphcisLayer">图层</param>
        /// <param name="modelKml">模型kml</param>
        public Model3d_ArcGlobe(IGlobeGraphicsLayer _graphicLayer, KmlModel3d modelKml, IImport3DFile import3Dfile)
        {
            graphicLayer = _graphicLayer;

            this.ElementType = ElementTypeEnum.Model3D;   // 图元类型
            this.Description = modelKml.Description;      // 图元描述

            #region  符号

            IGeometry geometry = import3Dfile.Geometry;
            //将模型转为3D符号
            marker3DSymbol       = new Marker3DSymbolClass();
            marker3DSymbol.Shape = geometry;
            markerSymbol         = marker3DSymbol as IMarkerSymbol;
            markerSymbol.Size    = modelKml.Scale;
            markerSymbol.Angle   = modelKml.Azimuth;


            IRgbColor c = new RgbColorClass();
            c.Transparency     = modelKml.Color.A;
            c.Red              = modelKml.Color.R;
            c.Green            = modelKml.Color.G;
            c.Blue             = modelKml.Color.B;
            markerSymbol.Color = c;

            this.scale = modelKml.Scale;
            this.color = modelKml.Color;

            #endregion

            #region  位置

            IPoint p = new PointClass();
            p.PutCoords(modelKml.Position.Lng, modelKml.Position.Lat);
            p.Z = modelKml.Position.Alt;
            (p as IZAware).ZAware = true;
            #endregion
            lngLat = modelKml.Position;

            base.Geometry = p;                                  //指定位置
            base.Symbol   = markerSymbol;                       //指定符号

            flashTimer          = new Timer();
            flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed);
            flashTimer.Interval = 500;
        }