Code example for Location

Methods: setLatitudesetLongitude

0
				distanceTwo);
		Log.d(TAG, "BoundingBox bbTwo = " + bbTwo.toString());
	} 
 
	public void testDistance() { 
		Location pointOne = new Location("");
		pointOne.setLongitude(0);
		pointOne.setLatitude(0);
		GeocoordinatesMath.useAngloDistanceUnit(false); 
 
		double expectedRoughDistOne = 14.164743972d;
 
		double pointNumOne = 0.09009009d;
		Location pointDestOne = new Location("");
		pointDestOne.setLatitude(-pointNumOne);
		pointDestOne.setLongitude(-pointNumOne);
		double distOne = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestOne);
		Log.d(TAG, "distanceOne = " + distOne);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistOne, distOne));
 
		Location pointDestTwo = new Location("");
		pointDestTwo.setLongitude(-pointNumOne);
		pointDestTwo.setLatitude(pointNumOne);
 
		double distTwo = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestTwo);
		Log.d(TAG, "distanceTwo = " + distTwo);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistOne, distTwo));
 
		Location pointDestThree = new Location("");
		pointDestThree.setLongitude(pointNumOne);
		pointDestThree.setLatitude(-pointNumOne);
		double distThree = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestThree);
		Log.d(TAG, "distanceThree = " + distThree);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistOne, distThree));
 
		Location pointDestFour = new Location("");
		pointDestFour.setLatitude(pointNumOne);
		pointDestFour.setLongitude(pointNumOne);
 
		double distFour = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestFour);
		Log.d(TAG, "distanceFour = " + distFour);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistOne, distFour));
 
		double expectedRoughDistTwo = 2809.19532927;
		double pointNumTwo = 18.018018018d;
		Location pointDestFive = new Location("");
		pointDestFive.setLongitude(-pointNumTwo);
		pointDestFive.setLatitude(-pointNumTwo);
		double distFive = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestFive);
		Log.d(TAG, "distanceFive = " + distFive);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistTwo, distFive));
 
		Location pointDestSix = new Location("");
		pointDestSix.setLongitude(-pointNumTwo);
		pointDestSix.setLatitude(pointNumTwo);
 
		double distSix = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestSix);
		Log.d(TAG, "distanceSix = " + distSix);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistTwo, distSix));
 
		Location pointDestSeven = new Location("");
		pointDestSeven.setLongitude(pointNumTwo);
		pointDestSeven.setLatitude(-pointNumTwo);
		double distSeven = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestSeven);
		Log.d(TAG, "distanceSeven = " + distSeven);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistTwo, distSeven));
 
		Location pointDestEight = new Location("");
		pointDestEight.setLongitude(pointNumTwo);
		pointDestEight.setLatitude(pointNumTwo);
 
		double distEight = GeocoordinatesMath.calculateDistance(pointOne,
				pointDestEight);
		Log.d(TAG, "distanceEight = " + distEight);
		Assert.assertTrue(isExpectedWithDelta(expectedRoughDistTwo, distEight));
	}