Exemplo n.º 1
0
 /// <param name="latLong">
 ///            the geographical coordinates of the map center. </param>
 /// <param name="zoomLevel">
 ///            the zoom level of the map. </param>
 /// <exception cref="IllegalArgumentException">
 ///             if {@code latLong} is null or {@code zoomLevel} is negative. </exception>
 public MapPosition(LatLong latLong, sbyte zoomLevel)
 {
     if (latLong == null)
     {
         throw new System.ArgumentException("latLong must not be null");
     }
     else if (zoomLevel < 0)
     {
         throw new System.ArgumentException("zoomLevel must not be negative: " + zoomLevel);
     }
     this.LatLong   = latLong;
     this.ZoomLevel = zoomLevel;
 }
Exemplo n.º 2
0
        public virtual void ContainsLatLongTest()
        {
            BoundingBox boundingBox = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE, MAX_LONGITUDE);
            LatLong     latLong1    = new LatLong(MIN_LATITUDE, MIN_LONGITUDE, true);
            LatLong     latLong2    = new LatLong(MAX_LATITUDE, MAX_LONGITUDE, true);
            LatLong     latLong3    = new LatLong(MIN_LONGITUDE, MIN_LONGITUDE, true);
            LatLong     latLong4    = new LatLong(MAX_LATITUDE, MAX_LATITUDE, true);

            Assert.True(boundingBox.Contains(latLong1));
            Assert.True(boundingBox.Contains(latLong2));
            Assert.False(boundingBox.Contains(latLong3));
            Assert.False(boundingBox.Contains(latLong4));
        }
Exemplo n.º 3
0
        public virtual void EqualsTest()
        {
            LatLong latLong1 = new LatLong(LATITUDE, LONGITUDE, true);
            LatLong latLong2 = new LatLong(LATITUDE, LONGITUDE, true);
            LatLong latLong3 = new LatLong(LATITUDE, LATITUDE, true);
            LatLong latLong4 = new LatLong(LONGITUDE, LONGITUDE, true);

            TestUtils.EqualsTest(latLong1, latLong2);

            TestUtils.NotEqualsTest(latLong1, latLong3);
            TestUtils.NotEqualsTest(latLong1, latLong4);
            TestUtils.NotEqualsTest(latLong1, new object());
            TestUtils.NotEqualsTest(latLong1, null);
        }
Exemplo n.º 4
0
        public virtual void ExtendLatLongTest()
        {
            BoundingBox boundingBox1 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE, MAX_LONGITUDE);
            BoundingBox boundingBox2 = new BoundingBox(MIN_LATITUDE - 1, MIN_LONGITUDE - 1, MAX_LATITUDE, MAX_LONGITUDE);
            BoundingBox boundingBox3 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE + 1, MAX_LONGITUDE + 1);

            Assert.AreEqual(boundingBox1, boundingBox1.ExtendCoordinates(new LatLong(MIN_LATITUDE, MIN_LONGITUDE)));
            Assert.AreEqual(boundingBox2, boundingBox2.ExtendCoordinates(new LatLong(MAX_LATITUDE, MAX_LONGITUDE)));
            Assert.AreEqual(boundingBox3, boundingBox3.ExtendCoordinates(new LatLong(boundingBox3.CenterPoint.Latitude, boundingBox3.CenterPoint.Longitude)));

            LatLong latLong = new LatLong(MIN_LATITUDE - 1, MAX_LONGITUDE + 1);

            Assert.True(boundingBox1.ExtendCoordinates(latLong).Contains(latLong));
            latLong = new LatLong(MAX_LATITUDE + 1, MAX_LONGITUDE + 1);
            Assert.True(boundingBox1.ExtendCoordinates(latLong).Contains(latLong));
            latLong = new LatLong(MAX_LATITUDE + 1, MIN_LONGITUDE - 1);
            Assert.True(boundingBox1.ExtendCoordinates(latLong).Contains(latLong));
            latLong = new LatLong(MIN_LATITUDE - 1, MIN_LONGITUDE - 1);
            Assert.True(boundingBox1.ExtendCoordinates(latLong).Contains(latLong));
        }
Exemplo n.º 5
0
        public virtual void ToStringTest()
        {
            LatLong latLong = new LatLong(LATITUDE, LONGITUDE, true);

            Assert.AreEqual(GEO_POINT_TO_STRING, latLong.ToString());
        }
Exemplo n.º 6
0
        public virtual void SerializeTest()
        {
            LatLong latLong = new LatLong(LATITUDE, LONGITUDE, true);

            TestUtils.SerializeTest(latLong);
        }
Exemplo n.º 7
0
 private static MapPosition invokeConstructor(LatLong latLong, sbyte zoomLevel)
 {
     return(new MapPosition(latLong, zoomLevel));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a BoundingBox extended up to <code>LatLong</code> (but does not cross date line/poles). </summary>
 /// <param name="latLong"> coordinates up to the extension </param>
 /// <returns> an extended BoundingBox or this (if contains coordinates) </returns>
 public virtual BoundingBox ExtendCoordinates(LatLong latLong)
 {
     return(ExtendCoordinates(latLong.Latitude, latLong.Longitude));
 }
Exemplo n.º 9
0
 /// <param name="latLong">
 ///            the LatLong whose coordinates should be checked. </param>
 /// <returns> true if this BoundingBox contains the given LatLong, false otherwise. </returns>
 public virtual bool Contains(LatLong latLong)
 {
     return(Contains(latLong.Latitude, latLong.Longitude));
 }