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
        // 添加波束图元
        private bool AddBeamElement(Beam beam, Model3D model)
        {
            var coverLayer = mapLogic.AddLayer(coverLayerName);
            var beamLayer  = mapLogic.AddLayer(beam.BeamLayerName);

            if (beamLayer == null)
            {
                return(false);
            }

            string           elementName      = beam.BeamName;
            List <MapLngLat> pointListPolygon = new List <MapLngLat>();
            List <MapLngLat> pointListCover   = new List <MapLngLat>();

            pointListPolygon.Add(model.Coordinate);
            //pointListCover.Add(new MapLngLat(beam.CenterPoint.Lng, beam.CenterPoint.Lat, 100000));

            for (double tempAngle = -180; tempAngle <= 180; tempAngle = tempAngle + beam.StepValue)
            {
                var p = Utils.GetPointByDistanceAndAngle(beam.Radius, beam.CenterPoint, tempAngle);
                if (p != null)
                {
                    pointListPolygon.Add(p);
                    pointListCover.Add(new MapLngLat(p.Lng, p.Lat, 100000));
                }
            }

            if (coverLayer != null)
            {
                // 创建覆盖图元
                Kml polygonCover = new Kml();
                polygonCover.Placemark.Name  = elementName + "cover";
                polygonCover.Placemark.Graph = new KmlPolygon()
                {
                    Description = elementName + "cover", PositionList = pointListCover, OutLineColor = Color.Red, FillColor = Color.FromArgb(20, Color.Blue), OutLineSize = 2
                };
                coverLayer.AddElement(polygonCover);

                // 线
                Kml kmlLine = new Kml();
                kmlLine.Placemark.Name = elementName + "cover_line";
                KmlLineString linekml = new KmlLineString();
                linekml.Color           = Color.Blue;
                linekml.Width           = 2;
                linekml.PositionList    = pointListCover;
                linekml.Rasterize       = false;
                kmlLine.Placemark.Graph = linekml;
                coverLayer.AddElement(kmlLine);
            }

            // 创建波束图元
            Kml polygonKml = new Kml();

            polygonKml.Placemark.Name  = elementName;
            polygonKml.Placemark.Graph = new KmlPolygon()
            {
                Description = elementName, PositionList = pointListPolygon, OutLineColor = Color.Red, FillColor = Color.FromArgb(beamAlpha, Color.YellowGreen), OutLineSize = 3
            };
            if (beamLayer.AddElement(polygonKml))
            {
                EventPublisher.PublishElementAddEvent(this, new ElementAddEventArgs(beam.BeamLayerName, elementName));
            }

            beamLayer.Refresh();   // 波束整体刷新

            return(true);
        }