예제 #1
0
        /// <inheritdoc />
        public MapBoundingBox CalculateBoundingBox(List<MapPoint> pushpins)
        {
            if (pushpins == null || !pushpins.Any())
            {
                throw new ArgumentNullException("pushpins");
            }

            // find the bounding box.
            // South Latitude, lowerst latitude
            // West Longitude, lowerst longitude
            // North Latitude, largest latitide
            // East Longitude. largest longitude
            var firstPin = pushpins[0];
            var minLat = firstPin.Latitude;
            var minLon = firstPin.Longitude;
            var maxLat = firstPin.Latitude;
            var maxLon = firstPin.Longitude;

            foreach (var pushPin in pushpins)
            {
                minLat = minLat > pushPin.Latitude ? pushPin.Latitude : minLat;
                minLon = minLon > pushPin.Longitude ? pushPin.Longitude : minLon;
                maxLat = maxLat < pushPin.Latitude ? pushPin.Latitude : maxLat;
                maxLon = maxLon < pushPin.Longitude ? pushPin.Longitude : maxLon;
            }

            var southWest = new MapPoint(minLat, minLon);
            var northEast = new MapPoint(maxLat, maxLon);

            var boundingBox = new MapBoundingBox(northEast, southWest);

            return boundingBox;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapBoundingBox"/> class.
        /// </summary>
        /// <param name="northEast">The coordinate of the north east of the bounding box.</param>
        /// <param name="southWest">The coordinate of the south west of the bounding box.</param>
        /// <exception cref="ArgumentNullException">When either <paramref name="northEast"/>
        /// or <paramref name="southWest"/> are <b>null</b>.</exception>
        public MapBoundingBox(MapPoint northEast, MapPoint southWest)
        {
            if (northEast == null)
            {
                throw new ArgumentNullException("northEast");
            }

            if (southWest == null)
            {
                throw new ArgumentNullException("southWest");
            }

            this.NorthEast = northEast;
            this.SouthWest = southWest;
        }
        private BingPushpinMetadata GetPushpinMetadata(
            MapPoint coordinate,
            IMapMetadata analyticMapMetadata)
        {
            BingPushpinMetadata selectedPushpin = null;
            foreach (var pin in analyticMapMetadata.Pushpins)
            {
                // index latituide = 0, longitude = 1
                ////if(Math.Abs(pin.point.coordinates[0] - (double)coordinate.Latitude) < TOLERANCE)
                if (pin.BingPointMetadata.Coordinates[0] == (double)coordinate.Latitude
                    && pin.BingPointMetadata.Coordinates[1] == (double)coordinate.Longitude)
                {
                    selectedPushpin = pin;
                    break;
                }
            }

            return selectedPushpin;
        }