Beispiel #1
0
        /// <summary>
        /// 加载WFS矢量地图服务
        /// </summary>
        /// <param name="WFSURl">获取范围URL</param>
        /// <param name="URl">服务URL</param>
        /// <param name="ServerName">服务名称</param>
        public void LoadWFS(ISGWorld61 sgworld, string WFSURl, string URl, string ServerName)
        {
            XmlDocument doc = new XmlDocument();

            doc = GetXMLFromUrl(WFSURl);

            XmlNodeList Childrennodes = doc.ChildNodes;
            XmlNode     Childrennode  = Childrennodes[1];
            XmlNode     FeatureType   = Childrennode.ChildNodes[3].FirstChild;

            string LayerName = FeatureType.FirstChild.InnerXml;
            string Connstr   = URl;

            Connstr = "Server=" + Connstr + ";User=admin;WFSVersion=1.0.0;LayerName=";
            // string Connstr = "Server=http://gisserver:8399/arcgis/services/line2/MapServer/WFSServer;User=admin;WFSVersion=1.0.0;LayerName=line2:WGSline1;TEPlugName=WFS;";
            Connstr = Connstr + "" + LayerName + "" + ";TEPlugName=WFS;";
            try
            {
                ILayer61 pILayer   = sgworld.Creator.CreateFeatureLayer(ServerName, Connstr, 0);
                string   wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
                pILayer.CoordinateSystem.WellKnownText = wellKtext;

                pILayer.Reproject = true;
                pILayer.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show("该服务地址不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void ReturnToOriginal(ILayer61 SlctdLyr)
        {
            IFeatureGroup61 SFeatureGroup = null;
            switch (SlctdLyr.GeometryType)
            {
                case LayerGeometryType.LGT_POINT:
                    SFeatureGroup = SlctdLyr.FeatureGroups.Point;
                    PointSymbol pPoint = this.CurrentSymbol.PrePointSymbol;
                    switch (pPoint.PointType)
                    {
                        #region
                        case "Circle":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_CIRCLE;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Radius X", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Radius X", pPoint.PointSizeClass);
                            if (pPoint.NumOfSidesClass == null)
                                SFeatureGroup.SetProperty("Number of sides", pPoint.NumOfSides);
                            else
                                SFeatureGroup.SetClassification("Number of sides", pPoint.NumOfSidesClass);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        case "Triangle":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_REGULAR_POLYGON;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Radius X", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Radius X", pPoint.PointSizeClass);
                            SFeatureGroup.SetProperty("Number of sides", 3);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        case "Rectangle":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_RECTANGLE;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Length", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Length", pPoint.PointSizeClass);
                            if (pPoint.PointSizeClass2 == null)
                                SFeatureGroup.SetProperty("Width", pPoint.PointSize2);
                            else
                                SFeatureGroup.SetClassification("Width", pPoint.PointSizeClass2);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        case "Pentagon":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_REGULAR_POLYGON;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Radius X", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Radius X", pPoint.PointSizeClass);
                            SFeatureGroup.SetProperty("Number of sides", 5);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        case "Hexagon":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_REGULAR_POLYGON;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Radius X", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Radius X", pPoint.PointSizeClass);
                            SFeatureGroup.SetProperty("Number of sides", 6);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        case "Arrow":
                            SFeatureGroup.DisplayAs = ObjectTypeCode.OT_ARROW;
                            if (pPoint.PointSizeClass == null)
                                SFeatureGroup.SetProperty("Length", pPoint.PointSize);
                            else
                                SFeatureGroup.SetClassification("Length", pPoint.PointSizeClass);
                            if (pPoint.PointFillcolorClass == null)
                            {
                                Color pColor = pPoint.PointFillcolor;
                                IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                SFeatureGroup.SetProperty("Fill Color", pColor);
                            }
                            else
                                SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                            if (pPoint.PointFillOpacityClass == null)
                                SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                            else
                                SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            break;
                        default:
                            //图像标签,文本标签及其他
                            #region
                            switch (SFeatureGroup.DisplayAs)
                            {
                                case ObjectTypeCode.OT_LABEL:
                                    if (pPoint.PointFillcolorClass == null)
                                    {
                                        Color pColor = pPoint.PointFillcolor;
                                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                        SFeatureGroup.SetProperty("Text Color", pColor);
                                    }
                                    else
                                        SFeatureGroup.SetClassification("Text Color", pPoint.PointFillcolorClass);
                                    break;
                                case ObjectTypeCode.OT_IMAGE_LABEL:
                                    if (pPoint.PointFillcolorClass == null)
                                    {
                                        Color pColor = pPoint.PointFillcolor;
                                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                        SFeatureGroup.SetProperty("Image Color", pColor);
                                    }
                                    else
                                        SFeatureGroup.SetClassification("Image Color", pPoint.PointFillcolorClass);
                                    if (pPoint.PointFillOpacityClass == null)
                                        SFeatureGroup.SetProperty("Image Opacity", pPoint.PointFillOpacity);
                                    else
                                        SFeatureGroup.SetClassification("Image Opacity", pPoint.PointFillOpacityClass);
                                    break;
                                case ObjectTypeCode.OT_MODEL:
                                    if (pPoint.PointFillcolorClass == null)
                                    {
                                        Color pColor = pPoint.PointFillcolor;
                                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                        SFeatureGroup.SetProperty("Tint Color", pColor);
                                    }
                                    else
                                        SFeatureGroup.SetClassification("Tint Color", pPoint.PointFillcolorClass);
                                    if (pPoint.PointFillOpacityClass == null)
                                        SFeatureGroup.SetProperty("Tint Opacity", pPoint.PointFillOpacity);
                                    else
                                        SFeatureGroup.SetClassification("Tint Opacity", pPoint.PointFillOpacityClass);
                                    break;
                                default:
                                    if (pPoint.PointFillcolorClass == null)
                                    {
                                        Color pColor = pPoint.PointFillcolor;
                                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                                        SFeatureGroup.SetProperty("Fill Color", pColor);
                                    }
                                    else
                                        SFeatureGroup.SetClassification("Fill Color", pPoint.PointFillcolorClass);
                                    if (pPoint.PointFillOpacityClass == null)
                                        SFeatureGroup.SetProperty("Fill Opacity", pPoint.PointFillOpacity);
                                    else
                                        SFeatureGroup.SetClassification("Fill Opacity", pPoint.PointFillOpacityClass);
                                    break;
                            }
                            SFeatureGroup.SetProperty("Altitude Method", pPoint.AltitMethod);
                            #endregion
                            break;
                        #endregion
                    }
                    break;
                case LayerGeometryType.LGT_POLYLINE:
                    SFeatureGroup = SlctdLyr.FeatureGroups.Polyline;
                    PolylineSymbol pPolyline = this.CurrentSymbol.PrePolylineSymbol;
                    #region
                    switch (pPolyline.PolylineType)
                    {
                        case "Solidline":
                            SFeatureGroup.SetProperty("Line Pattern", -1);
                            break;
                        case "Dottedline":
                            SFeatureGroup.SetProperty("Line Pattern", -1044481);
                            break;
                        case "Dottedline2":
                            SFeatureGroup.SetProperty("Line Pattern", -16776961);
                            break;
                        case "Dottedline3":
                            SFeatureGroup.SetProperty("Line Pattern", -267390961);
                            break;
                        case "Dottedline4":
                            SFeatureGroup.SetProperty("Line Pattern", -1010580541);
                            break;
                        case "Dottedline5":
                            SFeatureGroup.SetProperty("Line Pattern", -1717986919);
                            break;
                        case "Dottedline6":
                            SFeatureGroup.SetProperty("Line Pattern", -1431655766);
                            break;
                        case "Dottedline7":
                            SFeatureGroup.SetProperty("Line Pattern", -16678657);
                            break;
                        case "Dottedline8":
                            SFeatureGroup.SetProperty("Line Pattern", -15978241);
                            break;
                    }
                    if (pPolyline.PolylineWidthClass == null)
                        SFeatureGroup.SetProperty("Line Width", pPolyline.PolylineWidth);
                    else
                        SFeatureGroup.SetClassification("Line Width", pPolyline.PolylineWidthClass);

                    if (pPolyline.PolylineColorClass == null)
                    {
                        Color pColor = pPolyline.PolylineColor;
                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                        SFeatureGroup.SetProperty("Line Color", pColor);
                    }
                    else
                        SFeatureGroup.SetClassification("Line Color", pPolyline.PolylineColorClass);
                    if (pPolyline.PolylineOpacityClass == null)
                        SFeatureGroup.SetProperty("Line Opacity", pPolyline.PolylineOpacity);
                    else
                        SFeatureGroup.SetClassification("Line Opacity", pPolyline.PolylineOpacityClass);
                    if (pPolyline.PolylineBackColorClass == null)
                    {
                        Color pColor = pPolyline.PolylineBackColor;
                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                        SFeatureGroup.SetProperty("Line Back Color", pColor);
                    }
                    else
                        SFeatureGroup.SetClassification("Line Back Color", pPolyline.PolylineBackColorClass);
                    if (pPolyline.PolylineBackOpacityClass == null)
                        SFeatureGroup.SetProperty("Line Back Opacity", pPolyline.PolylineBackOpacity);
                    else
                        SFeatureGroup.SetClassification("Line Back Opacity", pPolyline.PolylineBackOpacityClass);
                    SFeatureGroup.SetProperty("Altitude Method", pPolyline.AltitMethod);
                    #endregion
                    break;
                case LayerGeometryType.LGT_POLYGON:
                    SFeatureGroup = SlctdLyr.FeatureGroups.Polygon;
                    PolygonSymbol pPolygon = this.CurrentSymbol.PrePolygonSymbol;
                    #region
                    if (pPolygon.PolygonFillcolorClass == null)
                    {
                        Color pColor = pPolygon.PolygonFillcolor;
                        IColor61 IFillcolor = Program.sgworld.Creator.CreateColor(pColor.R, pColor.G, pColor.B, pColor.A);
                        SFeatureGroup.SetProperty("Fill Color", pColor);

                    }
                    else
                        SFeatureGroup.SetClassification("Fill Color", pPolygon.PolygonFillcolorClass);
                    if (pPolygon.PolygonFillOpacityClass == null)
                        SFeatureGroup.SetProperty("Fill Opacity", pPolygon.PolygonFillOpacity);
                    else
                        SFeatureGroup.SetClassification("Fill Opacity", pPolygon.PolygonFillOpacityClass);
                    SFeatureGroup.SetProperty("Altitude Method", pPolygon.AltitMethod);
                    #endregion
                    break;
            }
        }
        private void InitialCurrentSymbol(ILayer61 CurrentLayer)
        {
            IFeatureGroup61 pFeatureGroup;
            switch (CurrentLayer.GeometryType)
            {
                case LayerGeometryType.LGT_POINT:

                    pFeatureGroup = CurrentLayer.FeatureGroups.Point;
                    PointSymbol pPoint = new PointSymbol();
                    #region
                    switch (pFeatureGroup.DisplayAs)
                    {
                        case ObjectTypeCode.OT_ARROW:
                            pPoint.PointType = "Arrow";
                            if (pFeatureGroup.IsClassified("Length"))
                                pPoint.PointSizeClass = pFeatureGroup.GetClassification("Length").ToString();
                            else
                            {
                                pPoint.PointSize = (double)pFeatureGroup.GetProperty("Length");
                                //pPoint.PointSizeClass = "NoClass";
                            }
                            if (pFeatureGroup.IsClassified("Fill Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                                pPoint.PointFillcolor = pColor;
                                //pPoint.PointFillcolorClass = "NoClass";
                            }
                            if (pFeatureGroup.IsClassified("Fill Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                            else
                            {
                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                                //pPoint.PointFillOpacityClass = "NoClass";
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_CIRCLE:
                            pPoint.PointType = "Circle";
                            if (pFeatureGroup.IsClassified("Radius X"))
                                pPoint.PointSizeClass = pFeatureGroup.GetClassification("Radius X").ToString();
                            else
                            {
                                pPoint.PointSize = (double)pFeatureGroup.GetProperty("Radius X");
                                //pPoint.PointSizeClass = "NoClass";
                            }
                            if (pFeatureGroup.IsClassified("Number of sides"))
                                pPoint.NumOfSidesClass = pFeatureGroup.GetClassification("Number of sides").ToString();
                            else
                            {
                                pPoint.NumOfSides = (int)pFeatureGroup.GetProperty("Number of sides");
                            }
                            if (pFeatureGroup.IsClassified("Fill Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Fill Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                            else
                            {
                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_RECTANGLE:
                            pPoint.PointType = "Rectangle";
                            if (pFeatureGroup.IsClassified("Length"))
                                pPoint.PointSizeClass = pFeatureGroup.GetClassification("Length").ToString();
                            else
                                pPoint.PointSize = (double)pFeatureGroup.GetProperty("Length");
                            if (pFeatureGroup.IsClassified("Width"))
                                pPoint.PointSizeClass2 = pFeatureGroup.GetClassification("Width").ToString();
                            else
                                pPoint.PointSize2 = (double)pFeatureGroup.GetProperty("Width");
                            if (pFeatureGroup.IsClassified("Fill Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Fill Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                            else
                            {
                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_REGULAR_POLYGON:
                            if (pFeatureGroup.IsClassified("Number of sides"))
                            {
                                pPoint.NumOfSidesClass = pFeatureGroup.GetClassification("Number of sides").ToString();
                                pPoint.PointType = "Other";
                            }
                            else
                            {
                                pPoint.NumOfSides = (int)pFeatureGroup.GetProperty("Number of sides");
                                switch (pPoint.NumOfSides)
                                {
                                    case 3:
                                        pPoint.PointType = "Triangle";
                                        break;
                                    case 5:
                                        pPoint.PointType = "Pentagon";
                                        break;
                                    case 6:
                                        pPoint.PointType = "Hexagon";
                                        break;
                                    default:
                                        pPoint.PointType = "Other";
                                        break;
                                }
                            }
                            if (pFeatureGroup.IsClassified("Radius X"))
                                pPoint.PointSizeClass = pFeatureGroup.GetClassification("Radius X").ToString();
                            else
                                pPoint.PointSize = (double)pFeatureGroup.GetProperty("Radius X");
                            if (pFeatureGroup.IsClassified("Fill Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Fill Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                            else
                            {
                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_LABEL:
                            pPoint.PointType = "Other";
                            if (pFeatureGroup.IsClassified("Text Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Text Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Text Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_IMAGE_LABEL:
                            pPoint.PointType = "Other";
                            if (pFeatureGroup.IsClassified("Image Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Image Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Image Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Image Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Image Opacity").ToString();
                            else
                            {
                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Image Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        case ObjectTypeCode.OT_MODEL:
                            pPoint.PointType = "Other";
                            if (pFeatureGroup.IsClassified("Tint Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Tint Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Tint Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Tint Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Tint Opacity").ToString();
                            else
                            {

                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Tint Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                        default:
                            pPoint.PointType = "Other";
                            if (pFeatureGroup.IsClassified("Fill Color"))
                                pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                            else
                            {
                                Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                                pPoint.PointFillcolor = pColor;
                            }
                            if (pFeatureGroup.IsClassified("Fill Opacity"))
                                pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                            else
                            {

                                pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                            }
                            pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                            break;
                    }
                    #endregion
                    this.CurrentSymbol.CurrentPointSymbol = pPoint;
                    this.CurrentSymbol.PrePointSymbol = pPoint;
                    break;
                case LayerGeometryType.LGT_POLYLINE:
                    pFeatureGroup = CurrentLayer.FeatureGroups.Polyline;
                    PolylineSymbol pPolyline = new PolylineSymbol();
                    #region
                    string LinePattern = pFeatureGroup.GetProperty("Line Pattern").ToString();
                    switch (LinePattern)
                    {
                        case "-1":
                            pPolyline.PolylineType = "Solidline";
                            break;
                        case "-1044481":
                            pPolyline.PolylineType = "Dottedline";
                            break;
                        case "-16776961":
                            pPolyline.PolylineType = "Dottedline2";
                            break;
                        case "-267390961":
                            pPolyline.PolylineType = "Dottedline3";
                            break;
                        case "-1010580541":
                            pPolyline.PolylineType = "Dottedline4";
                            break;
                        case "-1717986919":
                            pPolyline.PolylineType = "Dottedline5";
                            break;
                        case "-1431655766":
                            pPolyline.PolylineType = "Dottedline6";
                            break;
                        case "-16678657":
                            pPolyline.PolylineType = "Dottedline7";
                            break;
                        case "-15978241":
                            pPolyline.PolylineType = "Dottedline8";
                            break;
                    }
                    if (pFeatureGroup.IsClassified("Line Width"))
                        pPolyline.PolylineWidthClass = pFeatureGroup.GetClassification("Line Width").ToString();
                    else
                        pPolyline.PolylineWidth = (double)pFeatureGroup.GetProperty("Line Width");
                    if (pFeatureGroup.IsClassified("Line Color"))
                    {
                        pPolyline.PolylineColorClass = pFeatureGroup.GetClassification("Line Color").ToString();
                    }
                    else
                    {
                        Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Line Color"));
                        pPolyline.PolylineColor = pColor;
                    }
                    if (pFeatureGroup.IsClassified("Line Opacity"))
                        pPolyline.PolylineOpacityClass = pFeatureGroup.GetClassification("Line Opacity").ToString();
                    else
                    {
                        pPolyline.PolylineOpacity = (double)pFeatureGroup.GetProperty("Line Opacity");
                    }
                    if (pFeatureGroup.IsClassified("Line Back Color"))
                    {
                        pPolyline.PolylineBackColorClass = pFeatureGroup.GetClassification("Line Back Color").ToString();
                    }
                    else
                    {
                        Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Line Back Color"));
                        pPolyline.PolylineBackColor = pColor;
                    }
                    pPolyline.PolylineBackOpacity = (int)pFeatureGroup.GetProperty("Line Back Opacity");
                    if (pFeatureGroup.IsClassified("Line Back Opacity"))
                        pPolyline.PolylineBackOpacityClass = pFeatureGroup.GetClassification("Line Back Opacity").ToString();
                    else
                    {
                        pPolyline.PolylineBackOpacity = (int)pFeatureGroup.GetProperty("Line Back Opacity");
                    }
                    pPolyline.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                    #endregion
                    this.CurrentSymbol.CurrentPolylineSymbol = pPolyline;
                    this.CurrentSymbol.PrePolylineSymbol = pPolyline;
                    break;
                case LayerGeometryType.LGT_POLYGON:
                    pFeatureGroup = CurrentLayer.FeatureGroups.Polygon;
                    PolygonSymbol pPolygon = new PolygonSymbol();
                    #region
                    if (pFeatureGroup.IsClassified("Fill Color"))
                        pPolygon.PolygonFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString();
                    else
                    {
                        Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color"));
                        pPolygon.PolygonFillcolor = pColor;
                    }
                    if (pFeatureGroup.IsClassified("Fill Opacity"))
                        pPolygon.PolygonFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString();
                    else
                    {
                        pPolygon.PolygonFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity");
                    }
                    pPolygon.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method");
                    #endregion
                    this.CurrentSymbol.PrePolygonSymbol = pPolygon;
                    break;
                default:
                    break;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 加载shape文件添加模型
        /// 模型数据要与shape在同一路径下
        /// 2012-09-21 张航宇
        /// 添加Z修正 -56
        /// </summary>
        /// <param name="FileName"></param>
        ///
        public void LoadShapeAdd3model(ISGWorld61 sgworld, ITerraExplorer te, string FileName)
        {
            IInformationTree5 infoTree5 = te as IInformationTree5;

            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }
            if (File.Exists(FileName))
            {
                bool   PathType     = true;
                string PathFileName = "";
                string GroupName    = "模型组群" + System.Guid.NewGuid().ToString().Substring(0, 6);
                infoTree5.CreateGroup(GroupName, 0);
                int    GroupID         = sgworld.ProjectTree.FindItem(GroupName);
                string ModelFilename   = "";
                string UNModelFilename = "";
                string _XMLLayerInfo   = "<PlugData>" +

                                         "<PlugType>shape</PlugType>" +

                                         "<LayerName>" + FileName + "</LayerName>" +

                                         "<Server></Server>" +

                                         "<user></user>" +

                                         "<password></password>" +

                                         "<TableName></TableName>" +

                                         "<AttributesToLoad>*</AttributesToLoad >" +

                                         "<Feature>1</Feature >" +

                                         "<Annotation>1</Annotation>" +

                                         "<SaveItems>0</SaveItems>" +

                                         "<GroupKey>LAT-LONG</GroupKey>" +

                                         "<SysKey>LAT-LONG</SysKey>" +

                                         "<DatumKey>WGS84</DatumKey>" +

                                         "<UnitKey>METERS</UnitKey>" +

                                         "<UseZValue>0</UseZValue>" +

                                         "<AltitudeUnit>Meters</AltitudeUnit>" +

                                         "<Reproject>1</Reproject>" +

                                         "<StreamedLayer>0</StreamedLayer></PlugData >";
                ILayer5 iLyr = infoTree5.CreateLayer("3DModleGoto", _XMLLayerInfo, GroupID);//在根目录下装载shp数据
                iLyr.Load();
                IFeature61 sqfeature61 = null;
                int        itemid      = sgworld.ProjectTree.FindItem("" + GroupName + "\\3DModleGoto");

                ILayer61 m_layer61 = sgworld.ProjectTree.GetLayer(itemid);
                m_layer61.Streaming = false;

                IFeatureGroups61 pFeatureGroups61 = m_layer61.FeatureGroups;

                IFeatureGroup61 pFeatureGroup61 = pFeatureGroups61.Point as IFeatureGroup61;
                if (pFeatureGroup61 == null)
                {
                    MessageBox.Show("当前操作要求是正确的点图层");
                    return;
                }
                else
                {
                    if (pFeatureGroup61.Count == 0)
                    {
                        MessageBox.Show("图层为空!");
                        return;
                    }
                    else
                    {
                        sqfeature61 = pFeatureGroup61[0] as IFeature61;
                        IFeatureAttributes61 m_FeatureAttributes = sqfeature61.FeatureAttributes;
                        int      AttributesCount = m_FeatureAttributes.Count;
                        string[] FiledArry       = new string[AttributesCount];
                        for (int f = 0; f < AttributesCount; f++)
                        {
                            IFeatureAttribute61 m_FeatureAttribute = m_FeatureAttributes[f] as IFeatureAttribute61;
                            FiledArry[f] = m_FeatureAttribute.Name;
                        }
                        Skyline.Core.UI.FrmAddModelShape pFrmAddModelShape = new Skyline.Core.UI.FrmAddModelShape();
                        pFrmAddModelShape.GetFiledName = FiledArry;
                        pFrmAddModelShape.ShowDialog();
                        PathFileName = pFrmAddModelShape.Filed;
                        PathType     = pFrmAddModelShape.PathType;
                        pFrmAddModelShape.Dispose();

                        int m_FeatureCount     = pFeatureGroup61.Count;
                        int ImportFeatureCount = pFeatureGroup61.Count;
                        for (int i = 0; i < m_FeatureCount; i++)
                        {
                            sqfeature61 = pFeatureGroup61[i] as IFeature61;
                            IFeatureAttributes61     _FeatureAttributes = sqfeature61.FeatureAttributes;
                            TerraExplorerX.IGeometry _Geometry          = sqfeature61.GeometryZ;
                            TerraExplorerX.IPoint    pPoint             = _Geometry as TerraExplorerX.IPoint;
                            //IPosition61 TPosition61 = sgworld.Window.PixelToWorld(pPoint.X, pPoint.Y, WorldPointType.WPT_ALL).Position;
                            IPosition61         TPosition61       = sgworld.Creator.CreatePosition(pPoint.X, pPoint.Y, -56, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0);
                            IFeatureAttribute61 _FeatureAttribute = _FeatureAttributes.GetFeatureAttribute(PathFileName);
                            UNModelFilename = _FeatureAttribute.Value.ToString();
                            if (PathType)
                            {
                                ModelFilename = System.IO.Path.GetDirectoryName(FileName) + "\\" + UNModelFilename;
                            }
                            else
                            {
                                ModelFilename = UNModelFilename;
                            }

                            try
                            {
                                sgworld.Creator.CreateModel(TPosition61, ModelFilename, 1, ModelTypeCode.MT_NORMAL, GroupID, UNModelFilename);
                            }
                            catch
                            {
                                ImportFeatureCount--;
                                continue;
                            }
                        }
                        MessageBox.Show(ImportFeatureCount + "个模型加载成功," + (m_FeatureCount - ImportFeatureCount) + "个模型加载失败!");

                        /****20130227杨漾(添加文件有效性判断,分步判断图层有效性,增加加载统计情况提示)****/
                    }
                }
            }
        }