Operateurs { public static IDirectPosition projection(IDirectPosition m, IDirectPosition a, IDirectPosition b) { Vecteur ab = new Vecteur(a, b); boolean to2d = Double.isNaN(m.getZ()) || Double.isNaN(a.getZ()) || Double.isNaN(b.getZ()); if (to2d) { ab.setZ(Double.NaN); } if (ab.norme() == 0) { return a; } Vecteur u_ab = ab.vectNorme(); Vecteur am = new Vecteur(a, m); if (to2d) { am.setZ(Double.NaN); } double lambda = am.prodScalaire(u_ab); if (lambda <= 0) { return a; } if (lambda >= (to2d ? a.distance2D(b) : a.distance(b))) { return b; } return Operateurs.translate(a, u_ab.multConstante(lambda)); }  static double paramForPoint(IDirectPosition m, IDirectPosition a, IDirectPosition b); static IDirectPosition param(double param, IDirectPosition a, IDirectPosition b); static IDirectPosition projection(IDirectPosition m, IDirectPosition a, IDirectPosition b); static IDirectPosition projection(IDirectPosition dp, ILineString ls); static ILineString projectionEtInsertion(IDirectPosition point, ILineString line); static void projectAndInsert(IDirectPosition point, List<IDirectPosition> points); static int projectAndInsertWithPosition(IDirectPosition point, List<IDirectPosition> points); static void projectAndInsertAll(IDirectPosition point, List<IDirectPosition> points); static IDirectPosition projection(IDirectPosition dp, IAggregate<IGeometry> aggr); static IDirectPosition pointEnAbscisseCurviligne(ILineString ls, double abscisse); static IDirectPosition pointEnAbscisseCurviligne(IMultiCurve<? extends ILineString> multiLs,
			double abscisse); static double abscisseCurviligne(ILineString ls, int i); static IDirectPosition milieu(ILineString ls); static IDirectPosition milieu(IDirectPosition A, IDirectPosition B); static IDirectPositionList premiersPoints(ILineString ls, double longueur); static IDirectPositionList derniersPoints(ILineString ls, double longueur); static IDirectPosition barycentre2D(IPolygon poly); static ILineString directOffset(ILineString ls, double offset); static ILineString indirectOffset(ILineString ls, double offset); static ILineString echantillone(ILineString ls, double pas); static ILineString echantilloneSansPreservation(ILineString ls, double pas); static ILineString echantillonePasVariable(ILineString ls, double pas); static IDirectPosition translate(IDirectPosition P, Vecteur V); static ILineString compileArcs(List<ILineString> geometries); static ILineString compileArcs(List<ILineString> geometries, double tolerance); static ILineString compileArcs(Collection<ILineString> geometries, double tolerance); static IGeometry intersectionRobuste(IGeometry A, IGeometry B, double min, double max); static IGeometry unionRobuste(IGeometry A, IGeometry B, double min, double max); static Angle directionPrincipale(IDirectPositionList listePts); static Angle directionPrincipaleOrientee(IDirectPositionList listePts); static boolean superposes(IDirectPosition pt1, IDirectPosition pt2); static boolean superposes2D(IDirectPosition pt1, IDirectPosition pt2); static boolean superposes(IPoint pt1, IPoint pt2); static int indice2D(IDirectPositionList dpl, IDirectPosition dp); static int indice3D(IDirectPositionList dpl, IDirectPosition dp); static ILineString calculeZ(ILineString ligne); @SuppressWarnings("unchecked") static void fusionneSurfaces(IPopulation<? extends IFeature> pop); static void bufferSurfaces(IPopulation<IFeature> popSurf, double tailleBuffer); static double surface(IPolygon poly); static double surface(IDirectPositionList pts); static IPolygon surfaceFromLineStrings(ILineString lineString1, ILineString lineString2); static boolean sensDirect(IDirectPositionList pts); static ILineString union(List<ILineString> linestringList); static ILineString union(List<ILineString> linestringList, double tolerance); static int insertionIndex(IDirectPosition point, List<IDirectPosition> points); static ILineString resampling(ILineString ls, double maxDistance); static IDirectPositionList resampling(IDirectPositionList list, double maxDistance);  }
@Test public void testProjectionIDirectPositionIDirectPositionIDirectPosition() { IDirectPosition projection1 = Operateurs.projection(this.point3, this.point1, this.point2); Assert.assertTrue(projection1.equals(this.point1)); IDirectPosition projection2 = Operateurs.projection(this.point4, this.point1, this.point2); Assert.assertTrue(projection2.equals(this.point1)); IDirectPosition projection3 = Operateurs.projection(this.point5, this.point1, this.point2); Assert.assertTrue(projection3.equals(new DirectPosition(2, 0))); IDirectPosition projection4 = Operateurs.projection(this.point6, this.point1, this.point2); Assert.assertTrue(projection4.equals(this.point2)); IDirectPosition projection5 = Operateurs.projection(this.point7, this.point1, this.point2); Assert.assertTrue(projection5.equals(this.point2)); }
@Test public void testProjectionIDirectPositionILineString() { IDirectPosition projection1 = Operateurs .projection(this.point3, this.line1); Assert.assertTrue(projection1.equals(this.point1)); IDirectPosition projection2 = Operateurs .projection(this.point4, this.line1); Assert.assertTrue(projection2.equals(this.point1)); IDirectPosition projection3 = Operateurs .projection(this.point5, this.line1); Assert.assertTrue(projection3.equals(new DirectPosition(2, 0))); IDirectPosition projection4 = Operateurs .projection(this.point6, this.line1); Assert.assertTrue(projection4.equals(this.point2)); IDirectPosition projection5 = Operateurs .projection(this.point7, this.line1); Assert.assertTrue(projection5.equals(this.point2)); }