本文整理汇总了C#中EnvelopeClass.Union方法的典型用法代码示例。如果您正苦于以下问题:C# EnvelopeClass.Union方法的具体用法?C# EnvelopeClass.Union怎么用?C# EnvelopeClass.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnvelopeClass
的用法示例。
在下文中一共展示了EnvelopeClass.Union方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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;
}
示例3: InitializeNetworkAndMap
//初始化
private bool InitializeNetworkAndMap(IFeatureDataset Featuredataset,System.Collections.ArrayList array1,System.Collections.ArrayList array2,int flag)
{
IFeatureClassContainer ipFeatureClassContainer;
IFeatureClass ipFeatureClass;
IGeoDataset ipGeoDataset;
ILayer ipLayer;
IFeatureLayer ipFeatureLayer;
IEnvelope ipEnvelope, ipMaxEnvelope;
double dblSearchTol;
INetworkCollection ipNetworkCollection = Featuredataset as INetworkCollection;
int count = ipNetworkCollection.GeometricNetworkCount;
barrierarray1 =(System.Collections.ArrayList)array1.Clone();
barrierarray2 = (System.Collections.ArrayList)array2.Clone();
barrierflag = flag;
//获取几何网络工作空间
m_ipGeometricNetwork = ipNetworkCollection.get_GeometricNetwork(0);
INetwork ipNetwork = m_ipGeometricNetwork.Network;
if (m_ipMap != null)
{
m_ipMap = new MapClass();
ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer;
count = ipFeatureClassContainer.ClassCount;
for (int i = 0; i < count; i++)
{
ipFeatureClass = ipFeatureClassContainer.get_Class(i);
ipFeatureLayer = new FeatureLayerClass();
ipFeatureLayer.FeatureClass = ipFeatureClass;
m_ipMap.AddLayer(ipFeatureLayer);
}
}
count = m_ipMap.LayerCount;
ipMaxEnvelope = new EnvelopeClass();
for (int i = 0; i < count; i++)
{
ipLayer = m_ipMap.get_Layer(i);
ipFeatureLayer = ipLayer as IFeatureLayer;
ipGeoDataset = ipFeatureLayer as IGeoDataset;
ipEnvelope = ipGeoDataset.Extent;
ipMaxEnvelope.Union(ipEnvelope);
}
m_ipPointToEID = new PointToEIDClass();
m_ipPointToEID.SourceMap = m_ipMap;
m_ipPointToEID.GeometricNetwork = m_ipGeometricNetwork;
double dblWidth = ipMaxEnvelope.Width;
double dblHeight = ipMaxEnvelope.Height;
if (dblWidth > dblHeight)
dblSearchTol = dblWidth / 100;
else
dblSearchTol = dblHeight / 100;
m_ipPointToEID.SnapTolerance = dblSearchTol;
return true;
}
示例4: GetLayerExtent
/// <summary>
/// Calculates the layer extent
/// </summary>
private void GetLayerExtent()
{
if (null == m_table)
return;
IEnvelope env = new EnvelopeClass();
env.SpatialReference = base.m_spatialRef;
IPoint point = new PointClass();
foreach (DataRow r in m_table.Rows)
{
if (r[1] is DBNull || r[2] is DBNull)
continue;
point.Y = Convert.ToDouble(r[3]);
point.X = Convert.ToDouble(r[4]);
env.Union(point.Envelope);
}
base.m_extent = env;
}
示例5: GetGraphicsExtent
private IEnvelope GetGraphicsExtent(IActiveView docActiveView)
{
IEnvelope GraphicsBounds;
IEnvelope GraphicsEnvelope;
IGraphicsContainer oiqGraphicsContainer;
IPageLayout docPageLayout;
IDisplay GraphicsDisplay;
IElement oiqElement;
GraphicsBounds = new EnvelopeClass();
GraphicsEnvelope = new EnvelopeClass();
docPageLayout = docActiveView as IPageLayout;
GraphicsDisplay = docActiveView.ScreenDisplay;
oiqGraphicsContainer = docActiveView as IGraphicsContainer;
oiqGraphicsContainer.Reset();
oiqElement = oiqGraphicsContainer.Next();
while (oiqElement != null)
{
oiqElement.QueryBounds(GraphicsDisplay, GraphicsEnvelope);
GraphicsBounds.Union(GraphicsEnvelope);
oiqElement = oiqGraphicsContainer.Next();
}
return GraphicsBounds;
}
示例6: InitializeNetworkAndMap
//初始化几何网络和地图
private bool InitializeNetworkAndMap(IFeatureDataset FeatureDataset)
{
IFeatureClassContainer ipFeatureClassContainer;
IFeatureClass ipFeatureClass;
IGeoDataset ipGeoDataset;
ILayer ipLayer;
IFeatureLayer ipFeatureLayer;
IEnvelope ipEnvelope, ipMaxEnvelope;
double dblSearchTol;
INetworkCollection ipNetworkCollection = FeatureDataset as INetworkCollection;
int count = ipNetworkCollection.GeometricNetworkCount;
//获取第一个几何网络工作空间
m_ipGeometricNetwork = ipNetworkCollection.get_GeometricNetwork(0);
INetwork ipNetwork = m_ipGeometricNetwork.Network;
if (m_ipMap != null)
{
//m_ipMap = new MapClass();
ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer;
count = ipFeatureClassContainer.ClassCount;
for (int i = 0; i < count; i++)
{
ipFeatureClass = ipFeatureClassContainer.get_Class(i);
ipFeatureLayer = new FeatureLayerClass();
ipFeatureLayer.FeatureClass = ipFeatureClass;
for (int j = 0; j < m_ipMap.LayerCount; j++)
{
if (m_ipMap.get_Layer(j).Name.ToUpper() == ipFeatureLayer.Name.ToUpper())
{
continue;
}
}
m_ipMap.AddLayer(ipFeatureLayer);
}
m_ipActiveView.Refresh();
}
count = m_ipMap.LayerCount;
ipMaxEnvelope = new EnvelopeClass();
for (int i = 0; i < count; i++)
{
ipLayer = m_ipMap.get_Layer(i);
ipFeatureLayer = ipLayer as IFeatureLayer;
ipGeoDataset = ipFeatureLayer as IGeoDataset;
ipEnvelope = ipGeoDataset.Extent;
ipMaxEnvelope.Union(ipEnvelope);
}
m_ipPointToEID = new PointToEIDClass();
m_ipPointToEID.SourceMap = m_ipMap;
m_ipPointToEID.GeometricNetwork = m_ipGeometricNetwork;
double dblWidth = ipMaxEnvelope.Width;
double dblHeight = ipMaxEnvelope.Height;
if (dblWidth > dblHeight)
dblSearchTol = dblWidth / 100;
else
dblSearchTol = dblHeight / 100;
m_ipPointToEID.SnapTolerance = dblSearchTol;
return true;
}
示例7: CombineExtents
private IEnvelope CombineExtents(IFeatureClass pfclass1, IFeatureClass pfeatclass2)
{
try
{
IEnvelope pEnv = new EnvelopeClass();
IGeoDataset pGeoDS = pfclass1 as IGeoDataset;
pGeoDS.Extent.QueryEnvelope(pEnv);
pGeoDS = pfeatclass2 as IGeoDataset;
pEnv.Union(pGeoDS.Extent);
return pEnv;
}
catch
{
System.Windows.Forms.MessageBox.Show("Be sure that both layers have matching Spatial References.");
IEnvelope pEnv = new EnvelopeClass();
pEnv.SetEmpty();
return pEnv;
}
}
示例8: 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);
}
}
}
示例9: buttonApply_Click
//
private void buttonApply_Click(object sender, System.EventArgs e)
{
try
{
IQueryFilter pQueryFilter=new QueryFilterClass();
AxMapControl axMap=pMainFrm.getMapControl();
string sLayerName=comboBoxLayer.Text;
bool bLayerType=GetLayerType(sLayerName);
IActiveView pActiveView=axMap.Map as IActiveView ;
if(bLayerType==false)
{
pQueryFilter.WhereClause=textBox1.Text;
IFeatureCursor pFeatCursor=m_pFeatCls.Search(pQueryFilter,false);
IFeature pFeature=pFeatCursor.NextFeature();
axMap.Map.ClearSelection();
IEnvelope pEnvelope=new EnvelopeClass();
ILayer pLayer=GetLayerFromName(sLayerName);
while(pFeature!=null)
{
axMap.Map.SelectFeature(pLayer,pFeature);
pEnvelope.Union(pFeature.Extent.Envelope);
pFeature=pFeatCursor.NextFeature();
}
axMap.Extent=pEnvelope;
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,null,null);
pActiveView.Refresh();
}
else
{
IRasterDescriptor pRasDes=new RasterDescriptorClass();
pQueryFilter.WhereClause=textBox1.Text;
pRasDes.Create(m_pRaster,pQueryFilter,listBoxField.Text);
IExtractionOp pExtrOp=new RasterExtractionOpClass();
IRaster pRaster=pExtrOp.Attribute(pRasDes) as Raster ;
IRasterLayer pRsLayer=new RasterLayerClass();
pRsLayer.CreateFromRaster(pRaster);
axMap.Map.AddLayer(pRsLayer);
pActiveView.Refresh();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例10: 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;
}
示例11: 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;
}
}
示例12: GetLayerExtent
/// <summary>
/// get the overall extent of the items in the layer
/// </summary>
/// <returns></returns>
private IEnvelope GetLayerExtent()
{
if (null == base.m_spRef)
{
base.m_spRef = CreateGeographicSpatialReference();
}
IEnvelope env = new EnvelopeClass();
env.SpatialReference = base.m_spRef;
IPoint point = new PointClass();
point.SpatialReference = m_spRef;
foreach (DataRow r in m_table.Rows)
{
point.Y = Convert.ToDouble(r[3]);
point.X = Convert.ToDouble(r[4]);
env.Union(point.Envelope);
}
return env;
}