Android Open Source - android-gps-test-tool Draw Circle






From Project

Back to project page android-gps-test-tool.

License

The source code is released under:

Apache License ? 2.0 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by...

If you think the Android project android-gps-test-tool 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 com.agup.gps.utils;
/*from w  w  w . j  av a  2 s . c o  m*/
import java.util.Map;

import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.Polygon;

import android.graphics.Point;

public class DrawCircle {
  
  public DrawCircle(){
    
  }
  
  public void createMercatorCircle(double radius, Point center){
    double lon1 = degToRad(center.x);
    double lat1 = degToRad(center.y);
    double R_KM = 6371; //radius km
    double R_MI = 3963; //radius mi
    //double d = radius/R_KM; //angular distance on earth's surface
    double d = radius/R_MI;
    
    Polygon circle = new Polygon();
    int nodes = 100; //number of nodes in circle
    int step = Math.round(360/nodes);
    int n = 0;
    double[] pointArray;
    
    for(int x = 0; x <= 360; x++){
      int z = Math.round(n+=step);
      double bearing = degToRad(x);
      
      double lat2 = Math.asin(
          Math.sin(lat1) * Math.cos(d) +
          Math.cos(lat1) * Math.sin(d) * Math.cos(bearing)
      );
      
      double lon2 = lon1 + Math.atan2(
          Math.sin(bearing) * Math.sin(d) * Math.cos(lat1), 
          Math.cos(d) - Math.sin(lat1) * Math.sin(lat2)
      );
      
      //pointArray[x] = GeometryEngine.project(x, y, sr)
    }
  }
  
  public static double radToDeg(double radians){
    return radians * 180 / Math.PI;
  }
  
  public static double degToRad(double degrees){
    return degrees * Math.PI / 180;
  }
  
}




Java Source Code List

com.agup.gps.GPSTesterActivity.java
com.agup.gps.SatelliteDataActivity.java
com.agup.gps.SettingsActivity.java
com.agup.gps.controllers.GPSTesterActivityController.java
com.agup.gps.controllers.SatelliteDataActivityController.java
com.agup.gps.fragments.GPSAlertDialogFragment.java
com.agup.gps.fragments.NetworkAlertDialogFragment.java
com.agup.gps.utils.CheckConnectivity.java
com.agup.gps.utils.DrawCircle.java
com.agup.gps.utils.ElapsedTimer.java
com.agup.gps.utils.Preferences.java