本文整理汇总了C#中SpatialFilterClass类的典型用法代码示例。如果您正苦于以下问题:C# SpatialFilterClass类的具体用法?C# SpatialFilterClass怎么用?C# SpatialFilterClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpatialFilterClass类属于命名空间,在下文中一共展示了SpatialFilterClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStateQueryFilter
private IQueryFilter GetStateQueryFilter(string stateName, string subRegion, string stateAbbr)
{
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.WhereClause = StatesWhereBuilder(stateName, subRegion, stateAbbr);
return (QueryFilter)spatialFilter;
}
示例2: GetCitiesQueryFilter
private IQueryFilter GetCitiesQueryFilter(string areaName, string state, string cityClass, string isCapital, string pop2000)
{
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.WhereClause = CitiesWhereBuilder(areaName, state, cityClass, isCapital, pop2000);
return (QueryFilter)spatialFilter;
}
示例3: Check
public override bool Check(ref List<Error> checkResult)
{
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = m_structPara.strWhereClause;
//����������ѯ
IFeatureCursor ipFeatCursor = pSrcFeatClass.Search(pQueryFilter, true);
IFeature ipFeature = ipFeatCursor.NextFeature();
IGeometryCollection pGeometryCollection = new GeometryBagClass();
///��ȡ�����������geometry
while (ipFeature != null)
{
IGeometry ipGeometry = ipFeature.Shape;
if (ipGeometry == null)
{
ipFeature = ipFeatCursor.NextFeature();
continue;
}
object Missing = Type.Missing;
pGeometryCollection.AddGeometry(ipGeometry, ref Missing, ref Missing);
ipFeature = ipFeatCursor.NextFeature();
}
ISpatialIndex pSpatialIndex = (ISpatialIndex)pGeometryCollection;
pSpatialIndex.AllowIndexing = true;
pSpatialIndex.Invalidate();
///��������ͼ������ص��Ŀռ��ѯ
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps;
///�����GeometryCollection����spatialfilter
pSpatialFilter.Geometry = (IGeometry)pGeometryCollection;
string Fields = "OBJECTID,Shape";
pSpatialFilter.SubFields = Fields;
IFeatureCursor ipResultFtCur = pRelFeatClass.Search(pSpatialFilter, true);
//��������
List<Error> pRuleResult = new List<Error>();
AddResult(ref pRuleResult, ipResultFtCur);
checkResult = pRuleResult;
if (ipResultFtCur != null)
{
Marshal.ReleaseComObject(ipResultFtCur);
ipResultFtCur = null;
} if (pSrcFeatClass != null)
{
Marshal.ReleaseComObject(pSrcFeatClass);
pSrcFeatClass = null;
}
if (pRelFeatClass != null)
{
Marshal.ReleaseComObject(pRelFeatClass);
pRelFeatClass = null;
}
return true;
}
示例4: SearchContainFeat
/// <summary>
/// ��������ͼ�������ڵ�Ҫ��
/// </summary>
/// <param name="fc"></param>
/// <param name="geo"></param>
/// <returns></returns>
public static IFeatureCursor SearchContainFeat(IFeatureClass fc, IGeometry geo)
{
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = geo;
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
IFeatureCursor pfeatCursor = fc.Search(pSpatialFilter, false);
return pfeatCursor;
}
示例5: SearchIntersectLineFeat
/// <summary>
/// ����Ҫ�ؼ����������ͼ���ཻ��Ҫ�أ��������α�
/// </summary>
/// <param name="LineFeatClass"></param>
/// <param name="geo"></param>
/// <returns></returns>
public static IFeatureCursor SearchIntersectLineFeat(IFeatureClass LineFeatClass, IGeometry geo)
{
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = geo;
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
IFeatureCursor pfeatCursor = LineFeatClass.Search(pSpatialFilter, false);
return pfeatCursor;
}
示例6: GetQueryFilter
private IQueryFilter GetQueryFilter(string stateAbbr)
{
IGeometry stateGeometry = getGeometry(stateAbbr);
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = stateGeometry;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
return (QueryFilter)spatialFilter;
}
示例7: getSpatialFilter
private static ISpatialFilter getSpatialFilter(double centerX, double centerY, double distance)
{
IPoint center = getCenter(centerX, centerY);
IGeometry buffer = getBuffer(distance, center);
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = buffer;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
return spatialFilter;
}
示例8: SearchCities
public List<City> SearchCities(string userName, string password, double centerX, double centerY, double distance)
{
IWorkspace workspace = null;
IFeatureClass citiesClass = null;
IFeatureCursor citiesCursor = null;
try
{
workspace = Connect(userName, password);
//IFeatureClass citiesClass = (workspace as IFeatureWorkspace).OpenFeatureClass("SDE.SDE.Cities");
citiesClass = (workspace as IFeatureWorkspace).OpenFeatureClass("Cities");
int areaNameIndex = citiesClass.FindField("AREANAME");
IPoint center = new Point();
center.PutCoords(centerX, centerY);
IGeometry buffer = (center as ITopologicalOperator).Buffer(distance);
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = buffer;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor citiesCursor = citiesClass.Search(spatialFilter, true);
List<City> resultCities = new List<City>();
IFeature capital = citiesCursor.NextFeature();
IPoint capitalShape = null;
while (capital != null)
{
capitalShape = capital.Shape as IPoint;
resultCities.Add(new City() { AreaName = capital.get_Value(areaNameIndex) as string, X = capitalShape.X, Y = capitalShape.Y });
capital = citiesCursor.NextFeature();
}
return resultCities;
}
finally
{
if (citiesClass != null)
{
Marshal.ReleaseComObject(citiesClass);
}
}
}
示例9: Calculate
/// <summary>
/// 参数说明,栅格面,写入这个面的字段名称,点要素,点要素的速度字段,计算平均速度
/// </summary>
/// <param name="pPolygonFClass"></param>
/// <param name="pFieldName"></param>
/// <param name="pPointFClass"></param>
/// <param name="FieldName"></param>
public void Calculate(IFeatureClass pPolygonFClass, string pFieldName,IFeatureClass pPointFClass, string FieldName)
{
IFeatureCursor pPolyCursor = pPolygonFClass.Search(null, false);
int pFieldIndex = pPointFClass.FindField(FieldName);
IFeature pPolyFeature = pPolyCursor.NextFeature();
int pPolygonIndex = pPolygonFClass.FindField(pFieldName);
while (pPolyFeature != null)
{
IGeometry pPolGeo = pPolyFeature.Shape;
int Count = 0;
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = pPolGeo;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
IFeatureCursor pPointCur = pPointFClass.Search(spatialFilter, false);
double TotalSpeed = 0;
if (pPointCur != null)
{
IFeature pPointFeature = pPointCur.NextFeature();
while (pPointFeature != null)
{
pPointFeature = pPointCur.NextFeature();
TotalSpeed = TotalSpeed + (double)pPointFeature.get_Value(pFieldIndex);
Count++;
}
}
if (Count != 0)
{
pPolyFeature.set_Value(pPolygonIndex, TotalSpeed / Count);
}
pPolyFeature = pPolyCursor.NextFeature();
}
}
示例10: OnMouseDown
protected override void OnMouseDown(MouseEventArgs arg)
{
// access display and
IScreenDisplay display = (ArcMap.Document.FocusMap as IActiveView).ScreenDisplay;
// transform from display coordinates to map coordinates
IPoint point = display.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
// Buffer figure is ochertanie of other figure
IGeometry region = (point as ITopologicalOperator).Buffer(display.DisplayTransformation.FromPoints(4));
// Buffer always return polygone
IMap map = ArcMap.Document.FocusMap;
for (int i = 0; i < map.LayerCount; i++)
{
if (map.get_Layer(i).Name == "Cities")
{
IFeatureLayer citiesLayer = map.get_Layer(i) as IFeatureLayer;
IFeatureClass citiesClass = citiesLayer.FeatureClass;
int cityNameIndex = citiesClass.FindField("AREANAME");
int stateIndex = citiesClass.FindField("ST");
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = region;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor resCursor = citiesClass.Search(spatialFilter as IQueryFilter, true);
IFeature cityFeature = resCursor.NextFeature();
while (cityFeature != null)
{
MessageBox.Show(String.Format("{0}, {1}", cityFeature.get_Value(cityNameIndex), cityFeature.get_Value(stateIndex)));
cityFeature = resCursor.NextFeature();
}
Marshal.ReleaseComObject(resCursor);
break;
}
}
base.OnMouseDown(arg);
}
示例11: GetNearestEdge
//otherPt is for line features to chck if it is not split
public IFeature GetNearestEdge(IPoint point, IPoint otherPt, List<string> edgeSearchClasses)
{
IGeometry queryGeometry = point;
IFeature nearestFeat = null;
foreach (string edgeFeatClass in edgeSearchClasses)
{
IFeatureClass featClass = ((IFeatureWorkspace)ExtensionInfo.Editor.EditWorkspace).OpenFeatureClass(edgeFeatClass) as IFeatureClass;
if (featClass != null)
{
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = queryGeometry;
spatialFilter.GeometryField = featClass.ShapeFieldName;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; //esriSpatialRelEnum.esriSpatialRelTouches;
// Execute the query and iterate through the cursor's results.
IFeatureCursor featCursor = featClass.Search(spatialFilter, false);
IFeature feat = featCursor.NextFeature();
double length = 0.0;
while (feat != null)
{
ICurve curve = feat.ShapeCopy as ICurve;
if ( curve.Length > length)//DisplayMap.AreGeometriesTheSame(point, curve.FromPoint, false) == false
//&& DisplayMap.AreGeometriesTheSame(point, curve.ToPoint, false) == false
//&& (otherPt == null || (DisplayMap.AreGeometriesTheSame(otherPt, curve.FromPoint, false) == false
//&& DisplayMap.AreGeometriesTheSame(otherPt, curve.ToPoint, false) == false))
//&&
{
nearestFeat = feat;
length = curve.Length;
}
feat = featCursor.NextFeature();
}
// The cursors is no longer needed, so dispose of it.
System.Runtime.InteropServices.Marshal.ReleaseComObject(featCursor);
System.Runtime.InteropServices.Marshal.ReleaseComObject(featClass);
}
}
return nearestFeat;
}
示例12: adjustXTableFtr
private void adjustXTableFtr(IGeometry iGeometry)
{
string clFldName = dgc.IndependentFieldNames[0];
ISpatialFilter sf = new SpatialFilterClass();
sf.Geometry = iGeometry;
sf.GeometryField = ftrMap.ShapeFieldName;
sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
double tN = 0;
IFeatureCursor ftrCur = ftrMap.Search(sf, false);
IFeature ftr = ftrCur.NextFeature();
int fldIndex = ftrCur.FindField(clFldName);
while (ftr != null)
{
object vlObj = ftr.get_Value(fldIndex);
if (vlObj == null)
{
}
else
{
string vl = vlObj.ToString();
int vlIndex = olabels.IndexOf(vl);
nCnts[vlIndex] = nCnts[vlIndex] + 1;
tN += 1;
}
ftr = ftrCur.NextFeature();
}
updateXTable(tN);
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:28,代码来源:dataPrepAdjustAccuracyAssessment.cs
示例13: UpStreamFindParcels
//��˷�ٲ��ҹ����漰�ĵؿ�
public static void UpStreamFindParcels(AxMapControl ppAxMapControl, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork)
{
try
{
IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", ppAxMapControl);
IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", ppAxMapControl);
//����ѡ���Sewer�������д������ΰ�
IGeometryCollection pGeomBag = new GeometryBagClass();
object missing = Type.Missing;
int lEID;
int iUserClassID;
int iUserID;
int iUserSubID;
INetElements pNetElements = pGeoNetwork.Network as INetElements;
pEnumResultEdges.Reset();
IFeature pFeature;
for (int j = 0; j <= pEnumResultEdges.Count - 1; j++)
{
lEID = pEnumResultEdges.Next();
pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID);
pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing);
// MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString());
}
//���пռ����˵��Ӳ��������ڲ��ҵؿ���Ϣ
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = pGeomBag as IGeometry;
pSpatialFilter.GeometryField = "Shape";
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
//��ý��浽�ĵؿ���Ϣ
IFeatureCursor pFeatCursor = pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false);
//���ӱ�ѡ��ĵؿ����ݵ���ͼ��ͼ��ͼ��������
ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass();
ILayer pLayer = pComGraphicLayer as ILayer;
pLayer.Name = "��Ӱ��ĵؿ�";
IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer;
//������ѡ��ĵؿ鵽ͼ��������
ISimpleFillSymbol pSymFill = new SimpleFillSymbolClass();
IFillSymbol pFillSymbol = pSymFill as IFillSymbol;
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 0;
pRgbColor.Green = 200;
pRgbColor.Blue = 100;
pFillSymbol.Color = pRgbColor as IColor;
ICartographicLineSymbol pCartoLine = new CartographicLineSymbolClass();
IRgbColor pRgbColor2 = new RgbColorClass();
pRgbColor2.Red = 100;
pRgbColor2.Green = 200;
pRgbColor2.Blue = 100;
pCartoLine.Width = 2;
pCartoLine.Color = pRgbColor2 as IColor;
pFillSymbol.Outline = pCartoLine;
//����������еؿ�����������
IArray pFeatArray = new ArrayClass();
pFeature = pFeatCursor.NextFeature();
while (pFeature != null)
{
IElement pPolyElement = new PolygonElementClass();
IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement;
pPolyElement.Geometry = pFeature.Shape;
pFillShapeElement.Symbol = pFillSymbol;
pGraphicContainer.AddElement(pPolyElement, 0);
pFeatArray.Add(pFeature);
pFeature = pFeatCursor.NextFeature();
}
ppAxMapControl.AddLayer(pGraphicContainer as ILayer);
ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
//ma
//frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(ppAxMapControl,pFeatLayerParcels, pFeatArray);
//frmUpstreamCreateOwnerList1.Show();
}
catch (Exception eX)
{
MessageBox.Show(eX.Message);
}
}
示例14: nw_query
private void nw_query(IMapControlEvents2_OnMouseDownEvent e)
{
//axMapControl1
ILayer layer = m_datasource.GetAdministrativeMap().get_Layer(m_query_area_detail);
ILayer layer_shiyi =null;// = axMapControl1.Map.get_Layer (m_selectedLayer);
ILayer layer_cishi = null;//= axMapControl1.Map.get_Layer(m_selectedLayer);
getLayer(m_query_area_detail, ref layer_shiyi, ref layer_cishi);
//resolveNameRate(layer.Name);
//resolveNameRange(layer.Name);
//layer_name[1];
//
axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;
ESRI.ArcGIS.Geometry.IGeometry geometry = null;
ESRI.ArcGIS.Geometry.Point pt = new ESRI.ArcGIS.Geometry.Point();
pt.X = e.mapX;
pt.Y = e.mapY;
geometry = pt as ESRI.ArcGIS.Geometry.IGeometry;
// geometry = axMapControl1.TrackRectangle();
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
IQueryFilter pQueryFilter = pSpatialFilter as ISpatialFilter;
//设置过滤器的Geometry
pSpatialFilter.Geometry = geometry;
//设置空间关系类型
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//esriSpatialRelContains;
//获取FeatureCursor游标
IFeatureLayer featureLayer = layer as IFeatureLayer;
//获取featureLayer的featureClass
IFeatureClass featureClass = featureLayer.FeatureClass;
IFeatureCursor pFeatureCursor = featureClass.Search(pQueryFilter, true);
//遍历FeatureCursor
IFeature pFeature = pFeatureCursor.NextFeature();
//获取FeatureCursor游标
IFeatureLayer featureLayer1 = layer_shiyi as IFeatureLayer;
//获取featureLayer的featureClass
IFeatureClass featureClass1 = featureLayer1.FeatureClass;
IFeatureCursor pFeatureCursor1 = featureClass1.Search(pQueryFilter, true);
//遍历FeatureCursor
IFeature pFeature1 = pFeatureCursor1.NextFeature();
//获取FeatureCursor游标
IFeatureLayer featureLayer2 = layer_cishi as IFeatureLayer;
//获取featureLayer的featureClass
IFeatureClass featureClass2 = featureLayer2.FeatureClass;
IFeatureCursor pFeatureCursor2 = featureClass2.Search(pQueryFilter, true);
//遍历FeatureCursor
IFeature pFeature2 = pFeatureCursor2.NextFeature();
//QueryForm qf =new QueryForm(m_bin_path);
m_qf.m_mapControl = axMapControl1;
m_qf.m_featureLayer = featureLayer;
m_qf.m_query_name = m_range_en;
m_qf.m_mucao = m_mucao;
m_qf.QueryForm_SetText( m_mucao);
//qf.m_layername = "当前图层:" + layer.Name;
System.Windows.Forms.ListView listView_data = m_qf.nw_getListView();
listView_data.Items.Clear();
m_qf.m_range = m_range;
listView_data.Columns.Clear();
listView_data.Columns.Add(m_range + "名", 120, HorizontalAlignment.Left);//省名,,
listView_data.Columns.Add("适宜面积比", 120, HorizontalAlignment.Left);
listView_data.Columns.Add("适宜面积", 120, HorizontalAlignment.Left);
listView_data.Columns.Add("次适宜面积比", 120, HorizontalAlignment.Left);
listView_data.Columns.Add("次适宜面积", 120, HorizontalAlignment.Left);
string area1 = "area" + m_rate_en;
string rate1 = "rate" + m_rate_en;
string area2 = "area" + m_rate_en;
string rate2 = "rate" + m_rate_en;
if(pFeature1 != null)
{
for (int i = 0; i < pFeature1.Fields.FieldCount;++i )
{
if (pFeature1.Fields.Field[i].Name.IndexOf("area_") > -1)
{
area1 = pFeature1.Fields.Field[i].Name;
}
else if(pFeature1.Fields.Field[i].Name.IndexOf("rate_")>-1)
{
rate1 = pFeature1.Fields.Field[i].Name;
}
}
}
if (pFeature2 != null)
{
for (int i = 0; i < pFeature2.Fields.FieldCount; ++i)
{
if (pFeature2.Fields.Field[i].Name.IndexOf("area_") > -1)
{
area2 = pFeature2.Fields.Field[i].Name;
}
else if (pFeature2.Fields.Field[i].Name.IndexOf("rate_") > -1)
{
//.........这里部分代码省略.........
示例15: IntersectAll
private bool IntersectAll(IFeatureClass lineLayer, IPolygon polygon2, List<ziduan> list)
{
try
{
if (radioBtnKJ.Checked && polygon2 != null)
{
// 根据组合成的面裁剪压力等值线
SpatialFilterClass qfilter = new SpatialFilterClass();
qfilter.Geometry = polygon2;
qfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor qfeatureCursor = lineLayer.Search(qfilter, false);
if (qfeatureCursor != null)
{
IFeature feature = qfeatureCursor.NextFeature();
IGeometryArray geometryArray = new GeometryArrayClass();
while (feature != null)
{
geometryArray.Add(feature.Shape);
feature = qfeatureCursor.NextFeature();
}
IGeometryServer2 geometryServer2 = new GeometryServerClass();
IGeometryArray geometryArray2 = geometryServer2.Intersect(polygon2.SpatialReference, geometryArray, polygon2);
//DataEditCommon.DeleteFeatureByWhereClause(lineLayer, "");
IFeatureLayer pFeatureLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, EditLayerName) as IFeatureLayer;
DataEditCommon.CreateFeature(pFeatureLayer.FeatureClass, geometryArray2, list);
}
}
return true;
}
catch
{ return false; }
}