IRelationalOperator 接口

92 篇文章 5 订阅


1. Provides access to members that determine if a certain spatial relationship exists between two geometries.

  Members
  Description
MethodContainsIndicates if this geometry contains the other geometry.
前者是否包含后者!
MethodCrossesIndicates if the two geometries intersect in a geometry of lesser dimension.
MethodDisjointIndicates if the two geometries share no points in common. Negate this result to compute the Intersect relation.
MethodEqualsIndicates if the two geometries are of the same type and define the same set of points in the plane.
MethodOverlapsIndicates if the intersection of the two geometries has the same dimension as one of the input geometries.
前者和后者是否有重叠!不包括包含关系!
MethodRelationIndicates if the defined relationship exists.
MethodTouchesIndicates if the boundaries of the geometries intersect.
MethodWithinIndicates if this geometry is contained (is within) another geometry.
前者是否在后者内部!
  CoClasses that implement IRelationalOperator
CoClasses and ClassesDescription
EnvelopeA rectangle with sides parallel to a coordinate system defining the extent of another geometry; optionally has min and max measure, height and ID attributes.
GeometryBagAn ordered collection of objects that support the IGeometry interface.
MultiPatchA collection of surface patches.
MultipointAn ordered collection of points; optionally has measure, height and ID attributes.
PointA two dimensional point, optionally with measure, height, and ID attributes.
PolygonA collection of rings ordered by their containment relationship; optionally has measure, height and ID attributes.
PolylineAn ordered collection of paths; optionally has measure, height and ID attributes.

※ | ※ → 公共代码部分:


IMap pMap;
IActiveView pActiveView;
IEnvelope pEnv;
ISelectionEnvironment pSelectionEnv;
IEnumFeature pEnumFeature;
IFeature pFeature;
IGeometry pGeometry;
IGeometry pBasicGeo;


private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
    axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
    pMap = axMapControl1.Map;
    pActiveView = pMap as IActiveView;
    pEnv = axMapControl1.TrackRectangle();
    pSelectionEnv = new SelectionEnvironment();
    pSelectionEnv.DefaultColor = GetColor(255, 0, 0);
    pMap.SelectByShape(pEnv, pSelectionEnv, false);
    pActiveView.Refresh();
    pEnumFeature = pMap.FeatureSelection as IEnumFeature;
}


private IRgbColor GetColor(int r, int g, int b)
{
    IRgbColor pColor = new RgbColor();
    pColor.Red = r;
    pColor.Green = g;
    pColor.Blue = b;
    return pColor;
}


private IGeometry GetBasicGeometry()
{
    IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(1) as IFeatureLayer;
    IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
    IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
    IFeature pF = pFeatureCursor.NextFeature();
    IGeometry pUnionGeo = new PolygonClass();
    pUnionGeo = pF.Shape;
    while(pF != null)
    {
        ITopologicalOperator pUnionTopo = pUnionGeo as ITopologicalOperator;
        pUnionGeo = pUnionTopo.Union(pF.Shape);
        pF = pFeatureCursor.NextFeature();
    }
    return pUnionGeo;
}

private void Form1_Load(object sender, EventArgs e)
{
    (axMapControl1.get_Layer(1) as IFeatureLayer).Selectable = false;
}

 

※ | ※ → Contains:



private void button5_Click(object sender, EventArgs e)
{
    pBasicGeo = GetBasicGeometry();
    pGeometry = new PolygonClass();
    while (true)
    {
        pFeature = pEnumFeature.Next();
        if (pFeature == null)
            break;
        ITopologicalOperator pTopo = pGeometry as ITopologicalOperator;
        pGeometry = pTopo.Union(pFeature.Shape);
    }

    IRelationalOperator pRO = pBasicGeo as IRelationalOperator;
    bool IsContains = pRO.Contains(pGeometry);
    if (IsContains)
    {
        MessageBox.Show("Basic图层数据 包含 选中数据!");
    }
    else
    {
        MessageBox.Show("Basic图层数据 不包含 选中数据!");
    }
}

 

※ | ※ → Overlaps:



private void button2_Click(object sender, EventArgs e)
{
    pBasicGeo = GetBasicGeometry();
    pGeometry = new PolygonClass();
    while (true)
    {
        pFeature = pEnumFeature.Next();
        if (pFeature == null)
            break;
        ITopologicalOperator pTopo = pGeometry as ITopologicalOperator;
        pGeometry = pTopo.Union(pFeature.Shape);
    }

    IRelationalOperator pRO = pGeometry as IRelationalOperator;
    bool IsContains = pRO.Overlaps(pBasicGeo);
    if (IsContains)
    {
        MessageBox.Show("选中数据 重叠 Basic图层数据!");
    }
    else
    {
        MessageBox.Show("选中数据 不重叠 Basic图层数据!");
    }
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值