A struct that has a latitude and longitude, stored as doubles.
        public void Include_with_included_coordinate_must_not_extend_the_region(MapRegion originalRegion, Position position)
        {
            var region = originalRegion.Clone();
            region.Include(position);

            region.Should().Be(originalRegion);
        }
示例#2
0
 /// <summary>
 /// Discribes a rectangular region. This region usually encloses a set of geometries or represents a area of view.
 /// </summary>
 /// <param name="center">Center of the bounding box</param>
 /// <param name="width">Width of bounding box in degress</param>
 /// <param name="height">Height of bounding box in degress</param>
 public MapRegion(Position center, double width, double height)
     : this(
           center.Longitude - width/2, 
           center.Latitude + height/2, 
           center.Longitude + width/2,
           center.Latitude - height/2)
 {
 }
        public void Include_with_excluded_coordinate_must_extend_the_region(MapRegion originalRegion, Position position)
        {
            var region = originalRegion.Clone();
            region.Include(position);

            region.Should().NotBe(originalRegion);

            region.Contains(position).Should().BeTrue("the new region should containt the included position now");
            originalRegion.Contains(position).Should().BeFalse("the old region should not include the position");
        }
示例#4
0
        /// <summary>
        /// Discribes a rectangular region. This region usually encloses a set of geometries or represents a area of view.
        /// </summary>
        /// <param name="minX">Mininium X value (longitude), left most coordinate.</param>
        /// <param name="maxY">Maximium Y value (laitude), northern most coordinate.</param>
        /// <param name="maxX">Maximium X value (longitude), right most coordinate.</param>
        /// <param name="minY">Minimium Y value (latitude), southern most coordinate.</param>
        public MapRegion(double minX, double maxY, double maxX, double minY)
        {
            var lminX = ClampWidth(Math.Min(minX, maxX));
            var lmaxX = ClampWidth(Math.Max(minX, maxX));

            var lminY = ClampHeight(Math.Min(minY, maxY));
            var lmaxY = ClampHeight(Math.Max(minY, maxY));

            _topLeft = new Position(lmaxY, lminX);
            _bottomRight = new Position(lminY, lmaxX);

            RecalculateDimensionsAndCenter();
        }
示例#5
0
 /// <summary>
 /// Discribes a rectangular region. This region usually encloses a set of geometries or represents a area of view.
 /// </summary>
 /// <param name="topLeft">The top left coordinates of the bounding box.</param>
 /// <param name="bottomRight">The bottom right coordinate of the bounding box.</param>
 public MapRegion(Position topLeft, Position bottomRight)
     : this( topLeft.Longitude, topLeft.Latitude, bottomRight.Longitude, bottomRight.Latitude )
 {
 }
示例#6
0
        private void RecalculateDimensionsAndCenter()
        {
            _width = MaxX + Math.Abs(MinX);
            _height = MaxY + Math.Abs(MinY);

            _center = new Position(_height/2, _width/2);
        }
示例#7
0
 public bool Contains(Position position) => position.Longitude >= MinX && position.Longitude <= MaxX && 
                                            position.Latitude >= MinY && position.Latitude <= MaxY;
示例#8
0
        public void Include(Position item)
        {
            if (Contains(item) == false)
            {
                var lMinX = Math.Min(MinX, item.Longitude);
                var lMaxX = Math.Max(MaxX, item.Longitude);

                var lMinY = Math.Min(MinY, item.Latitude);
                var lMaxY = Math.Max(MaxY, item.Latitude);

                var newRegion = new MapRegion(lMinX, lMaxY, lMaxX, lMinY);
                _topLeft = newRegion._topLeft;
                _bottomRight = newRegion._bottomRight;

                RecalculateDimensionsAndCenter();
            }
        }