Esempio n. 1
0
        public void TestPointInRadiusMethod(string lat1, string lon1, string insideoutside, string lat2, string lon2, string radius)
        {
            var checkedPoint = new GeoCoordinations()
            {
                latitude  = Convert.ToDouble(lat1),
                longitude = Convert.ToDouble(lon1)
            };

            var centerPoint = new GeoCoordinations()
            {
                latitude  = Convert.ToDouble(lat2),
                longitude = Convert.ToDouble(lon2)
            };

            var result = centerPoint.Contains(checkedPoint, Convert.ToDouble(radius));

            Assert.AreEqual((insideoutside == "inside"), result);
        }
Esempio n. 2
0
        /// <summary>
        /// Zjistí, zda se nějaký autobus DPMB zadané linky nachází v okruhu zadaného místa
        /// </summary>
        /// <param name="dpmbSubscriber"></param>
        /// <param name="buses"></param>
        /// <returns></returns>
        public static async Task <List <DpmbRisObject> > WatchDpmbLine(DpmbSubscriber dpmbSubscriber, List <DpmbRisObject> buses)
        {
            List <DpmbRisObject> result = new List <DpmbRisObject>();

            foreach (DpmbRisObject bus in buses)
            {
                var busLocation = new GeoCoordinations()
                {
                    latitude  = bus.latitude,
                    longitude = bus.longitude
                };
                if (dpmbSubscriber.centerPoint.Contains(busLocation, dpmbSubscriber.radius))
                {
                    result.Add(bus);
                }
            }

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Checks if specified point is in specified radius within this point.
 /// </summary>
 /// <param name="centerPoint">This point (center of radius)</param>
 /// <param name="checkedPoint">Checked point (discover is point is inside or outside radius)</param>
 /// <param name="radius">Radius in meters</param>
 /// <returns></returns>
 public static bool Contains(this GeoCoordinations centerPoint, GeoCoordinations checkedPoint, double radius)
 {
     return(GetDistance(centerPoint.latitude, centerPoint.longitude, checkedPoint.latitude, checkedPoint.longitude) < radius);
 }