Bounding box referenced to WGS 84.
Exemple #1
0
        public static bool IsValid(BoundingBox box)
        {
            bool isntImpossible = (box.North > box.South) && (box.East > box.West);
            bool withinBounds = (box.North <= 90) && (box.South >= -90) && (box.East >= -180) && (box.West <= 180);

            return withinBounds && isntImpossible;
        }
Exemple #2
0
        public static bool IsBlank(BoundingBox box)
        {
            if (box == null)
                return true;

            return box.North == 0 && box.South == 0 && box.East == 0 && box.West == 0;
        }
Exemple #3
0
 public static string ToWkt(BoundingBox box)
 {
     return String.Format("POLYGON(({0:G7} {1:G7},{2:G7} {3:G7},{4:G7} {5:G7},{6:G7} {7:G7},{8:G7} {9:G7}))",
         box.West, box.South,
         box.East, box.South,
         box.East, box.North,
         box.West, box.North,
         box.West, box.South);
 }
Exemple #4
0
        public void should_be_correct_for_one_box_overlapping_the_other()
        {
            var southernIrishSea = new BoundingBox { North = 53.65873m, West = -6.967625m, South = 51.23337m, East = -3.950034m };
            var englishChannel = new BoundingBox { North = 52.065138m, West = -9.793268m, South = 48.264071m, East = 1.939627m };

            var min = BoundingBoxUtility.MinimumOf(new[] { southernIrishSea, englishChannel });

            // the southern irish sea is to the north of the english channel
            // but the english channel spans further to the east and west

            min.North.Should().Be(southernIrishSea.North);
            min.South.Should().Be(englishChannel.South);
            min.East.Should().Be(englishChannel.East);
            min.West.Should().Be(englishChannel.West);
        }
Exemple #5
0
        public void should_be_correct_for_single_box()
        {
            var box = new BoundingBox { North = 21.9259m, West = -63.8981m, South = 17.9476m, East = -60.6832m };

            var min = BoundingBoxUtility.MinimumOf(new[] { box });

            min.North.Should().Be(box.North);
            min.West.Should().Be(box.West);
        }
Exemple #6
0
        public void can_identify_a_valid_bounding_box()
        {
            var englishChannel = new BoundingBox { North = 52.065138m, West = -9.793268m, South = 48.264071m, East = 1.939627m };

            BoundingBoxUtility.IsValid(englishChannel).Should().BeTrue();
        }
Exemple #7
0
        public void can_identify_a_bad_bounding_box_from_real_data()
        {
            var box = new BoundingBox { North = 58.5076m, West = -10.6494m, South = 56.7659m, East = -14.1198m };

            BoundingBoxUtility.IsValid(box).Should().BeFalse();
        }
Exemple #8
0
 public void can_identify_a_blank_box()
 {
     var box = new BoundingBox { North = 0, South = 0, East = 0, West = 0 };
     BoundingBoxUtility.IsBlank(box).Should().BeTrue();
 }
Exemple #9
0
        public void can_identify_an_impossibly_sized_bounding_box()
        {
            var outsideTheWorld = new BoundingBox { North = 10000m, West = -9.793268m, South = 48.264071m, East = 1.939627m };

            BoundingBoxUtility.IsValid(outsideTheWorld).Should().BeFalse();
        }
Exemple #10
0
        public void can_identify_an_impossibly_inverted_bounding_box()
        {
            var englishChannelWithNorthAndSouthInverted = new BoundingBox { North = 48.264071m, West = -9.793268m, South = 52.065138m, East = 1.939627m };

            BoundingBoxUtility.IsValid(englishChannelWithNorthAndSouthInverted).Should().BeFalse();
        }
Exemple #11
0
 public void can_create_correct_wkt()
 {
     var box = new BoundingBox { North = 40, South = 10, East = 60, West = 20 };
     string wkt = BoundingBoxUtility.ToWkt(box);
     wkt.Should().Be("POLYGON((20 10,60 10,60 40,20 40,20 10))");
 }
Exemple #12
0
 public Metadata()
 {
     Keywords = new List<MetadataKeyword>();
     TemporalExtent = new TemporalExtent();
     ResponsibleOrganisation = new ResponsibleParty();
     MetadataPointOfContact = new ResponsibleParty();
     BoundingBox = new BoundingBox();
 }
Exemple #13
0
        void AddTwoRecordsWithTheSameBoundingBox()
        {
            var wales = new BoundingBox { North = 53.98783m, South = 50.92033m, East = -2.919512m, West = -5.682273m };

            var record1 = MakeExampleSeedRecord().With(r =>
            {
                r.Id = new Guid("50749e9a-4df5-4641-81a7-1fea04346be5");
                r.Path = @"X:\path\for\record\with\same\bounding\box\as\another\1";
                r.Gemini = r.Gemini.With(m =>
                {
                    m.Title = "A record with the same bounding box an another (1)";
                    m.BoundingBox = wales;
                });
                r.Gemini.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/some-vocab", Value = "Bounding boxes" });
            });

            var record2 = MakeExampleSeedRecord().With(r =>
            {
                r.Id = new Guid("6a969b7f-18e8-4e96-b0ea-371d8e2ba774");
                r.Path = @"X:\path\for\record\with\same\bounding\box\as\another\2";
                r.Gemini = r.Gemini.With(m =>
                {
                    m.Title = "A record with the same bounding box an another (2)";
                    m.BoundingBox = wales;
                });
                r.Gemini.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/some-vocab", Value = "Bounding boxes" });
            });

            recordService.Insert(record1);
            recordService.Insert(record2);
        }