public static bool IsPointCloseAB(Coordonnees coords, Coordonnees pointA, Coordonnees pointB, double precision) { Debug.Log("[CartoObj][IsPointCloseAB]"); //1 tester si le point recherché est proche de A ou de B ? if (pointA.IsPointClose(coords, precision)) { return(true); } if (pointB.IsPointClose(coords, precision)) { return(true); } //2 si le point recherché n'est pas proche du point A ou B, --> tester s'il est proche de la droite //recherche des max et min sur l'axe des x et y double maxLat, minLat, maxLong, minLong; //maxLat if (pointA.Latitude > pointB.Latitude) { maxLat = pointA.Latitude; } else { maxLat = pointB.Latitude; } //minLat if (pointA.Latitude < pointB.Latitude) { minLat = pointA.Latitude; } else { minLat = pointB.Latitude; } //maxLong if (pointA.Longitude > pointB.Longitude) { maxLong = pointA.Longitude; } else { maxLong = pointB.Longitude; } //minLong if (pointA.Longitude < pointB.Longitude) { minLong = pointA.Longitude; } else { minLong = pointB.Longitude; } //cas d'une droite verticale if (pointA.Latitude == pointB.Latitude) { if (coords.Longitude <= maxLong && coords.Longitude >= minLong) { double differenceLatitude; differenceLatitude = Math.Abs(pointA.Latitude - coords.Latitude); if (differenceLatitude <= precision) { return(true); } else { return(false); } } else { return(false); } } //cas d'une droite horizontale if (pointA.Longitude == pointB.Longitude) { if (coords.Latitude <= maxLat && coords.Latitude >= minLat) { double differenceLongitude; differenceLongitude = Math.Abs(pointA.Longitude - coords.Longitude); if (differenceLongitude <= precision) { return(true); } else { return(false); } } else { return(false); } } //cas d'une droite oblique //y = mx +p double m = (pointB.Longitude - pointA.Longitude) / (pointB.Latitude - pointA.Latitude); double p = pointA.Longitude - (m * pointA.Latitude); Coordonnees pointDeLaDroite = new Coordonnees(); for (double x = minLat; x <= maxLat; x += precision) { double y = m * x + p; pointDeLaDroite.Latitude = x; pointDeLaDroite.Longitude = y; if (pointDeLaDroite.IsPointClose(coords, precision)) { return(true); } } //si on arrive ici c'est que le point n'est pas proche de la droite AB return(false); }
//Vérifie si la coordonnée reçue en paramètre est proche du Polygon selon la précisoin donnée public override bool IsPointClose(Coordonnees coorTmp, double precision) { if (!Coordonnees.Any()) { return(false); } else if (Coordonnees.Count < 2) { if (MathUtil.Dist2Points(Coordonnees[0].Latitude, Coordonnees[0].Longitude, coorTmp.Latitude, coorTmp.Longitude) <= precision) { return(true); } else { return(false); } } double x0, y0, x1, x2, y1, y2; x0 = coorTmp.Latitude; y0 = coorTmp.Longitude; for (int i = 0; i < Coordonnees.Count - 1; i++) { x1 = Coordonnees[i].Latitude; y1 = Coordonnees[i].Longitude; x2 = Coordonnees[i + 1].Latitude; y2 = Coordonnees[i + 1].Longitude; if (MathUtil.Dist2Points(x1, y1, x0, y0) <= precision) { return(true); } if (MathUtil.Dist2Points(x2, y2, x0, y0) <= precision) { return(true); } if (MathUtil.DistPointSeg(x1, y1, x2, y2, x0, y0) <= precision) { return(true); } } x1 = Coordonnees[0].Latitude; y1 = Coordonnees[0].Longitude; x2 = Coordonnees[Coordonnees.Count - 1].Latitude; y2 = Coordonnees[Coordonnees.Count - 1].Longitude; if (MathUtil.DistPointSeg(x1, y1, x2, y2, x0, y0) <= precision) { return(true); } if (InBoundingBox(coorTmp)) { return(true); } return(false); }
public void Add(Coordonnees coordonneeToAdd) { Coordonnees.Add(coordonneeToAdd); }
public bool IsPointClose(Coordonnees coordonneesPoint, double precision) { return(true); }
public static bool DistanceLignePoint(Coordonnees c1, Coordonnees c2, Coordonnees c, double precision) { double a, x, y, b; double d = precision; bool ret_val = false; Coordonnees tmp; if (c2.Latitude < c1.Latitude || c2.Longitude < c1.Longitude) { //Console.WriteLine("J'echange Collection[i] et Collection[i+1]"); tmp = c1; c1 = c2; c2 = tmp; } //Console.WriteLine("c1.lat = " + c1.Latitude + " c1.long = " + c1.Longitude + " c2.lat = " + c2.Latitude + " c2.long = " + c2.Longitude); //Console.WriteLine("c.lat = " + c.Latitude + " c.long = " + c.Longitude + " precision = " + precision); if (c1.Latitude == c2.Latitude) //Les 2 coordonnees ont la même longitude { //Console.WriteLine("c1.lat == c2.lat"); if (c.Longitude < c1.Longitude) { //Console.WriteLine("c.long < c1.long"); ret_val = Pythagore(c1.Latitude, c1.Longitude, c, precision); return(ret_val); } else { if (c.Longitude > c2.Longitude) { //Console.WriteLine("c.long > c2.long"); ret_val = Pythagore(c2.Latitude, c2.Longitude, c, precision); return(ret_val); } else { //Console.WriteLine("c2 est entre la ligne"); --> car la pente est égale a null d = Math.Abs(c1.Latitude - c.Latitude); if (d <= precision) { return(true); } else { return(false); } } } } else { if (c1.Longitude == c2.Longitude) //Les 2 coordonnees ont la même latitude { //Console.WriteLine("c1.long == c2.long"); if (c.Latitude < c1.Latitude) { //Console.WriteLine("c.lat < c1.lat"); ret_val = Pythagore(c1.Latitude, c1.Longitude, c, precision); return(ret_val); } else { if (c.Latitude > c2.Latitude) { //Console.WriteLine("c.lat > c2.lat"); ret_val = Pythagore(c2.Latitude, c2.Longitude, c, precision); return(ret_val); } else { //Console.WriteLine("c est entre la ligne"); --> car la pente est égale a null d = Math.Abs(c1.Longitude - c.Longitude); if (d <= precision) { return(true); } else { return(false); } } } } else //Les 2 points n'ont pas la même longitude ou latitude { if (c.Latitude < c1.Latitude || c.Longitude < c1.Longitude) { //Console.WriteLine("le point est < que les coordonnees"); ret_val = Pythagore(c1.Latitude, c1.Longitude, c, precision); return(ret_val); } else { if (c.Latitude > c2.Latitude || c.Latitude > c.Longitude) { //Console.WriteLine("le point est > que les coordonnees"); ret_val = Pythagore(c2.Latitude, c2.Longitude, c, precision); return(ret_val); } else { //Console.WriteLine("le point est entre les 2 coordonnees"); a = (c2.Longitude - c1.Longitude) / (c2.Latitude - c1.Latitude); y = c1.Longitude; x = c1.Latitude; b = -(a * x) + y; //Console.WriteLine("a = " + a + " b = " + b + " x = " + x + " y = " + y); b = -b; a = -a; //Console.WriteLine("a = " + a + " x0 = " + c.Latitude + " b = 1" + " y0 = " + c.Longitude + " c = " + b); d = Math.Abs((a * c.Latitude + 1 * c.Longitude + b) / Math.Sqrt(Math.Pow(a, 2) + Math.Pow(1, 2))); //Console.WriteLine("d = " + d); if (d <= precision) { return(true); } else { return(false); } } } } } }
public abstract bool IsPointClose(Coordonnees clickCoord, double precision);
public POI(string newDescription, Coordonnees newCoordonnees) : base(newCoordonnees.Latitude, newCoordonnees.Longitude) { Description = newDescription; }
public static bool Pythagore(double Latitude, double Longitude, Coordonnees c, double precision) { double a, b, d; //Console.WriteLine("Lat = " + Latitude + " long = " + Longitude + " c.lat = " + c.Latitude + " c.long = " + c.Longitude); //Console.WriteLine("precision = " + precision); if (Longitude == c.Longitude) { //Console.WriteLine("long == c2.long"); d = Math.Abs(Latitude - c.Latitude); if (d < precision) { return(true); } else { return(false); } } else { if (Latitude == c.Latitude) { //Console.WriteLine("lat == c2.lat"); d = Math.Abs(Longitude - c.Longitude); if (d < precision) { return(true); } else { return(false); } } else { //Console.WriteLine("pythagore"); if (Longitude > c.Longitude) { a = Math.Abs(Longitude) - Math.Abs(c.Longitude); } else { a = Math.Abs(c.Longitude) - Math.Abs(Longitude); } if (Latitude > c.Latitude) { b = Math.Abs(Latitude) - Math.Abs(c.Latitude); } else { b = Math.Abs(c.Latitude) - Math.Abs(Latitude); } //Console.WriteLine("a = " + a + " b = " + b); d = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2)); //Console.WriteLine("d = " + d); if (d <= precision) { return(true); } else { return(false); } } } }
public override bool IsPointClose(Location locTmp, double precision) { Coordonnees coorTmp = new Coordonnees(locTmp.Latitude, locTmp.Longitude); return(this.IsPointClose(coorTmp, precision)); }
public POI(string newDescription, Coordonnees newCoordonnees) : base(newCoordonnees.Latitude, newCoordonnees.Longitude) { Debug.Log("[POI][Constructeur]newDescription,newCoordonnees"); Description = newDescription; }
public static Coordonnees operator *(Coordonnees c1, Coordonnees c2) { Coordonnees cT = new Coordonnees(c1.Longitude * c2.Longitude, c1.Latitude * c2.Latitude); return(cT); }
public Coordonnees(Coordonnees copie) : this(copie.Latitude, copie.Longitude) { }
public override bool IsPointClose(Coordonnees toCheck, double precision) { return(ZZMath.GetDistance((ZZCoordinate)toCheck, (ZZCoordinate)this) < precision); }