Beispiel #1
0
 //根据线的方向获取其更新的位置
 private void GetFromPointMovepointChangeLocation(IPolyline line, double distance, ref IPoint point, ref IPolyline retureline)
 {
     try
     {
         IPolyline[] pLines     = new IPolyline[2];
         IPolyline   pSplitLine = new PolylineClass();
         pSplitLine = line;
         IPolyline StarttoPointLine = new PolylineClass();
         IPolyline EndtoPointLine   = new PolylineClass();
         bool      splithappened;
         int       partindex, segmentindex;
         object    pObject = Type.Missing;
         pSplitLine.SplitAtDistance(distance, false, false, out splithappened, out partindex, out segmentindex);
         ISegmentCollection lineSegCol  = pSplitLine as ISegmentCollection;
         ISegmentCollection startSegCol = StarttoPointLine as ISegmentCollection;
         ISegmentCollection endSegCol   = EndtoPointLine as ISegmentCollection;
         for (int i = 0; i < segmentindex; i++)
         {
             startSegCol.AddSegment(lineSegCol.get_Segment(i), ref pObject, ref pObject);
         }
         for (int j = segmentindex; j < lineSegCol.SegmentCount; j++)
         {
             endSegCol.AddSegment(lineSegCol.get_Segment(j), ref pObject, ref pObject);
         }
         pLines[0]  = endSegCol as IPolyline;
         pLines[1]  = startSegCol as IPolyline;
         point      = new PointClass();
         point      = pLines[0].FromPoint;
         retureline = pLines[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "/n" + ex.ToString(), "异常");
     }
 }
        public void CanTest2SegmentCircle()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTest2SegmentCircle");

            IFeature row1 = fc.CreateFeature();

            IConstructCircularArc arc = new CircularArcClass();

            arc.ConstructCircle(GeometryFactory.CreatePoint(0, 0, 0), 3, false);

            IPolyline polyline = CreatePolyLine((ISegment)arc);

            int  segmentIndex;
            int  newPartIndex;
            bool splitHappened;

            polyline.SplitAtDistance(0.5, true, false,
                                     out splitHappened,
                                     out newPartIndex,
                                     out segmentIndex);
            Assert.True(splitHappened);

            row1.Shape = polyline;
            row1.Store();

            var test = new QaMinSegAngle(fc, 0.1, true);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            // assert that two segment closed curve does not always report two
            // errors when using linearized segments
            Assert.AreEqual(0, runner.Errors.Count);
        }
Beispiel #3
0
 //根据距离切割线段,获取切割的点和切割后尾段
 public void GetPointSplitAtDistance(IPolyline InputLine, double distance, ref IPolyline retureLine, ref IPoint returePoint)
 {
     try
     {
         IPolyline[] pLines     = new IPolyline[2];
         IPolyline   pSplitLine = new PolylineClass();
         pSplitLine = InputLine;
         IPolyline StarttoPointLine = new PolylineClass();
         IPolyline EndtoPointLine   = new PolylineClass();
         bool      splithappened;
         int       partindex, segmentindex;
         object    pObject = Type.Missing;
         pSplitLine.SplitAtDistance(distance, false, false, out splithappened, out partindex, out segmentindex);
         ISegmentCollection lineSegCol  = pSplitLine as ISegmentCollection;
         ISegmentCollection startSegCol = StarttoPointLine as ISegmentCollection;
         ISegmentCollection endSegCol   = EndtoPointLine as ISegmentCollection;
         for (int i = 0; i < segmentindex; i++)
         {
             startSegCol.AddSegment(lineSegCol.get_Segment(i), ref pObject, ref pObject);
         }
         for (int j = segmentindex; j < lineSegCol.SegmentCount; j++)
         {
             endSegCol.AddSegment(lineSegCol.get_Segment(j), ref pObject, ref pObject);
         }
         pLines[0]   = endSegCol as IPolyline;
         pLines[1]   = startSegCol as IPolyline;
         returePoint = new PointClass();
         bool asRatio = false;
         pLines[1].QueryPoint(esriSegmentExtension.esriNoExtension, pLines[1].Length / 2, asRatio, returePoint);
         retureLine = pLines[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }