所以爲了做到這一點而不必執行相交和「不包含」測試,您可以使用觸摸。從您可以在這裏找到的入門指南:Getting Started Guide觸摸應該有你想要的定義。在底部的例子中注意到,儘管考慮了所有的縣,普萊塞縣本身並沒有出現在結果集中,但是它周圍的每個縣都有。
IFeatureSet counties;
IFeature placer;
private void Form1_Load(object sender, EventArgs e)
{
// Open a FeatureSet from a shapefile containing Counties
counties = Shapefile.Open("D:\\Data\\Counties\\CntyBnds_ESRI.shp");
// Loop through the features to find the Feature with the Name equal to "Placer"
foreach (IFeature f in counties.Features)
{
if (f.DataRow["NAME"].ToString() == "Placer")
{
placer = f;
break;
}
}
// Add the counties layer to the map to show all the counties
this.map1.Layers.Add(counties);
}
private void button1_Click(object sender, EventArgs e)
{
FeatureSet result = new FeatureSet();
// Cycle thorugh the shapes using the Touches operation
foreach (IFeature county in counties.Features)
{
if (county.Touches(placer))
{
// Add only the features that touch to the result dataset.
result.AddFeature(county);
}
}
// Add the result to the map.
this.map1.Layers.Add(result);
}
來源
2015-04-22 23:34:57
Ted