예제 #1
0
 /// <summary>
 /// Densifies a coordinate sequence.
 /// </summary>
 /// <param name="pts">The coordinate sequence to densify</param>
 /// <param name="distanceTolerance">The distance tolerance (<see cref="DistanceTolerance"/>)</param>
 /// <param name="precModel">The precision model to apply on the new coordinates</param>
 /// <returns>The densified coordinate sequence</returns>
 private static Coordinate[] DensifyPoints(Coordinate[] pts,
                                            double distanceTolerance, IPrecisionModel precModel)
 {
     var seg = new LineSegment();
     var coordList = new CoordinateList();
     for (int i = 0; i < pts.Length - 1; i++)
     {
         seg.P0 = pts[i];
         seg.P1 = pts[i + 1];
         coordList.Add(seg.P0, false);
         double len = seg.Length;
         int densifiedSegCount = (int) (len/distanceTolerance) + 1;
         if (densifiedSegCount > 1)
         {
             double densifiedSegLen = len/densifiedSegCount;
             for (int j = 1; j < densifiedSegCount; j++)
             {
                 double segFract = (j*densifiedSegLen)/len;
                 var p = seg.PointAlong(segFract);
                 precModel.MakePrecise(p);
                 coordList.Add(p, false);
             }
         }
     }
     coordList.Add(pts[pts.Length - 1], false);
     return coordList.ToCoordinateArray();
 }
 private static Tuple<Coordinate, double> Interpolate(double m1, double measure, double m2, LineSegment segment)
 {
     var measureFraction = (measure - m1) / (m2 - m1);
     return Tuple.Create(segment.PointAlong(measureFraction), measure);
 }