Exemple #1
0
        public LinearLocation[] IndicesOf(Geometry subLine)
        {
            Coordinate startPt =
                ((LineString)subLine.GetGeometry(0)).Coordinates[0];
            LineString lastLine =
                (LineString)subLine.GetGeometry(subLine.NumGeometries - 1);
            Coordinate endPt = lastLine.Coordinates[lastLine.NumPoints - 1];

            LocationIndexOfPoint locPt = new LocationIndexOfPoint(linearGeom);

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

            // check for case where subline is zero length
            if (subLine.Length == 0.0)
            {
                subLineLoc[1] = subLineLoc[0].Clone();
            }
            else
            {
                subLineLoc[1] = locPt.IndexOfAfter(endPt, subLineLoc[0]);
            }

            return(subLineLoc);
        }
Exemple #2
0
        public static LinearLocation IndexOf(Geometry linearGeom,
                                             Coordinate inputPt)
        {
            LocationIndexOfPoint 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));
 }