『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcGIS Engine 10 开发手册(5-4)ArcGIS Engine 中的Polyline几何对象

ArcGIS Engine 10 开发手册(5-4)ArcGIS Engine 中的Polyline几何对象
Polyline 对象是由一个或多个相连或者不相连的 path 对象的有序集合,通常用来代表线状地物如道路 , 河流 , 管线等等. 该对象在ArcGIS Engine中的模型图如下 :

    Polyline 对象是由一个或多个相连或者不相连的 path 对象的有序集合,通常用来代表线状地物如道路 河流 管线等等. 该对象在ArcGIS Engine中的模型图如下

 

 

     在这个模型中,我们看到某些几何对象可以组合产生新的几何形体,如 polyline path 构成,path 又可以由 segement 组成,但是这并不意味着用户必须按照这种层次去构造 polyline,实际上 Point 集合 直接构成 Polyline,组成 Polyline 的这些路径既可以是连续的,也可以是不连续的,如下图:

     Polyline 是有序 path 组成的集合,可以拥有 MZ ID 属性值,Polyline 对象的 IPointCollection 接口包含了所有的节点信息,IGeometryCollection 接口可以获取 polyline pathsISegmentCollection 接口可以获取 polyline segments

 

   一个 Polyline 对象必须满足以下准则:

 

    组成 Polyline 对象的所有 Path 对象必须是有效的。

    组成 Polyline 对象的所有 Path 对象不能重合,相交或自相交。

    组成 Polyline 对象的多个 Path 对象可以连接与某一点,也可以分离。

     Path 对象的长度不能为 0.

     IPolyline Polyline 类的主要接口,IPolyline Reshape 方法可以使用一个 Path 对象为一个Polyline 对象整形,IPolyline SimplifyNetwork 方法用于简化网络。Polyline 对象可以使用 IGeometryCollection 接口添加 Path 对象的方法来创建,使用该接口需注意 以下情况:

 

     每一个 Path 对象必须是有效的,或使用 IPath::Simplify 方法后有效。

     由于 Polyline Path 对象的有序集合,所以添加 Path 对象时必须注意顺序和方向。

     为了保证 Polyline 是有效的,可以创建完 Polyline 对象后使用 ITopologicalOperator 接口的Simplify 方法。

     下面代码片段演示了一个 Polyline 的构成:

 

private object pMissing = Type.Missing;

public IGeometry GetPolylineGeometry()

{

    const double PathCount = 3;

    const double PathVertexCount = 3;

    IGeometryCollection pGeometryCollection = new PolylineClass();

    for (int i = 0; i < PathCount; i++)

    {

        IPointCollection pPointCollection = new PathClass();

        for (int j = 0; j < PathVertexCount; j++)

        {

            pPointCollection.AddPoint(GetPoint(), ref pMissing, ref pMissing);

        }

 

        pGeometryCollection.AddGeometry(pPointCollection as IGeometry, ref pMissing,ref pMissing);

    }

 

    return pGeometryCollection as IGeometry;

 

}

 

private IPoint GetPoint()

{

 

    const double Min = -10;

    const double Max = 10;

 

    Random random = new Random();

 

    double x = Min + (Max - Min) * random.NextDouble();

    double y = Min + (Max - Min) * random.NextDouble();

 

    return ConstructPoint(x, y);

 

}

      京ICP备08100627号-22 京公网安备 11010802030428号