当前位置: 首页>>代码示例>>C#>>正文


C# EnvelopeClass.Expand方法代码示例

本文整理汇总了C#中EnvelopeClass.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# EnvelopeClass.Expand方法的具体用法?C# EnvelopeClass.Expand怎么用?C# EnvelopeClass.Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnvelopeClass的用法示例。


在下文中一共展示了EnvelopeClass.Expand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: highLight

        private void highLight(IFeatureLayer featurelayer)
        {
            if(m_nactcn == "")
                return;
            IFeatureClass featureClass = featurelayer.FeatureClass;
            IFeatureSelection sel = featurelayer as IFeatureSelection;

                IFeature feature = null;

                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                axMapControl1.Map.ClearSelection();
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                IQueryFilter queryFilter = new QueryFilterClass();
                IFeatureCursor featureCusor;
                queryFilter.WhereClause = m_range_en + " = '" + m_nactcn + "'";

                featureCusor = featureClass.Search(queryFilter, true);
                //search的参数第一个为过滤条件,第二个为是否重复执行。
                //feature = featureCusor.NextFeature();
                IFeature pFeat = null;
                IEnvelope pEnve = new EnvelopeClass();
                while ((pFeat = featureCusor.NextFeature()) != null)
                {
                    pEnve.Union(pFeat.Extent);
                }

                if (!pEnve.IsEmpty)
                {
                    pEnve.Expand(4.9, 4.9, true);
                    (axMapControl1.Map as IActiveView).Extent = pEnve;
                    (axMapControl1.Map as IActiveView).Refresh();
                }
                else
                    return;
                sel.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultXOR, false);
                if (feature != null)
                {
                    //m_feature = feature;
                    // m_mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    // sel.Clear();
                    //m_mapControl.Map.FeatureSelection.Clear();
                    sel.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);
                    //m_mapControl.Map.SelectFeature(m_featureLayer as ILayer, feature);
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                   // axMapControl1.CenterAt(feature.Extent.LowerLeft);

                    //m_mapControl.MapScale = 0.1;
                    //m_mapControl.Map.SelectFeature(m_featureLayer as ILayer, null);
                }
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:51,代码来源:nw_query.cs

示例2: ZoomTo

    /// <summary>
    /// Zoom to weather item according to its zipcode
    /// </summary>
    /// <param name="zipCode"></param>
    public void ZoomTo(long zipCode)
    {
      if(null == m_table || null == m_symbolTable )
        return;

      if(null == m_display)
        return;

      //get the record for the requested zipCode
      DataRow r = m_table.Rows.Find(zipCode);
      if(null == r)
        return;

      //get the coordinate of the zipCode
      double lat = Convert.ToDouble(r[3]);
      double lon = Convert.ToDouble(r[4]);

      IPoint point = new PointClass();
      point.X = lon;
      point.Y = lat;
      point.SpatialReference = m_spatialRef;

			if (null != m_mapSpatialRef && m_mapSpatialRef.FactoryCode != m_layerSRFactoryCode)
        point.Project(m_mapSpatialRef);

      int iconCode = Convert.ToInt32(r[8]);
      //find the appropriate symbol record
      DataRow rec = m_symbolTable.Rows.Find(iconCode);
      if(rec == null)
        return;

      //get the icon's dimensions
      int iconWidth = Convert.ToInt32(rec[3]);
      int iconHeight = Convert.ToInt32(rec[4]);

      IDisplayTransformation displayTransformation = ((IScreenDisplay)m_display).DisplayTransformation;

      //Convert the icon coordinate into screen coordinate
      int windowX, windowY;
      displayTransformation.FromMapPoint(point,out windowX, out windowY);
      
      //get the upper left coord
      int ulx, uly;
      ulx = windowX - iconWidth/2;
      uly = windowY - iconHeight/2;
      IPoint ulPnt = displayTransformation.ToMapPoint(ulx, uly);

      //get the lower right coord
      int lrx,lry;
      lrx = windowX + iconWidth/2;
      lry = windowY + iconHeight/2;
      IPoint lrPnt = displayTransformation.ToMapPoint(lrx, lry);
      
      //construct the new extent
      IEnvelope envelope = new EnvelopeClass();
      envelope.PutCoords(ulPnt.X, lrPnt.Y, lrPnt.X, ulPnt.Y);
      envelope.Expand(2,2,false);
      
      //set the new extent and refresh the display
      displayTransformation.VisibleBounds = envelope;

			base.m_bIsCompiledDirty = true;

      ((IScreenDisplay)m_display).Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches);
      ((IScreenDisplay)m_display).UpdateWindow();
    }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:70,代码来源:RSSWeatherLayerClass.cs

示例3: GetLayerExtent

    /// <summary>
    /// get the overall extent of the items in the layer
    /// </summary>
    /// <returns></returns>
		private IEnvelope GetLayerExtent()
		{
      //iterate through all the items in the layers DB and get the bounding envelope
			IEnvelope env = new EnvelopeClass();
			env.SpatialReference = m_spatialRef;
			IPoint point = new PointClass();
			point.SpatialReference = m_spatialRef;
			int symbolCode = 0;
			double symbolSize = 0;
			foreach(DataRow r in m_table.Rows)
			{
				if (r[3] is DBNull || r[4] is DBNull)
					continue;

				point.Y = Convert.ToDouble(r[3]);
				point.X = Convert.ToDouble(r[4]);

				// need to get the symbol size in meters in order to add it to the total layer extent
				if (m_display != null)
				{
					symbolCode = Convert.ToInt32(r[8]);
					symbolSize = Math.Max(GetSymbolSize(m_display, symbolCode), symbolSize);
				}


				env.Union(point.Envelope);
			}

      // Expand the envelope in order to include the size of the symbol
			env.Expand(symbolSize, symbolSize, false);

      //return the layer's extent in the data underlying coordinate system
			return env;
		}
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:38,代码来源:RSSWeatherLayerClass.cs

示例4: ToggleOperableStatus

        public static IEnvelope ToggleOperableStatus(IApplication app, IPoint point, bool showMessage, string ISOvalveFeatureLayerName, string ISOsourceFeatureLayerName, string ISOoperableFieldNameValves, string ISOoperableFieldNameSources, string[] ISOoperableValues, double SnapTol)
        {
            //m_ISOsourceFeatureLayerName = ConfigUtil.GetConfigValue("TraceIsolation_Source_FeatureLayer", "");
            //m_ISOvalveFeatureLayerName = ConfigUtil.GetConfigValue("TraceIsolation_Valve_FeatureLayer", "");

            //m_ISOoperableFieldNameValves = ConfigUtil.GetConfigValue("TraceIsolation_Operable_Field_Valves", "");
            //m_ISOoperableFieldNameSources = ConfigUtil.GetConfigValue("TraceIsolation_Operable_Field_Sources", "");
            //m_ISOoperableValues = ConfigUtil.GetConfigValue("TraceIsolation_Operable_Values", "").Split('|');
            IFeatureCursor fcursor = null;
            ICursor ccursor = null;
            IFeature feat = null;
            UID uID = null;
            IEditor editor = null;
            IMxDocument mxdoc = null;
            IMap map = null;
            IFeatureLayer[] valveFLs = null;
            IFeatureClass[] valveFCs = null;
            IFeatureLayer[] sourceFLs = null;
            IFeatureClass[] sourceFCs = null;
            IEnvelope retEnv = null;
            //IGeometry geom = null;
            //IProximityOperator proxOp = null;
            IEnvelope env = null;
            ISpatialFilter sf = null;
            IWorkspace work = null;
            IWorkspaceEdit workEdit = null;
            IField opField = null;
            IPoint pTmpPnt = null;

            IEnvelope ptmpEnv = null;

            IDisplayExpressionProperties pDEP = null;
            IDisplayString pIDS = null;
            try
            {
                //Get editor
                uID = new UID();
                uID.Value = "esriEditor.Editor";
                editor = app.FindExtensionByCLSID(uID) as IEditor;

                mxdoc = app.Document as IMxDocument;
                map = mxdoc.ActiveView.FocusMap;

                string[] strValveFLs = ISOvalveFeatureLayerName.Split('|');
                // string[] strOpValues = .Split('|');
                valveFLs = new IFeatureLayer[strValveFLs.Length];//(IFeatureLayer)Globals.FindLayer(map, valveFLName);
                valveFCs = new IFeatureClass[strValveFLs.Length];
                bool lyrFnd = false;

                for (int i = 0; i < valveFLs.Length; i++)
                {
                    bool FCorLayerTemp = true;

                    valveFLs[i] = (IFeatureLayer)Globals.FindLayer(map, strValveFLs[i], ref FCorLayerTemp);
                    if (valveFLs[i] != null)
                    {
                        valveFCs[i] = valveFLs[i].FeatureClass;
                        lyrFnd = true;
                    }

                }
                string[] strSourceFLs = ISOsourceFeatureLayerName.Split('|');
                // string[] strOpValues = .Split('|');
                sourceFLs = new IFeatureLayer[strSourceFLs.Length];//(IFeatureLayer)Globals.FindLayer(map, valveFLName);
                sourceFCs = new IFeatureClass[strSourceFLs.Length];

                for (int i = 0; i < sourceFLs.Length; i++)
                {
                    bool FCorLayerTemp = true;

                    sourceFLs[i] = (IFeatureLayer)Globals.FindLayer(map, strSourceFLs[i], ref FCorLayerTemp);
                    if (sourceFLs[i] != null)
                    {
                        sourceFCs[i] = sourceFLs[i].FeatureClass;
                        lyrFnd = true;
                    }

                }
                if (lyrFnd == false)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_12a") + ISOvalveFeatureLayerName + A4LGSharedFunctions.Localizer.GetString("Or") + ISOsourceFeatureLayerName + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_12b"), A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_12c"));
                    return null;
                }

                // Globals.ClearSelected(map, false);

                foreach (IFeatureLayer valveFLayer in valveFLs)
                {

                    if (point != null)
                    {

                        env = new EnvelopeClass();
                        env.DefineFromPoints(1, ref point);
                        env.Expand(SnapTol / 2, SnapTol / 2, false);

                        sf = new SpatialFilterClass();
                        sf.Geometry = env;
                        sf.GeometryField = valveFLayer.FeatureClass.ShapeFieldName;
                        sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
//.........这里部分代码省略.........
开发者ID:rlwarford,项目名称:local-government-desktop-addins,代码行数:101,代码来源:GeoNetTools.cs

示例5: GetLinhaMaisProxima

        private static IFeature GetLinhaMaisProxima(IPoint ponto, IFeatureClass classeLinha)
        {
            IFeature ftrMaisProx = null;

            IFeatureCursor fcursor = BuscaEspacial(ponto, classeLinha, esriSpatialRelEnum.esriSpatialRelIntersects);
            IFeature ftrLinha = fcursor.NextFeature();
            double taxaBusca = 10; //10m
            int tentativas = 0;

            if (ftrLinha != null)
            {
                ftrMaisProx = LinhaMaisProxima(ponto, ref fcursor, ref ftrLinha, ref ftrMaisProx);
            }
            else
            {
                while (ftrLinha == null)
                {
                    IEnvelope env = new EnvelopeClass();
                    env = ponto.Envelope;
                    tentativas++;
                    env.Expand(taxaBusca * tentativas, taxaBusca * tentativas, false);

                    fcursor = GisUtils.BuscaEspacial(env, classeLinha, esriSpatialRelEnum.esriSpatialRelIntersects);

                    ftrLinha = fcursor.NextFeature();
                }

                ftrMaisProx = LinhaMaisProxima(ponto, ref fcursor, ref ftrLinha, ref ftrMaisProx);
            }
            return ftrMaisProx;
        }
开发者ID:ezequias,项目名称:Esri,代码行数:31,代码来源:GisUtils.cs

示例6: listView_data_SelectedIndexChanged

        private void listView_data_SelectedIndexChanged(object sender, EventArgs e)
        {
            return;
            if (listView_data.SelectedIndices != null && listView_data.SelectedIndices.Count > 0)
            {
                ListView.SelectedIndexCollection c = listView_data.SelectedIndices;
                string str = this.listView_data.SelectedItems[0].SubItems[1].Text;
                //MessageBox.Show( listView_data.Items[c[0]].Text);

                IFeatureClass featureClass = m_featureLayer.FeatureClass;
                IFeatureSelection sel = m_featureLayer as IFeatureSelection;

                IFeature feature = null;

                m_mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                m_mapControl.Map.ClearSelection();
                m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                IQueryFilter queryFilter = new QueryFilterClass();
                IFeatureCursor featureCusor;
                queryFilter.WhereClause = m_query_name +" = '" + this.listView_data.SelectedItems[0].SubItems[0].Text + "'";
                featureCusor = featureClass.Search(queryFilter, true);
                //search的参数第一个为过滤条件,第二个为是否重复执行。
                //feature = featureCusor.NextFeature();
                IFeature pFeat = null;
                IEnvelope pEnve = new EnvelopeClass();
                while ((pFeat = featureCusor.NextFeature()) != null)
                {
                    pEnve.Union(pFeat.Extent);
                }

                if (pEnve != null)
                {
                    pEnve.Expand(2, 2, true);
                    (m_mapControl.Map as IActiveView).Extent = pEnve;
                    (m_mapControl.Map as IActiveView).Refresh();
                }
                sel.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultXOR, false);
                if (feature != null)
                {
                    //m_feature = feature;
                   // m_mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                   // sel.Clear();
                    //m_mapControl.Map.FeatureSelection.Clear();
                    sel.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);
                    //m_mapControl.Map.SelectFeature(m_featureLayer as ILayer, feature);
                    m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    m_mapControl.CenterAt(feature.Extent.LowerLeft);

                    //m_mapControl.MapScale = 0.1;
                    //m_mapControl.Map.SelectFeature(m_featureLayer as ILayer, null);
                }

            }
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:55,代码来源:QueryForm.cs

示例7: btnZoomTo_Click

 private void btnZoomTo_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
     lblWarning.Text = "";
     IQueryFilter pQF = new QueryFilterClass();
     var query = from Parcel parcel in arylistParcelAdd
                 where parcel.StNum == tbStNum.Text.ToUpper() && parcel.StName == tbStNa.Text.ToUpper()
                 select parcel.FID;
     string strZoomWhereClause = "";
     var enumerator = query.GetEnumerator();
     enumerator.MoveNext();
     lblWarning.Text = (query.Count()).ToString() + " parcel is found";
     if (query.Count() == 1)
     {
         strZoomWhereClause = "FID_M='" + enumerator.Current + "'";
         pQF.WhereClause = strZoomWhereClause;
         IFeatureCursor pFC = featureClassParcels.Search(pQF, true);
         IFeature pFea = pFC.NextFeature();
         IEnvelope pEnv = pFea.Shape.Envelope;
         pEnv.Expand(1.2, 1.2, true);
         m_MapControl.ActiveView.Extent = pEnv;
         IGeometry geometry = pFea.Shape as IGeometry;
         ISimpleFillSymbol pSFS = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
         IRgbColor myColor = new RgbColorClass();
         myColor.RGB = ColorTranslator.ToWin32(Color.SkyBlue);
         pSFS.Color = myColor;
         //outline width 20?
         pSFS.Outline.Width = 20;
         pSFS.Outline.Color = myColor;
         pSFS.Style = esriSimpleFillStyle.esriSFSForwardDiagonal;
         IFillShapeElement pFSE = new PolygonElementClass();
         pFSE.Symbol = pSFS;
         pEE = (IElement)pFSE;
         pEE.Geometry = geometry;
         m_MapControl.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControlbase.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControltop.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControl.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         m_MapControlbase.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         m_MapControltop.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         //IMapFrame MF1 = this.axPageLayoutControl1.FindElementByName("MapTop", 1) as IMapFrame;
         //IActiveView acttt = MF1.Map as IActiveView;
         //acttt.GraphicsContainer.AddElement(pEE, 0);
         //acttt.Refresh();
         //? try to remove refresh
         //?try partialrefresh and geometry
         m_MapControl.ActiveView.Refresh();
     }
     //multiple parcels share parcel information, Haven't test it yet???
     else if (query.Count() > 1)
     {
         foreach (string strFID in query)
         {
             strZoomWhereClause += "FID_M='" + strFID + "' OR ";
             pQF.WhereClause = strZoomWhereClause;
         }
         //absolutely wrong here 1. not eliminate the" OR " in the end. 2. why assign whereclause twice??
         pQF.WhereClause = strZoomWhereClause;
         IFeatureCursor pFC = featureClassParcels.Search(pQF, true);
         IEnvelope pEnv = new EnvelopeClass();
         IEnvelope pEnv2 = new EnvelopeClass();
         IGeometry pShp;
         IFeature pFea = pFC.NextFeature();
         //not necessary at all???
         IFeature m_Fea = pFea;
         while (!(pFea == null))
         {
             pShp = pFea.Shape;
             pEnv2 = pShp.Envelope;
             pEnv.Union(pEnv2);
             pFea = pFC.NextFeature();
         }
         pEnv.Expand(1.2, 1.2, true);
         //??add selected parcels into graphicscontainer
         m_MapControl.ActiveView.Extent = pEnv;
         m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
     System.Windows.Forms.Cursor.Current = Cursors.Default;
 }
开发者ID:jiang-ming,项目名称:aerialphotoviewer,代码行数:79,代码来源:frmMain.cs

示例8: ZOOMTOSELECTED

        public bool ZOOMTOSELECTED()
        {
            IMxDocument pMXDoc;
            IDocument pDoc;
            IApplication pApp;
            IEnvelope pPoly;
            IMap pMap;
            IActiveView pAV;
            try
            {
                SW1.Reset();
                SW1.Start();

                //Type t = Type.GetTypeFromCLSID(typeof(AppRefClass).GUID);
                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;
                pDoc = pApp.Document;
                pMap = pMXDoc.FocusMap;
                    if (pMap.SelectionCount > 0)
                    {
                    pAV = pMXDoc.ActiveView;
                    pPoly = new EnvelopeClass();
                    ISelection selection = pMap.FeatureSelection;
                    IEnumFeature enumFeature = selection as IEnumFeature;
                    enumFeature.Reset();
                    IFeature feature;
                    feature = enumFeature.Next();
                    while (feature != null)
                    {
                        pPoly.Union(feature.ShapeCopy.Envelope);
                        feature = enumFeature.Next();
                    }

                    //pPoly = (IEnvelope)pGeomBag;
                    if (pPoly == null)
                    {
                        this.Logger.WriteLine("No Geometry");
                    }
                    else
                    {
                        this.Logger.WriteLine("X1:" + pPoly.XMin + " Y1:" + pPoly.YMin + " X2:" + pPoly.XMax + " Y2:" + pPoly.YMax);
                        if (pPoly.XMin == pPoly.XMax)
                        {
                            pPoly.Expand(1000, 1000,false);
                        }
                        pAV.Extent = (IEnvelope)pPoly;
                        pAV.ContentsChanged();
                        pAV.Refresh();
                    }
                    SW1.Stop();
                    RecordActionTime("ZoomToSelected Time", SW1.ElapsedMilliseconds);
                    return true;
                }
                else
                {
                    SW1.Stop();
                    this.Logger.WriteLine("ZoomToSelected:no features selected:");
                    return false;
                }
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("ZoomToSelected error:" + EX.Message + " Stack:" + EX.StackTrace);
                return false;
            }
        }
开发者ID:UDCUS,项目名称:ArcFM_PerfQA,代码行数:68,代码来源:PERFQA_ARCFM.cs


注:本文中的EnvelopeClass.Expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。