Example #1
0
        public override bool IsPointClose(Coordonnees toCheck, double precision)
        {
            for (int i = 0; i < Coordonnees.Count() - 1; i++)
            {
                if (ZZMath.GetDistancePointToLine((ZZCoordinate)Coordonnees[i], (ZZCoordinate)Coordonnees[i + 1], (ZZCoordinate)toCheck) < precision)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        /*
         * public bool IsPointClose_BoundingBox(Coordonnees toCheck, double precision)
         * {
         *  if (IsValid()) {
         *      double max_X = Coordonnees[0].Latitude, max_Y = Coordonnees[0].Longitude, min_X = Coordonnees[0].Latitude, min_Y = Coordonnees[0].Longitude;
         *
         *      for (int i = 1; i < NbPoints; i++) {
         *          if (Coordonnees[i].Latitude > max_X) max_X = Coordonnees[i].Latitude;
         *          else if (Coordonnees[i].Latitude < min_X) min_X = Coordonnees[i].Latitude;
         *          if (Coordonnees[i].Longitude > max_Y) max_Y = Coordonnees[i].Longitude;
         *          else if (Coordonnees[i].Longitude < min_Y) min_Y = Coordonnees[i].Longitude;
         *      }
         *
         *      if (toCheck.Latitude > min_X - precision && toCheck.Latitude < max_X + precision) {
         *          if (toCheck.Longitude > min_Y - precision && toCheck.Longitude < max_Y + precision) {
         *              return true;
         *          }
         *      }
         *  }
         *  return false;
         * }
         */

        public override bool IsPointClose(Coordonnees toCheck, double precision)
        {
            if (IsValid())
            {
                // return Extend(precision).IsPointInside(toCheck);
                // Or, more precise:
                if (!IsPointInside(toCheck))
                {
                    for (int i = 0; i < NbPoints; i++)
                    {
                        if (ZZMath.GetDistancePointToLine((ZZCoordinate)Coordonnees[i], (ZZCoordinate)Coordonnees[(i + 1) % NbPoints], (ZZCoordinate)toCheck) < precision)
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }