当前位置: 首页>>代码示例>>C#>>正文


C# IPolyline.QueryPointAndDistance方法代码示例

本文整理汇总了C#中IPolyline.QueryPointAndDistance方法的典型用法代码示例。如果您正苦于以下问题:C# IPolyline.QueryPointAndDistance方法的具体用法?C# IPolyline.QueryPointAndDistance怎么用?C# IPolyline.QueryPointAndDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPolyline的用法示例。


在下文中一共展示了IPolyline.QueryPointAndDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPINValue

    private void SetPINValue()
    {
      //The Theory.
      //Select polygons that intersect the sketch.
      //Construct one polyline from the boundaries and intersect with sketch.
      //Sort resulting intersection locations (multipoint) by distance of the intersect
      // from the start of the sketch and create new ordered multipoint.
      //Loop through new ordered multipoint, select underlying parcel and calc pin.

      IFeatureLayer featLayer = m_editLayers.CurrentLayer;
      m_curve = m_edSketch.Geometry as IPolyline;

      //Search parcel polys by graphic to get feature cursor
      ISpatialFilter spatialFilter = new SpatialFilter();
      spatialFilter.Geometry = m_curve;
      spatialFilter.GeometryField = m_editLayers.CurrentLayer.FeatureClass.ShapeFieldName;
      spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;

      IFeatureCursor featCursor = featLayer.Search(spatialFilter,true);
      IFeature feature = featCursor.NextFeature();

      //If we have no intersects then exit
      if (feature == null)
        return;
  
      //Make a GeomBag of the polygons boundaries (polylines)
      IGeometryCollection geomBag = new GeometryBagClass();
      object missing = Type.Missing;
      while (feature != null)
      {
        ITopologicalOperator poly = feature.Shape as ITopologicalOperator;
        geomBag.AddGeometry(poly.Boundary,ref missing,ref missing);
        feature = featCursor.NextFeature();
      }

      //Make one polyline from the boundaries
      IPolyline polyLineU = new PolylineClass();
      ITopologicalOperator topoOp = polyLineU as ITopologicalOperator;
      topoOp.ConstructUnion(geomBag as IEnumGeometry);

      //Get the intersections of the boundaries and the curve
      IPointCollection pointCol = topoOp.Intersect(m_curve, esriGeometryDimension.esriGeometry0Dimension) as IPointCollection;

      //The point collection is not ordered by distance along the curve so
      //need to create a new collection with this info

      int[] pointOrder = new int[pointCol.PointCount];
      double dac = 0, dfc = 0;
      bool bRS = false;

      for (int i = 0; i < pointCol.PointCount; i++)
      {
        IPoint queryPoint = new PointClass();
        pointCol.QueryPoint(i, queryPoint);
        m_curve.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, queryPoint, false, null,ref dac,ref dfc,ref bRS);
        pointOrder[i] = (int)dac;
      }

      //use built in bubble sort
      System.Array.Sort(pointOrder);

      //Loop through the sorted array and calc midpoint between parcel boundaries
      IPointCollection midPoints = new MultipointClass();

      for (int i = 0; i < pointOrder.Length -1; i++)
      {
        //Get the midpoint distance
        double midPointDist = (pointOrder[i] + pointOrder[i + 1]) / 2;
        
        //create a point at the distance and store in point collection
        IPoint queryPoint = new PointClass();
        m_curve.QueryPoint(esriSegmentExtension.esriNoExtension, midPointDist, false, queryPoint);
        midPoints.AddPoint(queryPoint,ref missing,ref missing);
      }

      //If ends of sketch are included then add them as points
      if (chkEnds.Checked)
      {
        object before = 0 as object;
        midPoints.AddPoint(m_curve.FromPoint, ref before, ref missing);
        midPoints.AddPoint(m_curve.ToPoint, ref missing, ref missing);
      }

      m_editor.StartOperation();

      //Loop through calculated midpoints, select polygon and calc pin
      for (int i = 0; i < midPoints.PointCount; i++)
      {
        IPoint midPoint = midPoints.get_Point(i);
        spatialFilter = new SpatialFilter();
        spatialFilter.Geometry = midPoint;
        spatialFilter.GeometryField = m_editLayers.CurrentLayer.FeatureClass.ShapeFieldName;
        spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;

        featCursor = featLayer.Search(spatialFilter, false);
        while ((feature = featCursor.NextFeature()) != null)
        {
          feature.set_Value(feature.Fields.FindField(cmbPINField.Text), m_lotNum);
          feature.Store();
          m_lotNum += int.Parse(txtlotinc.Text);
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:101,代码来源:ViperPinForm.cs

示例2: CalculateExtendPointNew

 /// <summary>
 /// 计算延长线上的距离
 /// </summary>
 /// <params name="startP"></params>
 /// <params name="endP"></params>
 /// <params name="jjcd"></params>
 /// <returns></returns>
 public IPoint CalculateExtendPointNew(IPolyline plin, IPoint pntTo, double jjcd, out bool bres)
 {
     bres = false;
     IPoint pntOut = new PointClass();
     double distfrom = 0.0, distto = 0.0;
     double outdistfrom = 0.0, outdistto = 0.0;
     bool boolfrom = false;
     plin.QueryPointAndDistance(esriSegmentExtension.esriExtendAtFrom, pntTo, false, pntOut, ref distfrom, ref outdistfrom, ref boolfrom);
     plin.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pntTo, false, pntOut, ref distto, ref outdistto, ref boolfrom);
     if (distfrom < distto)//反向的
     {
         bres = true;
         plin.ReverseOrientation();
         plin.QueryPoint(esriSegmentExtension.esriExtendAtTo, jjcd + plin.Length, false, pntOut);
     }
     else//正向
     {
         bres = false;
         plin.QueryPoint(esriSegmentExtension.esriExtendAtTo, jjcd + plin.Length, false, pntOut);
     }
     return pntOut;
 }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:29,代码来源:ConstructParallel.cs

示例3: ClipContour

        /// <summary>
        /// clip a polyline at the specified lengths
        /// </summary>
        public static IPolyline ClipContour(IPoint npsPoint, IPolyline npsPolyline, double RangeLeft, double RangeRight)
        {
            ICurve NewPolyline = null, pl2, pl1;
            IPoint npsExactPoint;
            double PolylineLength, DistanceFromStart = 0, DistanceFromCurve = 0, NewLineEnd,
                AmountOver, start1 = 0, start2 = 0, end1 = 0, end2 = 0, NewLineStart;
            bool npsRightSide = false, IsOutOfBoundsLeft, IsOutOfBoundsRight;
            ISegmentCollection newpl = null;

            if (npsPolyline == null) return null;

            PolylineLength = npsPolyline.Length;

            //get the distance of the point from the start of the contour
            npsExactPoint = new PointClass();
            npsPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, npsPoint, false,
                npsExactPoint, ref DistanceFromStart, ref DistanceFromCurve, ref npsRightSide);

            //if (contour)polyline is not a closed line
            if (npsPolyline.IsClosed == false)
            {

                IsOutOfBoundsLeft = false;
                IsOutOfBoundsRight = false;

                NewLineStart = DistanceFromStart - RangeLeft;
                NewLineEnd = DistanceFromStart + RangeRight;

                if (NewLineStart < 0) IsOutOfBoundsLeft = true;

                if (NewLineEnd > PolylineLength) IsOutOfBoundsRight = true;

                //if contour is outbound to the left, then try to shift it to the right
                if (IsOutOfBoundsLeft == true && IsOutOfBoundsRight == false)
                {

                    AmountOver = (DistanceFromStart - RangeLeft) * -1;

                    if (((DistanceFromStart + RangeRight) + AmountOver) < PolylineLength)
                    {
                        NewLineStart = 0;
                        NewLineEnd = (DistanceFromStart + RangeRight) + AmountOver;
                    }
                    else
                    {
                        NewLineStart = -1;
                        NewLineEnd = -1;
                    }
                }

                //if contour is out of bounds to the right, then try to shift it to the left
                if (IsOutOfBoundsLeft == false && IsOutOfBoundsRight == true)
                {
                    AmountOver = (DistanceFromStart + RangeRight) - PolylineLength;

                    if (((DistanceFromStart - RangeLeft) - AmountOver) >= 0)
                    {

                        NewLineStart = (DistanceFromStart - RangeLeft) - AmountOver;
                        NewLineEnd = PolylineLength;
                    }
                    else
                    {
                        NewLineStart = -1;
                        NewLineEnd = -1;
                    }
                }

                //since the contour is to short on both ends to create the new polyline,abound operation
                if (IsOutOfBoundsLeft == true && IsOutOfBoundsRight == true)
                {
                    NewLineStart = -1;
                    NewLineEnd = -1;
                }

                if (NewLineStart != -1 && NewLineEnd != -1)
                {

                    NewPolyline = new PolylineClass();
                    npsPolyline.GetSubcurve(NewLineStart, NewLineEnd, false, out NewPolyline);

                }
            }
            else //if polyline is closed
            {
                if ((RangeLeft + RangeRight) < PolylineLength)
                {

                    pl1 = new PolylineClass();
                    pl2 = new PolylineClass();
                    newpl = new PolylineClass();

                    //if desired subcurve does not cross the start/end point of the closed polyline(circular) then get
                    //a sub curve as normal
                    if ((DistanceFromStart - RangeLeft) >= 0 && (DistanceFromStart + RangeRight) < PolylineLength)
                    {

//.........这里部分代码省略.........
开发者ID:regan-sarwas,项目名称:NPSTransectTool,代码行数:101,代码来源:Utility.cs


注:本文中的IPolyline.QueryPointAndDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。