GM_LineString extends GM_CurveSegment implements ILineString { @Override public double[] paramForPoint(IDirectPosition p) { double minDistance = Double.POSITIVE_INFINITY; double minParam = -1; double d = 0; for (int i = 0; i < this.sizeControlPoint() - 1; i++) { IDirectPosition p1 = this.getControlPoint(i); IDirectPosition p2 = this.getControlPoint(i + 1); double param = Operateurs.paramForPoint(p, p1, p2); IDirectPosition point = Operateurs.param(param, p1, p2); double distance = p.distance(point); if (distance < minDistance) { minDistance = distance; minParam = d + param; } d += p1.distance(p2); } return new double[] { minParam }; } GM_LineString(List<IDirectPosition> list, boolean allowRepeated);  GM_LineString(List<IDirectPosition> list);  GM_LineString(IDirectPosition... list);  GM_LineString(IDirectPositionList points);  GM_LineString(IDirectPositionList points, boolean allowRepeated); @Override IDirectPositionList getControlPoint(); @Override IDirectPosition getControlPoint(int i); @Override void setControlPoint(int i, IDirectPosition value); @Override void addControlPoint(IDirectPosition value); void addControlPoint(IDirectPosition value, boolean allowRepeated); @Override void addControlPoint(int i, IDirectPosition value); @Override void removeControlPoint(IDirectPosition value); @Override void removeControlPoint(int i); @Override int sizeControlPoint(); @Override List<ILineSegment> asGM_LineSegment(); @Override IDirectPositionList coord(); @Override ILineString reverse(); @Override boolean isClosed(double tolerance); @Override boolean isClosed(); @Override Object clone(); @Override GM_LineString getNegative(); @Override boolean isLineString(); @Override String getInterpolation(); @Override IDirectPosition param(double s); @Override double[] paramForPoint(IDirectPosition p);  }
@Test public void testParamForPoint() { double param = line1.paramForPoint(new DirectPosition(1, 0.5, 0))[0]; Assert.assertEquals(1.5, param, 0.01); param = curve.paramForPoint(new DirectPosition(1, 0.5, 0))[0]; Assert.assertEquals(1.5, param, 0.01); param = line2.paramForPoint(p5)[0]; Assert.assertEquals(1, param, 0.01); param = curve.paramForPoint(p5)[0]; Assert.assertEquals(4, param, 0.01); }