public void OnItemClick(int index)
 {
     ESRI.ArcGIS.Carto.ILayer       layer = m_map.get_Layer(index);
     ESRI.ArcGIS.Geometry.IEnvelope env   = layer.AreaOfInterest;
     m_doc.ActiveView.Extent = env;
     m_doc.ActiveView.Refresh();
 }
Пример #2
0
        private ArcMapBrowse.BrowseGISTypes GetBrowseType(ref ESRI.ArcGIS.Carto.ILayer pLayer)
        {
            if (pLayer is IGeoFeatureLayer)
            {
                IGeoFeatureLayer pGFLayer = (IGeoFeatureLayer)pLayer;
                switch (pGFLayer.FeatureClass.ShapeType)
                {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                    return(ArcMapBrowse.BrowseGISTypes.Point);

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine:
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                    return(ArcMapBrowse.BrowseGISTypes.Line);

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                    return(ArcMapBrowse.BrowseGISTypes.Polygon);

                default:
                    return(ArcMapBrowse.BrowseGISTypes.Any);
                }
            }
            else if (pLayer is IRasterLayer)
            {
                return(ArcMapBrowse.BrowseGISTypes.Raster);
            }
            else if (pLayer is ITinLayer)
            {
                return(ArcMapBrowse.BrowseGISTypes.TIN);
            }
            else
            {
                return(ArcMapBrowse.BrowseGISTypes.Any);
            }
        }
Пример #3
0
 public ModifyShape(ILayer pCurrentLayer)
 {
     //
     // TODO: Define values for the public properties
     //
     m_CurrentLayer = pCurrentLayer;
 }
Пример #4
0
        /// <summary>
        /// 创建图元
        /// </summary>
        /// <param name="kml">图标的kml</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer)
        {
            KmlPoint pointKml = kml.Placemark.Graph as KmlPoint;

            if (pointKml == null)
            {
                return(null);
            }
            if (pointKml.Position == null)
            {
                return(null);
            }

            CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass;

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

            PointIco_ArcMap pictureElement = new PointIco_ArcMap(mapControl, pointKml, mapFactory);

            pictureElement.ElementType = ElementTypeEnum.Picture;
            graphicLayer.AddElement(pictureElement, 0);

            return(pictureElement);
        }
Пример #5
0
        /// <summary>
        /// Feature 必须有 OBJECTID  int类型字段
        /// </summary>
        /// <param name="features"></param>
        public MapTablePagerPage(IList <IFeature> features, ESRI.ArcGIS.Carto.ILayer pLayer)
        {
            this.pLayer = pLayer;
            featureDic  = new Dictionary <int, IFeature>();
            if (features != null)
            {
                try
                {
                    IFields fields = features[0].Fields;
                    for (int a = 0; a < fields.FieldCount; a++)
                    {
                        if (fields.Field[a].AliasName.StartsWith("OBJECTID"))
                        {
                            if (!fields.Field[a].Editable)
                            {
                                objectIndex = a;
                            }
                        }
                    }

                    foreach (IFeature feature in features)
                    {
                        featureDic.Add((int)feature.Value[objectIndex], feature);
                    }
                }
                catch
                {
                    MessageBox.Show("没有这个字段,请添加:且内容必须唯一:OBJECTID");
                }
            }
        }
Пример #6
0
        // ArcGIS Snippet Title:
        // Loop Through Layers of Specific UID
        //
        // Long Description:
        // Stub code to loop through layers in a map where a specific UID is supplied.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.Carto
        // ESRI.ArcGIS.System
        // System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView)
        // ArcGIS Engine
        // ArcGIS Server
        //
        // Applicable ArcGIS Product Versions:
        // 9.2
        // 9.3
        // 9.3.1
        // 10.0
        //
        // Required ArcGIS Extensions:
        // (NONE)
        //
        // Notes:
        // This snippet is intended to be inserted at the base level of a Class.
        // It is not intended to be nested within an existing Method.
        //

        ///<summary>Stub code to loop through layers in a map where a specific UID is supplied.</summary>
        ///
        ///<param name="map">An IMap interface in which the layers reside.</param>
        ///<param name="layerCLSID">A System.String that is the layer GUID type. For example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" is the IGeoFeatureLayer.</param>
        ///
        ///<remarks>In order of the code to be useful the user needs to write their own code to use the layer in the TODO section.
        ///
        /// The different layer GUID's and Interface's are:
        /// "{AD88322D-533D-4E36-A5C9-1B109AF7A346}" = IACFeatureLayer
        /// "{74E45211-DFE6-11D3-9FF7-00C04F6BC6A5}" = IACLayer
        /// "{495C0E2C-D51D-4ED4-9FC1-FA04AB93568D}" = IACImageLayer
        /// "{65BD02AC-1CAD-462A-A524-3F17E9D85432}" = IACAcetateLayer
        /// "{4AEDC069-B599-424B-A374-49602ABAD308}" = IAnnotationLayer
        /// "{DBCA59AC-6771-4408-8F48-C7D53389440C}" = IAnnotationSublayer
        /// "{E299ADBC-A5C3-11D2-9B10-00C04FA33299}" = ICadLayer
        /// "{7F1AB670-5CA9-44D1-B42D-12AA868FC757}" = ICadastralFabricLayer
        /// "{BA119BC4-939A-11D2-A2F4-080009B6F22B}" = ICompositeLayer
        /// "{9646BB82-9512-11D2-A2F6-080009B6F22B}" = ICompositeGraphicsLayer
        /// "{0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E}" = ICoverageAnnotationLayer
        /// "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}" = IDataLayer
        /// "{0737082E-958E-11D4-80ED-00C04F601565}" = IDimensionLayer
        /// "{48E56B3F-EC3A-11D2-9F5C-00C04F6BC6A5}" = IFDOGraphicsLayer
        /// "{40A9E885-5533-11D0-98BE-00805F7CED21}" = IFeatureLayer
        /// "{605BC37A-15E9-40A0-90FB-DE4CC376838C}" = IGdbRasterCatalogLayer
        /// "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer
        /// "{34B2EF81-F4AC-11D1-A245-080009B6F22B}" = IGraphicsLayer
        /// "{EDAD6644-1810-11D1-86AE-0000F8751720}" = IGroupLayer
        /// "{D090AA89-C2F1-11D3-9FEF-00C04F6BC6A5}" = IIMSSubLayer
        /// "{DC8505FF-D521-11D3-9FF4-00C04F6BC6A5}" = IIMAMapLayer
        /// "{34C20002-4D3C-11D0-92D8-00805F7C28B0}" = ILayer
        /// "{E9B56157-7EB7-4DB3-9958-AFBF3B5E1470}" = IMapServerLayer
        /// "{B059B902-5C7A-4287-982E-EF0BC77C6AAB}" = IMapServerSublayer
        /// "{82870538-E09E-42C0-9228-CBCB244B91BA}" = INetworkLayer
        /// "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}" = IRasterLayer
        /// "{AF9930F0-F61E-11D3-8D6C-00C04F5B87B2}" = IRasterCatalogLayer
        /// "{FCEFF094-8E6A-4972-9BB4-429C71B07289}" = ITemporaryLayer
        /// "{5A0F220D-614F-4C72-AFF2-7EA0BE2C8513}" = ITerrainLayer
        /// "{FE308F36-BDCA-11D1-A523-0000F8774F0F}" = ITinLayer
        /// "{FB6337E3-610A-4BC2-9142-760D954C22EB}" = ITopologyLayer
        /// "{005F592A-327B-44A4-AEEB-409D2F866F47}" = IWMSLayer
        /// "{D43D9A73-FF6C-4A19-B36A-D7ECBE61962A}" = IWMSGroupLayer
        /// "{8C19B114-1168-41A3-9E14-FC30CA5A4E9D}" = IWMSMapLayer
        ///</remarks>
        public void LoopThroughLayersOfSpecificUID(ESRI.ArcGIS.Carto.IMap map, System.String layerCLSID)
        {
            if (map == null || layerCLSID == null)
            {
                return;
            }
            ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
            uid.Value = layerCLSID; // Example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer
            try
            {
                ESRI.ArcGIS.Carto.IEnumLayer enumLayer = map.get_Layers(((ESRI.ArcGIS.esriSystem.UID)(uid)), true); // Explicit Cast
                enumLayer.Reset();
                ESRI.ArcGIS.Carto.ILayer layer = enumLayer.Next();
                cboLayers.Items.Clear();
                lstLayers.Clear();
                while (!(layer == null))
                {
                    IFeatureLayer featureLayer = (IFeatureLayer)layer;
                    if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        cboLayers.Items.Add(layer.Name);
                        lstLayers.Add(layer);
                    }
                    layer = enumLayer.Next();
                }
                if (cboLayers.Items.Count > 0)
                {
                    cboLayers.SelectedIndex = 0;
                }
            }
            catch (System.Exception ex)
            {
                //System.Windows.Forms.MessageBox.Show("No layers of type: " + uid.Value.ToString);
            }
        }
Пример #7
0
        public frmDEMSymbology(byte[] rendererValue, string rendererType, ESRI.ArcGIS.Controls.esriSymbologyStyleClass pStyleClass, List <ESRI.ArcGIS.Geodatabase.IField> pFields)
        {
            _Layer           = null;
            m_StyleClass     = pStyleClass;
            m_RendererObject = new Dictionary <string, IRasterRendererUI>();
            _RasterRenderer  = GetRasterRenderer(rendererValue, rendererType);
            m_FieldInfo      = new List <FieldInfo>();
            FieldInfo noneField = new FieldInfo();

            noneField.FieldName = "<NONE>";
            noneField.FieldDesc = "<NONE>";
            noneField.FieldType = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDate;
            m_FieldInfo.Add(noneField);

            if (pFields != null && pFields.Count != 0)
            {
                for (int i = 0; i < pFields.Count; i++)
                {
                    FieldInfo field = new FieldInfo();
                    //if ((pFields[i].VarType > 1 && pFields[i].VarType < 6 && pFields[i].Type != ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID)
                    //                || pFields[i].Type == ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString)
                    if ((int)pFields[i].Type < 5)
                    {
                        field.FieldName = pFields[i].Name;
                        field.FieldDesc = pFields[i].AliasName;
                        field.FieldType = pFields[i].Type;
                        m_FieldInfo.Add(field);
                    }
                }
            }

            InitializeUI();
            InitRendererUI();
        }
        public UploadToGoogleMapsEngine(ref GoogleMapsEngineToolsExtensionForArcGIS ext)
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("OAuth2AuthForm initializing.");

            // initialize the local extension object
            log.Debug("Initializing the reference to the Extension.");
            this.ext = ext;

            // initialize form components
            InitializeComponent();

            // establish a reference to the running ArcMap instance
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

            // retrieve a reference to the selected layer
            ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

            // determine if the selected layer is valid
            if (!Tools.ToolsCommand_UploadToGoogleMapsEngine.isLayerValid(selectedLayer))
            {
                // Handle invalid layer
                System.Windows.Forms.MessageBox.Show("The selected layer does not meet the minimum requirements or is invalid.");

                // close the dialog
                this.Close();
            }
            else
            {
                this.isLayerValidated = true;
            }
        }
Пример #9
0
 public ModifyShape(ILayer pCurrentLayer)
 {
     //
     // TODO: Define values for the public properties
     //
     m_CurrentLayer = pCurrentLayer;
 }
Пример #10
0
        /// <summary>
        /// 创建图元
        /// </summary>
        /// <param name="kml">图标的kml</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public Core.Interface.IElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer)
        {
            KmlPicture pictureKml = kml.Placemark.Graph as KmlPicture;

            if (pictureKml == null)
            {
                return(null);
            }
            if (pictureKml.Position == null)
            {
                return(null);
            }

            CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass;

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

            Picture_ArcMap pictureElement = new Picture_ArcMap(graphicLayer, pictureKml);

            pictureElement.ElementType = ElementTypeEnum.Picture;
            graphicLayer.AddElement(pictureElement, 0);
            return(pictureElement);
        }
Пример #11
0
        private void UploadToGoogleMapsEngine_Load(object sender, EventArgs e)
        {
            // establish a reference to the running ArcMap instance
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

            // retrieve a reference to the selected layer
            ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

            // get the data layer of this feature layer
            ESRI.ArcGIS.Carto.IDataLayer2 dataLayer
                = (ESRI.ArcGIS.Carto.IDataLayer2)selectedLayer;
            ESRI.ArcGIS.Geodatabase.IDatasetName datasetName
                = (ESRI.ArcGIS.Geodatabase.IDatasetName)dataLayer.DataSourceName;

            // add a script manager to the browser
            // in order to capture select events
            webBrowser.ObjectForScripting = new BrowerScriptManager(this);

            // fetch the upload_dialog_html resource
            log.Debug("fetch the upload_dialog_html resource");
            string uploadhtml = Properties.Resources.upload_dialog_html;

            // populate the source dataset information
            uploadhtml = uploadhtml.Replace("{sourcename}", datasetName.Name);
            uploadhtml = uploadhtml.Replace("{sourceworkspace}", datasetName.WorkspaceName.PathName);

            // configure raster/vector specific information
            if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer)
            {
                // cast the selected layer into a feature layer
                ESRI.ArcGIS.Carto.IFeatureLayer featureLayer
                    = (ESRI.ArcGIS.Carto.IFeatureLayer)selectedLayer;

                // set the source vector type
                uploadhtml = uploadhtml.Replace("{sourcetype}", featureLayer.DataSourceType);

                // set the variable upload type to vector
                uploadType = "vector";
            }
            else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer)
            {
                // cast the selected layer into a raster layer
                ESRI.ArcGIS.Carto.IRasterLayer rasterLayer
                    = (ESRI.ArcGIS.Carto.IRasterLayer)selectedLayer;

                // set the source raster type
                uploadhtml = uploadhtml.Replace("{sourcetype}", "Raster: "
                                                + rasterLayer.RowCount + " rows, " + rasterLayer.ColumnCount + " columns, "
                                                + rasterLayer.BandCount + " bands");

                // set the variable upload type to raster
                uploadType = "raster";
            }

            // set the upload html
            log.Debug("Setting the HTML to the web browser on the dialog.");
            this.webBrowser.DocumentText = uploadhtml;
        }
Пример #12
0
        private void TOCContextMenuItem_RemoveLayer(object sender, EventArgs e)
        {
            ESRI.ArcGIS.Controls.esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone;
            ESRI.ArcGIS.Carto.ILayer    pLayer            = null;
            ESRI.ArcGIS.Carto.IBasicMap pMap = null;
            object pIndex = null;
            object pOther = null;

            TOCControl.GetSelectedItem(ref pItem, ref pMap, ref pLayer, ref pIndex, ref pOther);
            if (pLayer != null)
            {
                MainMap.Map.DeleteLayer(pLayer);
            }
        }
Пример #13
0
        public frmDEMSymbology(ILayer pLayer)
        {
            InitializeComponent();
            _Layer = pLayer;
            if (_Layer == null)
            {
                return;
            }
            m_RendererObject = new Dictionary <string, IRasterRendererUI>();
            _RasterRenderer  = GetRasterRenderer(pLayer);
            m_FieldInfo      = null;

            InitializeUI();
            InitRendererUI();
        }
Пример #14
0
        /// <summary>
        /// 从图层获取符号方案
        /// </summary>
        /// <param name="pLayer"></param>
        /// <returns></returns>
        private ESRI.ArcGIS.Carto.IRasterRenderer  GetRasterRenderer(ESRI.ArcGIS.Carto.ILayer pLayer)
        {
            IRasterRenderer pRasterRender = null;

            if (pLayer is IRasterLayer)
            {
                IRasterLayer pRasterLayer = pLayer as IRasterLayer;
                pRasterRender = pRasterLayer.Renderer;
            }
            else if (pLayer is IRasterCatalogLayer)
            {
                IRasterCatalogLayer pRasterCatalogLayer = pLayer as IRasterCatalogLayer;
                pRasterRender = pRasterCatalogLayer.Renderer;
            }
            return(pRasterRender);
        }
Пример #15
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="element">要移除的图元</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public bool RemoveElement(Core.Interface.IElement element, ESRI.ArcGIS.Carto.ILayer layer)
        {
            if (element == null)
            {
                return(true);
            }
            CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass;

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

            PictureElementClass pictureElement = element as PictureElementClass;

            graphicLayer.DeleteElement(pictureElement);
            return(true);
        }
Пример #16
0
        /// <summary>
        /// Updates the treeview based on the given IMap document
        /// </summary>
        /// <param name="map">The Map for which to populate the TreeView</param>
        public void UpdateTreeView(IMap map)
        {
            this.BeginUpdate();
            this.Nodes.Clear();
            for (int i = 0; i < map.LayerCount; ++i)
            {
                TreeNode root = new TreeNode();
                ESRI.ArcGIS.Carto.ILayer l = map.get_Layer(i);

                PopulateTree(l, root);

                Nodes.Add(root.FirstNode);

                root.FirstNode.Expand();

                this.Indent = 2;
                //this.CheckBoxes = true;

                CheckTree(root);
            }
            this.EndUpdate();
        }
Пример #17
0
        /// <summary>
        /// 根据map获得feaurelayer的workspace
        /// </summary>
        /// <param name="pMap"></param>
        /// <returns></returns>
        public static IWorkspace GetCurrentWorkspace(IMap pMap)
        {
            if (pMap == null)
            {
                return(null);
            }

            IUID uid = new UIDClass();

            uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}";//uid代表featurelayer

            IEnumLayer enumLayer = pMap.get_Layers(((UID)(uid)), true);

            enumLayer.Reset();
            ESRI.ArcGIS.Carto.ILayer layer = enumLayer.Next();
            if (!(layer == null))
            {
                IFeatureLayer featureLayer = (IFeatureLayer)layer;
                return(GetCurrentWorkspace(featureLayer));
            }
            return(null);
        }
Пример #18
0
        //创建饼状专题图
        public static void CreatePieTheme(System.Web.UI.Page page, int nLayerID, string[] fields)
        {
            if (page == null)
            {
                return;
            }
            // 得到地图服务下的ArcObjects map对象
            ESRI.ArcGIS.Server.IServerContext pServerContext = GetServerContext(page);

            ESRI.ArcGIS.Carto.IMapServer         mapServer        = (ESRI.ArcGIS.Carto.IMapServer)pServerContext.ServerObject;
            ESRI.ArcGIS.Carto.IMapServerObjects2 mapServerObjects = (ESRI.ArcGIS.Carto.IMapServerObjects2)mapServer;
            string mapName = mapServer.DefaultMapName;

            ESRI.ArcGIS.Carto.IMap aoMap = mapServerObjects.get_Map(mapName);

            ESRI.ArcGIS.Carto.ILayer           pLayer    = aoMap.get_Layer(nLayerID);//得到图层
            ESRI.ArcGIS.Carto.IGeoFeatureLayer pGeoLayer = pLayer as IGeoFeatureLayer;

            //设置专题图的属性列表
            ESRI.ArcGIS.Carto.IChartRenderer  pCharRenderer = pServerContext.CreateObject("esriCarto.ChartRenderer") as IChartRenderer;
            ESRI.ArcGIS.Carto.IRendererFields pRenderFields = pCharRenderer as IRendererFields;
            foreach (string var in fields)
            {
                pRenderFields.AddField(var, var);
            }

            //实例化图表对象并取得元素指定属性的最大值
            ESRI.ArcGIS.Display.IPieChartSymbol pPieSym  = pServerContext.CreateObject("esriDisplay.PieChartSymbol") as ESRI.ArcGIS.Display.IPieChartSymbol;
            ESRI.ArcGIS.Display.IChartSymbol    pCharSym = pPieSym as ESRI.ArcGIS.Display.IChartSymbol;
            pPieSym.Clockwise  = true;
            pPieSym.UseOutline = true;

            pCharSym.MaxValue = GetStaMaxMin(fields, pGeoLayer)[0];

            //设置饼图外围线
            ISimpleLineSymbol pOutLine = pServerContext.CreateObject("esriDisplay.SimpleLineSymbol") as ISimpleLineSymbol;

            pOutLine.Color = GetRGB(255, 0, 128, pServerContext);
            pOutLine.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
            pOutLine.Width = 1;

            pPieSym.Outline = pOutLine;
            IMarkerSymbol pMarkSym = pPieSym as IMarkerSymbol;

            pMarkSym.Size = 5;


            //设置饼状图填充效果
            ESRI.ArcGIS.Display.ISymbolArray pSymArr = pPieSym as ISymbolArray;
            ISimpleFillSymbol pSimFillSym            = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as ESRI.ArcGIS.Display.SimpleFillSymbol;

            pSimFillSym.Color   = GetRGB(128, 128, 128, pServerContext);
            pSimFillSym.Outline = pOutLine;

            Random randColor = new Random();

            for (int i = 0; i < fields.Length; i++)
            {
                IFillSymbol pFillSym = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as IFillSymbol;
                pFillSym.Color = GetRGB(randColor.Next(255), randColor.Next(255), randColor.Next(255), pServerContext);
                pSymArr.AddSymbol((ISymbol)pFillSym);
            }

            //设置地图图层背景
            pSimFillSym              = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as ESRI.ArcGIS.Display.SimpleFillSymbol;
            pSimFillSym.Color        = GetRGB(255, 128, 255, pServerContext);
            pCharRenderer.BaseSymbol = pSimFillSym as ISymbol;


            //设置饼状图表属性
            IPieChartRenderer pPieChartRenderer = pCharRenderer as IPieChartRenderer;

            pPieChartRenderer.MinValue             = 0.1;
            pPieChartRenderer.MinSize              = 1;
            pPieChartRenderer.FlanneryCompensation = false;
            pPieChartRenderer.ProportionalBySum    = true;
            pPieChartRenderer.ProportionalField    = fields[0];
            pCharRenderer.ChartSymbol              = pPieSym as IChartSymbol;
            pCharRenderer.Label = "面积";

            //应用饼状专题到指定图层
            pCharRenderer.UseOverposter = false;
            pCharRenderer.CreateLegend();
            pGeoLayer.Renderer = pCharRenderer as IFeatureRenderer;

            //刷新地图显示图表及图例
            mapServerObjects.RefreshServerObjects();
            // Map1.RefreshResource("MapResourceItem0");
            pServerContext.ReleaseContext();
        }
        protected void uploadButtonClicked(String projectId, String name, String description, String tags, String aclName, String attribution)
        {
            try
            {
                // create a new Processing Dialog
                Dialogs.Processing.ProgressDialog processingDialog = new Processing.ProgressDialog();

                // check to see if the layer is valid
                // and destination is configured correctly
                if (isLayerValidated &&
                    projectId != null && projectId.Length > 0 &&
                    name != null && name.Length > 0 &&
                    aclName != null && aclName.Length > 0)
                {
                    // show the processing dialog
                    processingDialog.Show();

                    // create a reference to the Google Maps Engine API
                    MapsEngine.API.GoogleMapsEngineAPI api = new MapsEngine.API.GoogleMapsEngineAPI(ref log);

                    // establish a reference to the running ArcMap instance
                    ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

                    // retrieve a reference to the selected layer
                    ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

                    // create a temporary working directory
                    System.IO.DirectoryInfo tempDir
                        = System.IO.Directory.CreateDirectory(ext.getLocalWorkspaceDirectory() + "\\" + System.Guid.NewGuid());

                    // determine what type of layer is selected
                    if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer)
                    {
                        // export a copy of the feature class to a "uploadable" Shapefile
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (feature class) for data upload.");
                        ExportLayerToShapefile(tempDir.FullName, selectedLayer.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createVectorTableAssetForUploading(ext.getToken(),
                                                                     MapsEngine.API.GoogleMapsEngineAPI.AssetType.table,
                                                                     projectId,
                                                                     name,
                                                                     aclName,
                                                                     filesNames,
                                                                     description,
                                                                     tags.Split(",".ToCharArray()).ToList <String>(),
                                                                     "UTF-8");

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }
                    else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer)
                    {
                        // export a copy of the raster to a format that can be uploaded
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (raster) for data upload.");
                        ExportLayerToUploadableRaster(tempDir.FullName, tempDir.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createRasterAssetForUploading(ext.getToken(),
                                                                projectId,
                                                                name,
                                                                aclName,
                                                                attribution, // attribution
                                                                filesNames,
                                                                description,
                                                                tags.Split(",".ToCharArray()).ToList <String>());

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }

                    // Delete temporary directory and containing files
                    // TODO: Remove temporary files, but can't remove them at the moment because they are in use by
                    // the ArcMap seesion.
                    //tempDir.Delete(true);

                    // close the processing dialog
                    ext.publishRaiseDownloadProgressChangeEvent(true, "Finished");
                    processingDialog.Close();
                }
                else
                {
                    // display an error dialog to the user
                    System.Windows.Forms.MessageBox.Show("The selected layer is invalid or the destination configuration has not been properly set.");
                }
            }
            catch (System.Exception ex)
            {
                // Ops.
                System.Windows.Forms.MessageBox.Show("An error occured. " + ex.Message);
            }

            // close the dialog
            this.Close();
        }
Пример #20
0
        //创建柱状专题图
        public void CreateBarRenderer(int layerID, string[] fields)
        {
            // 得到地图服务下的ArcObjects map对象
            ESRI.ArcGIS.Server.IServerContext pServerContext = GetServerContext();

            ESRI.ArcGIS.Carto.IMapServer         mapServer        = (ESRI.ArcGIS.Carto.IMapServer)pServerContext.ServerObject;
            ESRI.ArcGIS.Carto.IMapServerObjects2 mapServerObjects = (ESRI.ArcGIS.Carto.IMapServerObjects2)mapServer;
            string mapName = mapServer.DefaultMapName;

            ESRI.ArcGIS.Carto.IMap aoMap = mapServerObjects.get_Map(mapName);

            ESRI.ArcGIS.Carto.ILayer           pLayer    = aoMap.get_Layer(layerID);//得到图层
            ESRI.ArcGIS.Carto.IGeoFeatureLayer pGeoLayer = pLayer as IGeoFeatureLayer;
            //设置专题图元素的属性名称列表
            IChartRenderer  pChartRender  = pServerContext.CreateObject("esriCarto.ChartRenderer") as IChartRenderer;
            IRendererFields pRenderFields = pChartRender as IRendererFields;

            foreach (string var in fields)
            {
                pRenderFields.AddField(var, var);
            }

            //实例化图表对象并取得元素指定属性的最大值
            IBarChartSymbol pBarChartSymbol = pServerContext.CreateObject("esriDisplay.BarChartSymbol") as IBarChartSymbol;
            IChartSymbol    pChartSymbol    = pBarChartSymbol as IChartSymbol;

            pChartSymbol.MaxValue = GetStaMaxMin(fields, pGeoLayer)[0];
            pBarChartSymbol.Width = 8;
            IMarkerSymbol pMarkerSymbol = pBarChartSymbol as IMarkerSymbol;

            pMarkerSymbol.Size = 50;

            //设置柱状图每列填充效果
            ISymbolArray pSymbolArray = pBarChartSymbol as ISymbolArray;
            Random       ranColor     = new Random();

            for (int i = 0; i < fields.Length; i++)
            {
                IFillSymbol pFillSymbol = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as IFillSymbol;
                pFillSymbol.Color = GetRGB(ranColor.Next(255), ranColor.Next(255), ranColor.Next(255), pServerContext);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            }

            //设置地图图层背景
            ESRI.ArcGIS.Display.ISimpleFillSymbol pFSymbol = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as ESRI.ArcGIS.Display.SimpleFillSymbol;
            pFSymbol.Color          = GetRGB(239, 228, 249, pServerContext);
            pChartRender.BaseSymbol = pFSymbol as ISymbol;

            //应用柱状专题到指定图层
            pChartRender.ChartSymbol   = pBarChartSymbol as IChartSymbol;
            pChartRender.Label         = "Test";
            pChartRender.UseOverposter = false;
            pChartRender.CreateLegend();
            pGeoLayer.Renderer = pChartRender as IFeatureRenderer;

            //刷新地图显示图表及图例
            mapServerObjects.RefreshServerObjects();
            Map1.RefreshResource("MapResourceItem0");
            Toc1.BuddyControl = "Map1";
            //Toc1.Refresh();
            Map1.Refresh();
            pServerContext.ReleaseContext();
        }
Пример #21
0
        /// <summary>
        /// 点重复数字化检查主函数
        /// </summary>
        /// <param name="_AppHk"></param>
        private void ExcutePointDigitalDuplicateCheck(object Hook)
        {
            Plugin.Application.IAppGISRef _AppHk = Hook as Plugin.Application.IAppGISRef;

            #region 取得进度条对象

            //取得进度条对象

            Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef;
            #endregion
            System.Data.DataTable Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示
            Datatable.Columns.Add("重复点", typeof(string));                  //创建一列

            ///如果检查结果提示内有内容就清除
            ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid();
            ClearGrid.Operate(pAppForm, _AppHk);
            //判断图层个数是否为0
            if (_AppHk.MapControl.LayerCount == 0)
            {
                return;
            }
            SetCheckState.CheckShowTips(pAppForm, "重复点检查开始.....");
            int Count = _AppHk.MapControl.LayerCount;
            for (int i = 0; i < Count; i++)
            {
                ILayer temp_layer = _AppHk.MapControl.get_Layer(i);
                //判别是不是组,如果是,就从组中取一个层
                if (temp_layer is IGroupLayer && temp_layer.Name == SetCheckState.CheckDataBaseName)
                {
                    ICompositeLayer grouplayer = temp_layer as ICompositeLayer; //把组图层转成组合图层
                    int             C_count    = grouplayer.Count;              //组合图层数
                    if (C_count == 0)
                    {
                        return;
                    }
                    #region 遍历组下面的重复点
                    ArrayList LayerList = new ArrayList();//存要素类
                    //将所有可用的图层存入动态数组
                    for (int c = 0; c < C_count; c++)
                    {
                        //图层转换
                        pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { C_count, 0, 1, c, pAppForm }); //给进度条传需要的值
                        int num = c + 1;                                                                                          //由于层的索引是从0开始的,所以得加1
                        ESRI.ArcGIS.Carto.ILayer        pLayer     = grouplayer.get_Layer(c);
                        ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as ESRI.ArcGIS.Carto.IFeatureLayer;
                        //如果图层不为空,就转成对应的要素类
                        if (pFeatLayer == null)
                        {
                            continue;
                        }
                        IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;
                        if (pFeatureClass == null)
                        {
                            continue;
                        }
                        //只取点层
                        if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
                        {
                            LayerList.Add(pFeatureClass);//加入动态数组中
                        }
                    }
                    SetCheckState.TreeIni_Fun(LayerList, _AppHk);//初始化树
                    //重复点检查操作
                    for (int L = 0; L < LayerList.Count; L++)
                    {
                        IFeatureClass pFeatureClass = LayerList[L] as IFeatureClass;
                        RePoint(pFeatureClass, pAppForm, Datatable, L);//开始遍历重复点
                        if (L == LayerList.Count - 1)
                        {
                            SetCheckState.CheckShowTips(pAppForm, "重复点检查马上完成,请稍后...");
                        }
                    }
                    #endregion
                    break;
                }
            }
            pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //是否显示进度条,加载让它显示
            SetCheckState.CheckShowTips(pAppForm, "重复点检查完成!");
            _AppHk.CurrentThread = null;                                                                     //线程使用完置空

            pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk });
            SetCheckState.Message(pAppForm, "提示", "重复点检查完成!");
            //选中检查出错列表
            ClearGrid.CheckDataGridShow(pAppForm, _AppHk);
        }
Пример #22
0
        private void button_Import_Click(object sender, System.EventArgs e)
        {
            // point to the first selected feature:
            ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass();

            // Set properties for AGImportPathOptions
            AGImportPathOptionsCls.BasicMap        = (ESRI.ArcGIS.Carto.IBasicMap)globe;              // Explicit Cast
            AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast
            AGImportPathOptionsCls.AnimationType   = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass();
            AGImportPathOptionsCls.AnimatedObject  = globe.GlobeDisplay.ActiveViewer.Camera;

            if (this.radioButton_flyby.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget;
                AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative);
                AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0);
            }
            else if (this.radioButton_currentTarget.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver;
            }
            else if (this.radioButton_currentObserver.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget;
            }

            double pAzimuth, pInclination, pRollVal;

            AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal);

            AGImportPathOptionsCls.LookaheadFactor   = this.trackBarSimplificationFactor.Value / 100;
            AGImportPathOptionsCls.TrackName         = this.textBox_TrackName.Text;
            AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState);
            AGImportPathOptionsCls.VerticalOffset    = Convert.ToDouble(this.textBox_VertOffset.Text);
            AGImportPathOptionsCls.ReversePath       = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState);

            // get the layer selected in the combo box
            if (this.comboBoxLayers.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a layer before you proceed");
            }
            else
            {
                //set the layer based on the item selected in the combo box
                ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex);                  // Explicit Cast

                // Get the line feature selected in the layer
                ESRI.ArcGIS.Carto.IFeatureLayer       featureLayer     = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;       // Explicit Cast
                ESRI.ArcGIS.Carto.IFeatureSelection   featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer;   // Explicit Cast
                ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet     = featureSelection.SelectionSet;
                ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass     = featureLayer.FeatureClass;
                string shapeField = featureClass.ShapeFieldName;
                ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();

                IScene scene = globe.GlobeDisplay.Scene;

                ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference;
                spatialFilterCls.GeometryField = shapeField;
                spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference);
                ESRI.ArcGIS.Geodatabase.ICursor cursor;
                selectionSet.Search(spatialFilterCls, true, out cursor);
                ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor;                 // Explicit Cast

                ESRI.ArcGIS.Geodatabase.IFeature lineFeature;
                lineFeature = featureCursor.NextFeature();
                if (lineFeature == null)
                {
                    MessageBox.Show("Please select a feature in the feature layer selected");
                }
                else
                {
                    CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls);
                }
            }
            this.Close();
        }
Пример #23
0
        /// <summary>
        /// 修正处理函数,参数框架为主窗体,以获得图层(取得待处理的要素)和进度条

        /// </summary>
        /// <param name="AppHook"></param>

        private void ExcuteCorrect(object hook)
        {
            SetCheckState.GeoCor = true;//拓扑修正里用到开启和关闭编辑
            Plugin.Application.IAppGISRef AppHook = hook as Plugin.Application.IAppGISRef;
            #region 取得进度条对象

            //取得进度条对象

            Plugin.Application.IAppFormRef pAppForm = AppHook as Plugin.Application.IAppFormRef;
            #endregion
            Plugin.Application.IAppGISRef appHook = hook as Plugin.Application.IAppGISRef;

            #region 获得待处理的图层

            //判断图层个数是否为0
            if (AppHook.MapControl.LayerCount == 0)
            {
                return;
            }
            IWorkspaceEdit pWorkspaceEdit = null;

            #region 循环图层进行处理,并控制进度条

            for (int i = 0; i < AppHook.MapControl.LayerCount; i++)
            {
                ESRI.ArcGIS.Carto.ILayer pLayer = AppHook.MapControl.get_Layer(i);
                bool isShpFile = false;

                //操作更新库体下的层 && pLayer.Name == SetCheckState.CheckDataBaseName

                #region 针对的是IGrouplayer下的层进行拓扑修正
                if (pLayer is IGroupLayer)
                {
                    ICompositeLayer C_layer = pLayer as ICompositeLayer;
                    int             count   = C_layer.Count;//得到组合图层数
                    if (count == 0)
                    {
                        return;
                    }
                    for (int c = 0; c < count; c++)
                    {
                        ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = C_layer.get_Layer(c) as IFeatureLayer;
                        #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向
                        if (pFeatLayer == null)
                        {
                            continue;
                        }
                        IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;

                        //开启编辑  wjj 20090921
                        IDataset pDataset = pFeatureClass as IDataset;
                        pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                        if (pWorkspaceEdit.IsBeingEdited() == false)
                        {
                            pWorkspaceEdit.StartEditing(false);
                        }

                        //判断图层类型,线或者面才进行处理

                        if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //删除空几何图形

                                        if (pFeat.Shape.IsEmpty)
                                        {
                                            pFeat.Delete();
                                            //写状态栏信息
                                            string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, del);
                                        }
                                        else
                                        {
                                            ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                            if (pTopo != null)
                                            {
                                                //图形简单化
                                                pTopo.Simplify();
                                                //写状态栏信息
                                                string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                                SetCheckState.CheckShowTips(pAppForm, simplify);
                                            }
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #region  除长度为零的线要素
                            //删除长度为零的要素

                            IQueryFilter pFilter = new QueryFilterClass();
                            pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, zero);
                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #endregion

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                        }
                        else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                        {
                            IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);
                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //删除空几何图形

                                        if (pFeat.Shape.IsEmpty)
                                        {
                                            pFeat.Delete();
                                            //写状态栏信息
                                            string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, delps);
                                        }
                                        else
                                        {
                                            ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                            if (pTopo != null)
                                            {
                                                //图形简单化
                                                pTopo.Simplify();
                                                //写状态栏信息
                                                string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                                SetCheckState.CheckShowTips(pAppForm, simplifyps);
                                            }
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #region 负面积面点序逆向
                            IQueryFilter pFilter = new QueryFilterClass();
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();
                                if (pFeat != null)
                                {
                                    do
                                    {
                                        //点序逆向
                                        ICurve pCurv = pFeat.Shape as ICurve;

                                        if (pCurv != null)
                                        {
                                            pCurv.ReverseOrientation();
                                            pFeat.Shape = pCurv;
                                            pFeat.Store();
                                            //写状态栏信息
                                            string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, reverse);
                                        }

                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            #endregion

                            //删除面积为零的要素

                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null";

                            pFeatCur = pFeatureClass.Search(pFilter, false);

                            if (pFeatCur != null)
                            {
                                IFeature pFeat = pFeatCur.NextFeature();

                                if (pFeat != null)
                                {
                                    do
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, delarea);
                                        pFeat = pFeatCur.NextFeature();
                                    } while (pFeat != null);
                                }
                            }

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);

                            #endregion
                        }

                        //结束编辑 wjj 20090921
                        if (pWorkspaceEdit.IsBeingEdited() == true)
                        {
                            pWorkspaceEdit.StopEditing(true);
                        }
                    }
                    SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!");
                    appHook.CurrentThread = null;
                    SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!");
                    SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原
                    break;
                }
                #endregion
                else
                {
                    ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as IFeatureLayer;
                    #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向
                    if (pFeatLayer == null)
                    {
                        continue;
                    }
                    IFeatureClass pFeatureClass = pFeatLayer.FeatureClass;

                    //开启编辑  wjj 20090921
                    IDataset pDataset = pFeatureClass as IDataset;

                    #region 陈胜鹏添加shp文件类型的判断 2010-3-10
                    if (pFeatLayer.DataSourceType == "Shapefile Feature Class")
                    {
                        isShpFile = true;
                    }
                    #endregion

                    pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                    if (pWorkspaceEdit.IsBeingEdited() == false)
                    {
                        pWorkspaceEdit.StartEditing(false);
                    }

                    //判断图层类型,线或者面才进行处理

                    if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    //删除空几何图形

                                    if (pFeat.Shape.IsEmpty)
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, del);
                                    }
                                    else
                                    {
                                        ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                        if (pTopo != null)
                                        {
                                            //图形简单化
                                            pTopo.Simplify();
                                            //写状态栏信息
                                            string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, simplify);
                                        }
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #region  除长度为零的线要素
                        //删除长度为零的要素

                        IQueryFilter pFilter = new QueryFilterClass();

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Leng" + "=0 or " + "SHAPE_Leng" + " is null";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    pFeat.Delete();
                                    //写状态栏信息
                                    string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID;
                                    SetCheckState.CheckShowTips(pAppForm, zero);
                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #endregion

                        //释放cursor
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                    }
                    else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        IFeatureCursor pFeatCur = pFeatureClass.Search(null, false);
                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    //删除空几何图形

                                    if (pFeat.Shape.IsEmpty)
                                    {
                                        pFeat.Delete();
                                        //写状态栏信息
                                        string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, delps);
                                    }
                                    else
                                    {
                                        ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator;
                                        if (pTopo != null)
                                        {
                                            //图形简单化
                                            pTopo.Simplify();
                                            //写状态栏信息
                                            string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID;
                                            SetCheckState.CheckShowTips(pAppForm, simplifyps);
                                        }
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #region 负面积面点序逆向
                        IQueryFilter pFilter = new QueryFilterClass();

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Area" + "<0";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();
                            if (pFeat != null)
                            {
                                do
                                {
                                    //点序逆向
                                    ICurve pCurv = pFeat.Shape as ICurve;

                                    if (pCurv != null)
                                    {
                                        pCurv.ReverseOrientation();
                                        pFeat.Shape = pCurv;
                                        pFeat.Store();
                                        //写状态栏信息
                                        string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID;
                                        SetCheckState.CheckShowTips(pAppForm, reverse);
                                    }

                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }

                        #endregion

                        //删除面积为零的要素

                        if (isShpFile)
                        {
                            pFilter.WhereClause = "SHAPE_Area" + "=0 or " + "SHAPE_Area" + " is null";
                        }
                        else
                        {
                            pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null";
                        }

                        pFeatCur = pFeatureClass.Search(pFilter, false);

                        if (pFeatCur != null)
                        {
                            IFeature pFeat = pFeatCur.NextFeature();

                            if (pFeat != null)
                            {
                                do
                                {
                                    pFeat.Delete();
                                    //写状态栏信息
                                    string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID;
                                    SetCheckState.CheckShowTips(pAppForm, delarea);
                                    pFeat = pFeatCur.NextFeature();
                                } while (pFeat != null);
                            }
                        }
                        //释放cursor
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
                    }
                    #endregion
                }
            }
            //结束编辑 wjj 20090921
            if (pWorkspaceEdit.IsBeingEdited() == true)
            {
                pWorkspaceEdit.StopEditing(true);
                SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!");
                appHook.CurrentThread = null;
                SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!");
                SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原
            }
            #endregion
            #endregion
        }
Пример #24
0
        public void AddVectorDataToGlobe(ESRI.ArcGIS.GlobeCore.IGlobe globe, ESRI.ArcGIS.GlobeCore.esriGlobeLayerType globeLayerType, ESRI.ArcGIS.Carto.ILayer layer)
        {
            if (globe == null || layer == null || globeLayerType == ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeElevation || globeLayerType == ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeUnknown)
            {
                return;
            }

            if (!layer.Valid)
            {
                return;
            }

            ESRI.ArcGIS.GlobeCore.IGlobeDisplay  globeDisplay  = globe.GlobeDisplay;
            ESRI.ArcGIS.GlobeCore.IGlobeDisplay2 globeDisplay2 = globeDisplay as ESRI.ArcGIS.GlobeCore.IGlobeDisplay2; // Reference or Boxing Conversion
            globeDisplay2.PauseCaching = true;
            globe.AddLayerType(layer, globeLayerType, true);
            ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers   globeDisplayLayers   = globeDisplay as ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers; // Reference or Boxing Conversion
            ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer);
            globeLayerProperties.IsDynamicallyRasterized = false;
            globeDisplay2.PauseCaching = false;
        }
Пример #25
0
        protected override void OnClick()
        {
            // Get the min/max zoom from user input
            int minzoom = 0;
            int maxzoom = 6;

            Ecotrust.Form1 form1 = new Ecotrust.Form1();
            if (form1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                minzoom = (int)form1.numericUpDown1.Value;
                maxzoom = (int)form1.numericUpDown2.Value;
            }
            else
            {
                return; //TODO
            }

            // Use the FolderBrowserDialog Class to choose export folder
            System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
            folderDialog.Description = "Select output folder for map tiles...";
            string exportDir = "";

            if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // The returned string will be the full path, filename and file-extension for the chosen shapefile. Example: "C:\test\cities.shp"
                exportDir = folderDialog.SelectedPath;
                if (exportDir == "")
                {
                    return;  // TODO raise error
                }
            }
            else
            {
                return; //TODO
            }

            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ArcMap.Application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument; // Dynamic Cast
            ESRI.ArcGIS.Carto.IActiveView    activeView = mxDocument.ActiveView;
            ESRI.ArcGIS.Carto.IMap           map        = activeView.FocusMap;

            ESRI.ArcGIS.Geometry.IEnvelope mapaoi = activeView.Extent;

            // Set up export object and tile pixel coordinates
            int tileSizeX = 256;
            int tileSizeY = 256;

            // set up exporter with transparent background
            ESRI.ArcGIS.Output.IExportPNG pngexport = new ESRI.ArcGIS.Output.ExportPNGClass();
            ESRI.ArcGIS.Display.IColor    tcolor    = new ESRI.ArcGIS.Display.RgbColorClass();
            // Warning: 254,254,254 will be set to transparent; don't use in any of map styling
            ((IRgbColor)tcolor).Red   = 254;
            ((IRgbColor)tcolor).Green = 254;
            ((IRgbColor)tcolor).Blue  = 254;
            ((ExportPNG)pngexport).BackgroundColor = tcolor;
            pngexport.TransparentColor             = tcolor;
            ESRI.ArcGIS.Output.IExport export = (ESRI.ArcGIS.Output.IExport)pngexport;

            ESRI.ArcGIS.esriSystem.tagRECT exportRECT;
            exportRECT.left   = 0;
            exportRECT.top    = 0;
            exportRECT.right  = tileSizeX;
            exportRECT.bottom = tileSizeY;
            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            export.PixelBounds = envelope;

            map.DelayDrawing(true);

            // Turn off all layers
            for (int i = 0; i < map.LayerCount; i++)
            {
                map.get_Layer(i).Visible = false;
            }

            // Calculate total number of tiles needed
            GlobalMercator mercator = new GlobalMercator();

            GlobalMercator.Coords tempmins;
            GlobalMercator.Coords tempmaxs;
            Double numTiles = 0;

            for (int tz = minzoom; tz <= maxzoom; tz++)
            {
                tempmins  = mercator.MetersToTile(mapaoi.XMin, mapaoi.YMin, tz);
                tempmaxs  = mercator.MetersToTile(mapaoi.XMax, mapaoi.YMax, tz);
                numTiles += ((tempmaxs.y - tempmins.y) + 1) * ((tempmaxs.x - tempmins.x) + 1);
            }
            numTiles *= map.LayerCount;

            ESRI.ArcGIS.esriSystem.IStatusBar statusBar = ArcMap.Application.StatusBar;
            statusBar.set_Message(0, "Rendering " + numTiles.ToString() + " tiles");

            // Create a CancelTracker
            ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();

            ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();

            // Set the properties of the Step Progressor
            System.Int32 int32_hWnd = ArcMap.Application.hWnd;
            ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);
            stepProgressor.MinRange  = 0;
            stepProgressor.MaxRange  = (int)numTiles;
            stepProgressor.StepValue = 1;
            stepProgressor.Message   = "Calculating " + numTiles.ToString() + " tiles";

            // Create the ProgressDialog. This automatically displays the dialog
            ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog2 = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

            // Set the properties of the ProgressDialog
            progressDialog2.CancelEnabled = true;
            progressDialog2.Description   = "Rendering " + numTiles.ToString() + " map tiles";
            progressDialog2.Title         = "Creating map tiles...";
            progressDialog2.Animation     = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriDownloadFile;
            System.Boolean boolean_Continue = true;

            int tileCount = 0;

            for (int lyrnum = 0; lyrnum < map.LayerCount; lyrnum++)
            {
                // Turn on the layer of interest
                ESRI.ArcGIS.Carto.ILayer layer = map.get_Layer(lyrnum);
                layer.Visible = true;

                // Set extents
                //ESRI.ArcGIS.Geometry.IEnvelope layeraoi = layer.AreaOfInterest;
                ESRI.ArcGIS.Geometry.IEnvelope aoi = new ESRI.ArcGIS.Geometry.EnvelopeClass();

                // Create layer directory if it doesn't exist
                DirectoryInfo dir = new DirectoryInfo(exportDir + "\\" + layer.Name);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                DateTime startTime = DateTime.Now;

                // Loop through zoom levels, rows, cols
                for (int tz = minzoom; tz <= maxzoom; tz++)
                {
                    GlobalMercator.Coords mins = mercator.MetersToTile(mapaoi.XMin, mapaoi.YMin, tz);
                    GlobalMercator.Coords maxs = mercator.MetersToTile(mapaoi.XMax, mapaoi.YMax, tz);

                    // Create zoom directory if it doesn't exist
                    DirectoryInfo dir2 = new DirectoryInfo(dir.FullName + "\\" + tz);
                    if (!dir2.Exists)
                    {
                        dir2.Create();
                    }

                    for (int tx = (int)mins.x; tx <= (int)maxs.x; tx++)
                    {
                        // Create X directory if it doesn't exist
                        DirectoryInfo dir3 = new DirectoryInfo(dir2.FullName + "\\" + tx);
                        if (!dir3.Exists)
                        {
                            dir3.Create();
                        }

                        for (int ty = (int)mins.y; ty <= (int)maxs.y; ty++)
                        {
                            // Flip y-axis for output tile name
                            int invertTy = (int)((Math.Pow(2, tz) - 1) - ty);

                            tileCount += 1;

                            // TODO Calculate time and set new message
                            // TimeSpan timeElapsed = TimeSpan.FromTicks(DateTime.Now.Subtract(startTime).Ticks); // * ((double)tileCount - (numTiles + 1)) / (numTiles + 1));
                            // double timeRemaining = (timeElapsed.TotalSeconds / (tileCount / numTiles)) - timeElapsed.TotalSeconds;
                            //(" + ((int)timeRemaining).ToString() +" remaining)";

                            stepProgressor.Message = layer.Name + "\\" + tz + "\\" + tx + "\\" + invertTy +
                                                     ".png (" + tileCount + " of " + numTiles + ")";


                            export.ExportFileName = dir3.FullName + "\\" + invertTy + ".png";

                            GlobalMercator.Bounds bnd = mercator.TileBounds(tx, ty, tz);
                            aoi.PutCoords(bnd.minx, bnd.miny, bnd.maxx, bnd.maxy);
                            aoi.SpatialReference = map.SpatialReference; // TODO aoi spatial reference == mercator?
                            // Use FullExtent instead of Extent to make the extent independent of the activeView ratio
                            activeView.FullExtent = aoi;

                            // Export
                            System.Int32 hDC = export.StartExporting();
                            activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null); // Explicit Cast and 'ref' keyword needed
                            export.FinishExporting();
                            export.Cleanup();

                            stepProgressor.Position = tileCount;

                            //Check if the cancel button was pressed. If so, break out of row
                            boolean_Continue = trackCancel.Continue();
                            if (!boolean_Continue)
                            {
                                break;
                            }
                        }
                        //Check if the cancel button was pressed. If so, break out of col
                        boolean_Continue = trackCancel.Continue();
                        if (!boolean_Continue)
                        {
                            break;
                        }
                    }
                    //Check if the cancel button was pressed. If so, break out of layers
                    boolean_Continue = trackCancel.Continue();
                    if (!boolean_Continue)
                    {
                        break;
                    }

                    // Write log
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(exportDir + "\\log.txt", true))
                    {
                        file.WriteLine(layer.Name + ", zoom " + tz + ", numtiles " + tileCount + ":" +
                                       mins.x + " " + mins.y + " " + maxs.x + " " + maxs.y);
                    }
                }
                // Turn it off
                layer.Visible = false;
            }

            map.DelayDrawing(false);

            // Turn ON all layers
            for (int i = 0; i < map.LayerCount; i++)
            {
                map.get_Layer(i).Visible = true;
            }

            // restore extent
            activeView.FullExtent = mapaoi;
            activeView.Refresh();

            // Done
            trackCancel    = null;
            stepProgressor = null;
            progressDialog2.HideDialog();
            progressDialog2 = null;
        }