/// <summary>
        ///
        /// </summary>
        /// <param name="subLine"></param>
        /// <returns></returns>
        public virtual LinearLocation[] IndicesOf(IGeometry subLine)
        {
            var startPt  = ((ILineString)subLine.GetGeometryN(0)).GetCoordinateN(0);
            var lastLine = (ILineString)subLine.GetGeometryN(subLine.NumGeometries - 1);
            var endPt    = lastLine.GetCoordinateN(lastLine.NumPoints - 1);

            var locPt      = new LocationIndexOfPoint(_linearGeom);
            var subLineLoc = new LinearLocation[2];

            subLineLoc[0] = locPt.IndexOf(startPt);

            // check for case where subline is zero length
            if (subLine.Length == 0)
            {
                subLineLoc[1] = (LinearLocation)subLineLoc[0].Copy();
            }
            else
            {
                subLineLoc[1] = locPt.IndexOfAfter(endPt, subLineLoc[0]);
            }
            return(subLineLoc);
        }
Beispiel #2
0
        public static LinearLocation IndexOfAfter(IGeometry linearGeom, Coordinate inputPt, LinearLocation minIndex)
        {
            var locater = new LocationIndexOfPoint(linearGeom);

            return(locater.IndexOfAfter(inputPt, minIndex));
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="linearGeom"></param>
        /// <param name="inputPt"></param>
        /// <returns></returns>
        public static LinearLocation IndexOf(IGeometry linearGeom, Coordinate inputPt)
        {
            var locater = new LocationIndexOfPoint(linearGeom);

            return(locater.IndexOf(inputPt));
        }
 /// <summary>
 /// Computes the index for the closest point on the line to the given point.
 /// If more than one point has the closest distance the first one along the line is returned.
 /// (The point does not necessarily have to lie precisely on the line.)
 /// </summary>
 /// <param name="pt">A point on the line.</param>
 /// <returns>The index of the point.</returns>
 public LinearLocation Project(Coordinate pt)
 {
     return(LocationIndexOfPoint.IndexOf(_linearGeom, pt));
 }
 ///<summary>
 /// Finds the index for a point on the line which is greater than the given index.
 /// If no such index exists, returns <paramref name="minIndex" />.
 ///</summary>
 /// <remarks>
 /// <para>
 /// This method can be used to determine all indexes for
 /// a point which occurs more than once on a non-simple line.
 /// It can also be used to disambiguate cases where the given point lies
 /// slightly off the line and is equidistant from two different
 /// points on the line.
 /// </para>
 /// <para>
 /// The supplied point does not <i>necessarily</i> have to lie precisely
 /// on the line, but if it is far from the line the accuracy and
 /// performance of this function is not guaranteed.
 /// Use <see cref="Project"/> to compute a guaranteed result for points
 /// which may be far from the line.
 /// </para>
 /// </remarks>
 /// <param name="pt">A point on the line</param>
 /// <param name="minIndex">The value the returned index must be greater than</param>
 /// <returns>The index of the point greater than the given minimum index</returns>
 /// <seealso cref="Project(Coordinate)"/>
 public LinearLocation IndexOfAfter(Coordinate pt, LinearLocation minIndex)
 {
     return(LocationIndexOfPoint.IndexOfAfter(_linearGeom, pt, minIndex));
 }