Android Open Source - WhatsUp Geodetics Test






From Project

Back to project page WhatsUp.

License

The source code is released under:

GNU General Public License

If you think the Android project WhatsUp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package nu.placebo.whatsuptest.utiltest;
//from ww w.  ja  va 2  s.c o m
import com.google.android.maps.GeoPoint;

import nu.placebo.whatsup.util.Geodetics;
import android.test.AndroidTestCase;

public class GeodeticsTest extends AndroidTestCase {

  public GeodeticsTest() {
    super();
  }

  public void setUp() throws Exception {

    super.setUp();
  }

  public void testPresentMeterPrecision() {
    double hundredmeters = 100.4;

    String result = Geodetics.distanceWithUnit(hundredmeters);
    assertEquals("100.4 returns 100 m", "100 m", result);

  }

  public void testPresentKMeterPrecision() {
    double nearlyKm = -999.7;
    /*
     * should auto-negate the value to show a positive distance.
     */

    String result = Geodetics.distanceWithUnit(nearlyKm);

    assertEquals("999.7 returns 1000 m", "1.0 km", result);
  }

  public void testPresentFarLimit() {
    /*
     * The far limit is 1000 km exclusive, which may present 999.9 km.
     * 1000.0 km should thus never be displayed.
     */

    double nearlyFar = 999970.0;

    String result = Geodetics.distanceWithUnit(nearlyFar);

    assertEquals("999.970 m returns far away", "Very far away", result);
  }

  public void testDistanceOne() {
    GeoPoint a = new GeoPoint(55000000, 12000000);
    GeoPoint b = new GeoPoint(55000009, 12000000);

    double distance = Math.round(Geodetics.distance(a, b));

    assertEquals("Distance should be 1 meter", 1.0, distance);
  }

  public void testDistanceEquator() {
    /*
     * Testing one degree at equator
     */

    GeoPoint a = new GeoPoint(0, 12000000);
    GeoPoint b = new GeoPoint(0, 13000000);

    double distance = Math.round(Geodetics.distance(a, b) / 100);
    /*
     * Tolerate within 100 m
     */

    assertEquals("Equator:", 1112.0, distance);

  }

  public void testDistanceFarNorth() {
    /*
     * Testing one degree very far north
     */
    GeoPoint a = new GeoPoint(80000000, 12000000);
    GeoPoint b = new GeoPoint(80000000, 12020000);

    double distance = Math.round(Geodetics.distance(a, b));
    /*
     * Tolerate within 100 m
     */
    
    assertEquals("Far north", 386.0, distance);
  }
  
  public void testTwoGeoPoints(){
    
    GeoPoint brunnsparken = new GeoPoint(57706704,11968081);
    GeoPoint nordstan = new GeoPoint(57709240, 11970747);
    
    String distance1 = Geodetics.distanceWithUnit(brunnsparken, nordstan);
    
    assertEquals("Less to more", "323 m", distance1);
    
    String distance2 = Geodetics.distanceWithUnit(nordstan, brunnsparken);
    
    assertEquals("More to less", distance1, distance2);
  }
}




Java Source Code List

nu.placebo.whatsup.activity.AnnotationActivity.java
nu.placebo.whatsup.activity.CreateAnnotationActivity.java
nu.placebo.whatsup.activity.CreateCommentActivity.java
nu.placebo.whatsup.activity.ListViewActivity.java
nu.placebo.whatsup.activity.LogInActivity.java
nu.placebo.whatsup.activity.LoginRegTabActivity.java
nu.placebo.whatsup.activity.MapViewActivity.java
nu.placebo.whatsup.activity.Marker.java
nu.placebo.whatsup.activity.MenuHelper.java
nu.placebo.whatsup.activity.PositionPickerActivity.java
nu.placebo.whatsup.activity.RefPointActivity.java
nu.placebo.whatsup.activity.RegisterActivity.java
nu.placebo.whatsup.android.os.AsyncTask.java
nu.placebo.whatsup.balloon.BalloonItemizedOverlay.java
nu.placebo.whatsup.balloon.BalloonOverlayView.java
nu.placebo.whatsup.constants.Constants.java
nu.placebo.whatsup.ctrl.SessionHandler.java
nu.placebo.whatsup.datahandling.DataProvider.java
nu.placebo.whatsup.datahandling.DataReturnListener.java
nu.placebo.whatsup.datahandling.DataReturn.java
nu.placebo.whatsup.datahandling.DatabaseConnectionLayer.java
nu.placebo.whatsup.datahandling.DatabaseHelper.java
nu.placebo.whatsup.model.Annotation.java
nu.placebo.whatsup.model.Comment.java
nu.placebo.whatsup.model.ExtendedOverlayItem.java
nu.placebo.whatsup.model.GeoLocation.java
nu.placebo.whatsup.model.ListMarker.java
nu.placebo.whatsup.model.ReferencePoint.java
nu.placebo.whatsup.model.SessionInfo.java
nu.placebo.whatsup.network.AbstractNetworkOperation.java
nu.placebo.whatsup.network.Action.java
nu.placebo.whatsup.network.AnnotationCreate.java
nu.placebo.whatsup.network.AnnotationRetrieve.java
nu.placebo.whatsup.network.CommentCreate.java
nu.placebo.whatsup.network.GeoLocationsRetrieve.java
nu.placebo.whatsup.network.Login.java
nu.placebo.whatsup.network.NetworkCalls.java
nu.placebo.whatsup.network.NetworkOperationListener.java
nu.placebo.whatsup.network.NetworkOperation.java
nu.placebo.whatsup.network.NetworkTask.java
nu.placebo.whatsup.network.OperationResult.java
nu.placebo.whatsup.network.RegisterOperation.java
nu.placebo.whatsup.network.SessionTest.java
nu.placebo.whatsup.util.GeoPointUtil.java
nu.placebo.whatsup.util.Geodetics.java
nu.placebo.whatsup.util.ValidationUtil.java
nu.placebo.whatsuptest.TestStarter.java
nu.placebo.whatsuptest.activitytest.AnnotationActivityTest.java
nu.placebo.whatsuptest.activitytest.ListViewActivityTest.java
nu.placebo.whatsuptest.activitytest.MapViewActivityTest.java
nu.placebo.whatsuptest.networktest.NetworkTest.java
nu.placebo.whatsuptest.utiltest.GeoPointUtilTest.java
nu.placebo.whatsuptest.utiltest.GeodeticsTest.java
nu.placebo.whatsuptest.utiltest.ValidationTest.java