The Elevation service provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values). In those cases where Google does not possess exact elevation measurements at the precise location you request, the service will interpolate and return an averaged value using the four nearest locations.
		public void GetElevationForTwoLocations()
		{
			// expectations
			var expectedStatus = ServiceResponseStatus.Ok;
			var expectedResultCount = 2;

			var expectedElevation1 = 1608.6m;
			var expectedLocation1 = new LatLng(39.739153,-104.984703);
			var expectedElevation2 = -50.789m;
			var expectedLocation2 = new LatLng(36.4555560,-116.8666670);

			// test
			var request = new ElevationRequest();

			request.AddLocations(expectedLocation1, expectedLocation2);
			request.Sensor = false;
			var response = new ElevationService().GetResponse(request);

			// asserts
			Assert.AreEqual(expectedStatus, response.Status);

			Assert.AreEqual(expectedResultCount, response.Results.Length);
			
			Assert.That(expectedElevation1, Is.EqualTo(response.Results[0].Elevation).Within(0.1));
			Assert.That(expectedLocation1, Is.EqualTo(response.Results[0].Location));
			
			Assert.That(expectedElevation2, Is.EqualTo(response.Results[1].Elevation).Within(0.1));
			Assert.That(expectedLocation2, Is.EqualTo(response.Results[1].Location));
		}
        public void GetElevationForTwoLocations()
        {
            // expectations
            var expectedStatus      = ServiceResponseStatus.Ok;
            var expectedResultCount = 2;

            var expectedElevation1 = 1608.6m;
            var expectedLocation1  = new LatLng(39.739153, -104.984703);
            var expectedElevation2 = -50.789m;
            var expectedLocation2  = new LatLng(36.4555560, -116.8666670);

            // test
            var request = new ElevationRequest();

            request.AddLocations(expectedLocation1, expectedLocation2);
            var response = new ElevationService().GetResponse(request);

            // asserts
            Assert.AreEqual(expectedStatus, response.Status);

            Assert.AreEqual(expectedResultCount, response.Results.Length);

            Assert.That(expectedElevation1, Is.EqualTo(response.Results[0].Elevation).Within(0.1));
            Assert.That(expectedLocation1, Is.EqualTo(response.Results[0].Location));

            Assert.That(expectedElevation2, Is.EqualTo(response.Results[1].Elevation).Within(0.1));
            Assert.That(expectedLocation2, Is.EqualTo(response.Results[1].Location));
        }
        public void GetElevationForOneLocation()
        {
            // expectations
            var expectedStatus      = ServiceResponseStatus.Ok;
            var expectedResultCount = 1;
            var expectedElevation   = 1608.6m;
            var expectedLocation    = new LatLng(39.739153, -104.984703);

            // test
            var request = new ElevationRequest();

            request.AddLocations(expectedLocation);
            var response = new ElevationService().GetResponse(request);

            // asserts
            Assert.AreEqual(expectedStatus, response.Status);
            Assert.AreEqual(expectedResultCount, response.Results.Length);

            Assert.That(expectedElevation, Is.EqualTo(response.Results[0].Elevation).Within(0.1));

            Assert.That(expectedLocation, Is.EqualTo(response.Results[0].Location));
        }
		public void GetElevationForOneLocation()
		{
			// expectations
			var expectedStatus = ServiceResponseStatus.Ok;
			var expectedResultCount = 1;
			var expectedElevation = 1608.6m;
			var expectedLocation = new LatLng(39.739153, -104.984703);
			
			// test
			var request = new ElevationRequest();

			request.AddLocations(expectedLocation);
			request.Sensor = false;
			var response = new ElevationService().GetResponse(request);

			// asserts
			Assert.AreEqual(expectedStatus, response.Status);
			Assert.AreEqual(expectedResultCount, response.Results.Length);

			Assert.That(expectedElevation, Is.EqualTo(response.Results[0].Elevation).Within(0.1));
			
			Assert.That(expectedLocation, Is.EqualTo(response.Results[0].Location));
		}
Esempio n. 5
0
        ElevationService CreateService()
        {
            var svc = new ElevationService(TestingApiKey);

            return(svc);
        }