public void BasicTest() { const double North = 45.45; const double South = -12.12; const double East = 123.123; const double West = -89.89; BoundingBox box = new BoundingBox(); Assert.That(box.IsEmpty, Is.True); box.Expand(North, East); Assert.That(box.IsEmpty, Is.False); box.Expand(South, West); VerifyBounds(box, North, South, East, West); Assert.That(box.Center.Latitude, Is.EqualTo(16.665).Within(0.000001)); Assert.That(box.Center.Longitude, Is.EqualTo(16.6165).Within(0.000001)); }
/// <summary> /// Expands the BoundingBox to include the specified coordinates. /// </summary> /// <param name="bounds">A collection of coordinates to expand the box with.</param> /// <param name="box">The BoundingBox to expand.</param> internal static void ExpandBox(IBoundsInformation bounds, BoundingBox box) { if (bounds != null) { foreach (var coord in bounds.Coordinates) { box.Expand(coord.Latitude, coord.Longitude); } } }
public void TestContains() { double[][] points = { new double[] { 46.3941, 10.1168 }, new double[] { 46.6356, 8.84678 }, new double[] { 46.69, 8.95711 }, new double[] { 46.158, 8.97531 }, new double[] { 46.1719, 8.79744 }, new double[] { 46.1217, 8.35152 }, new double[] { 46.62, 8.5706 }, new double[] { 46.7067, 8.953 }, new double[] { 46.6087, 8.82036 }, new double[] { 46.1546, 8.9633 }, new double[] { 46.2368, 10.1363 }, new double[] { 46.7079, 9.19907 }, new double[] { 45.9296, 8.92094 }, new double[] { 46.1738, 8.84359 }, new double[] { 46.5616, 8.34504 }, new double[] { 46.7389, 8.97314 }, new double[] { 46.7493, 8.23686 }, new double[] { 46.7233, 8.92272 }, new double[] { 45.9528, 8.95471 } }; BoundingBox box = new BoundingBox(); foreach (var point in points) { box.Expand(point[0], point[1]); } VerifyBounds(box, 46.7493, 45.9296, 10.1363, 8.23686); Assert.That(box.Center.Latitude, Is.EqualTo(46.33945).Within(0.000001)); Assert.That(box.Center.Longitude, Is.EqualTo(9.18658).Within(0.000001)); foreach (var point in points) { Assert.True(box.Contains(point[0], point[1])); box.Expand(point[0], point[1]); } }
public void TestExpand() { const double North = 89.123; const double South = -2.222; const double East = -88.888; const double West = -154.6789; BoundingBox box = new BoundingBox(North, South, East, West); BoundingBox other = new BoundingBox(); other.Expand(box); VerifyBounds(box, North, South, East, West); }