Android Open Source - WhatsUp Geo Point Util 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   www .ja v  a 2s .c  o m
import nu.placebo.whatsup.util.GeoPointUtil;
import android.test.AndroidTestCase;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;

public class GeoPointUtilTest extends AndroidTestCase {

  public GeoPointUtilTest() {
    super();
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
  }

  public void testConvertAreaToDoubles() {
    double[] d = { 1.0, 2.0, 3.0, 4.0 };
    double[] e = GeoPointUtil.convertAreaToDoubles(new GeoPoint(1000000,
        2000000), new GeoPoint(3000000, 4000000));
    assertEquals(d[0], e[0]);
    assertEquals(d[1], e[1]);
    assertEquals(d[2], e[2]);
    assertEquals(d[3], e[3]);
  }

  public void testConvertFlippedAreaToDoubles() {
    /*
     * Same as above, but geopoints are relatively oriented with a SE-NW
     * bearing (instead of NE-SW where one point is less in both
     * attributes.)
     * Should give the same result.
     */

    double[] d = { 1.0, 2.0, 3.0, 4.0 };
    double[] e = GeoPointUtil.convertAreaToDoubles(new GeoPoint(1000000,
        4000000), new GeoPoint(3000000, 2000000));
    assertEquals(d[0], e[0]);
    assertEquals(d[1], e[1]);
    assertEquals(d[2], e[2]);
    assertEquals(d[3], e[3]);
  }

  public void testConvertGeoPointToDoubles() {
    double[] a = { 1.0, 1.0 };
    double[] b = GeoPointUtil.convertGeoPointToDoubles(new GeoPoint(
        1000000, 1000000));
    assertEquals(a[0], b[0]);
    assertEquals(a[1], b[1]);
  }

  public void testGetBottomLeftToTopRightPoints() {
    GeoPoint bl = new GeoPoint(0, 0);
    GeoPoint tr = new GeoPoint(10, 10);
    GeoPoint[] gp = GeoPointUtil.getBottomLeftToTopRightPoints(
        new GeoPoint(5, 5), 10, 10);
    assertEquals(bl.getLatitudeE6(), gp[0].getLatitudeE6());
    assertEquals(bl.getLongitudeE6(), gp[0].getLongitudeE6());
    assertEquals(tr.getLatitudeE6(), gp[1].getLatitudeE6());
    assertEquals(tr.getLongitudeE6(), gp[1].getLongitudeE6());
  }

  public void testPushGeoPoint() {
    Bundle b = GeoPointUtil.pushGeoPoint(new GeoPoint(1000000, 1000000));
    
    assertEquals(b.get("lat"), 1000000);
    assertEquals(b.get("long"), 1000000);
  }

  public void testPopGeoPoint() {
    Bundle b = GeoPointUtil.pushGeoPoint(new GeoPoint(1000000, 1000000));
    GeoPoint p = GeoPointUtil.popGeoPoint(b);
    
    assertEquals(1000000, p.getLatitudeE6());
    assertEquals(1000000, p.getLongitudeE6());
  }

  public void testBundleHasGeoPoint() {
    Bundle b = GeoPointUtil.pushGeoPoint(new GeoPoint(1000000, 1000000));
    
    assertTrue(GeoPointUtil.bundleHasGeoPoint(b));
  }
}




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