public static IGeometry Project(IGeometry g, IGeometry g2)
 {
     var ll = new LengthIndexedLine(g);
     var index = ll.Project(g2.Coordinate);
     var p = ll.ExtractPoint(index);
     return g.Factory.CreatePoint(p);
 }
 public static double ProjectIndex(IGeometry g, IGeometry g2)
 {
     var ll = new LengthIndexedLine(g);
     return ll.Project(g2.Coordinate);
 }
 public void TestProjectExtractPoint()
 {
     IGeometry linearGeom = Read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))");
     LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
     var index = indexedLine.Project(new Coordinate(1, 0));
     Coordinate pt = indexedLine.ExtractPoint(index);
     Assert.IsTrue(pt.Equals(new Coordinate(0, 0)));
 }
 public void TestComputeZNaN()
 {
     IGeometry linearGeom = Read("LINESTRING (0 0, 10 10 10)");
     LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
     double projIndex = indexedLine.Project(new Coordinate(5, 5));
     Coordinate projPt = indexedLine.ExtractPoint(projIndex);
     Assert.IsTrue(Double.IsNaN(projPt.Z));
 }
 public void TestComputeZ()
 {
     IGeometry linearGeom = Read("LINESTRING (0 0 0, 10 10 10)");
     LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
     double projIndex = indexedLine.Project(new Coordinate(5, 5));
     Coordinate projPt = indexedLine.ExtractPoint(projIndex);
     //    System.out.println(projPt);
     Assert.IsTrue(projPt.Equals3D(new Coordinate(5, 5, 5)));
 }
 public void TestProjectPointWithDuplicateCoords()
 {
     IGeometry linearGeom = Read("LINESTRING (0 0, 10 0, 10 0, 20 0)");
     LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
     double projIndex = indexedLine.Project(new Coordinate(10, 1));
     Assert.IsTrue(projIndex == 10.0);
 }