Exemple #1
0
        public override bool Equals(object unknownObject)
        {
            if (unknownObject is GpsPosition)
            {
                GpsPosition otherPosition = (GpsPosition)unknownObject;

                if (otherPosition.ToString() == this.ToString() &&
                    otherPosition.Time.Ticks == this.Time.Ticks &&
                    otherPosition.Source == this.Source)
                {
                    return(true);
                }
            }

            return(false);
        }
        public static GpsPosition FindCenter(List <GpsPosition> gpsPlaces)
        {
            if (gpsPlaces == null || gpsPlaces.Count == 0)
            {
                throw new Exception("gpsPlaces is NULL or Empty");
            }

            // Calculate Center
            GpsPosition center = new GpsPosition();

            center.Latitude          = new GpsCoordinate();
            center.Latitude.Numeric  = gpsPlaces.Average(x => x.Latitude.Numeric);
            center.Longitude         = new GpsCoordinate();
            center.Longitude.Numeric = gpsPlaces.Average(x => x.Longitude.Numeric);

            return(center);
        }
        public static void FindBounds(List <GpsPosition> gpsPlaces, out GpsPosition topLeft, out GpsPosition bottomRight)
        {
            if (gpsPlaces == null || gpsPlaces.Count == 0)
            {
                throw new Exception("gpsPlaces is NULL or Empty");
            }

            // Calculate Top Left
            topLeft                   = new GpsPosition();
            topLeft.Latitude          = new GpsCoordinate();
            topLeft.Latitude.Numeric  = gpsPlaces.Max(x => x.Latitude.Numeric);
            topLeft.Longitude         = new GpsCoordinate();
            topLeft.Longitude.Numeric = gpsPlaces.Max(x => x.Longitude.Numeric);

            // Calculate Bottom Right
            bottomRight                   = new GpsPosition();
            bottomRight.Latitude          = new GpsCoordinate();
            bottomRight.Latitude.Numeric  = gpsPlaces.Min(x => x.Latitude.Numeric);
            bottomRight.Longitude         = new GpsCoordinate();
            bottomRight.Longitude.Numeric = gpsPlaces.Min(x => x.Longitude.Numeric);
        }