开发者

Can i get satellites names in android?It shows me in their SNR,PNR,elevation,azimuth but i don't know if the data that it shows me is correct

  package my.pack;

  import java.util.Iterator;

  import android.app.Activity;
  import android.content.Context;
  import android.location.GpsSatellite;
  import android.location.GpsStatus;
  import android.location.GpsStatus.NmeaListener;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.Toast;

  public class SatellitesAct开发者_JAVA百科ivity extends Activity {
LocationManager locMgr;
double lat;
double lon;
  /** Called when the activity is first created. */
  @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

     locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
     MyGpsListener listener = new MyGpsListener();
     MyLocationListener locListener = new MyLocationListener();
     locMgr.addGpsStatusListener(listener);      
     locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
     locMgr.addNmeaListener(new NmeaListener() {

        @Override
        public void onNmeaReceived(long timestamp, String nmea) {
            // TODO Auto-generated method stub
            Log.e("Test!", nmea);
        }
    });

   }



  public class MyGpsListener implements GpsStatus.Listener{
    @Override
    public void onGpsStatusChanged(int event) {
        // TODO Auto-generated method stub
        switch(event){
        case GpsStatus.GPS_EVENT_STARTED:Log.e("Started", "");
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:Log.e("FirstFix", "");
            break;
        case GpsStatus.GPS_EVENT_STOPPED:Log.e("Sopped", "");
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:GpsStatus xGpsStatus = locMgr.getGpsStatus(null) ; 
        Iterable<GpsSatellite> iSatellites = xGpsStatus.getSatellites() ; 
        Iterator<GpsSatellite> it = iSatellites.iterator() ; 
        while ( it.hasNext() ) 
        { 
                GpsSatellite oSat = (GpsSatellite) it.next() ; 
                if(oSat.usedInFix()){
                    Log.e("A fost folosit ", "int fix!");
                }
                if(oSat.toString()!=null){

                    Log.e("Test", "SNR:"+oSat.getSnr()+"; Azimuth:"+oSat.getAzimuth()+"; Elevation:"+oSat.getElevation()+" "+oSat.toString()+"; PRN:"+oSat.getPrn());
                }
        } 
        break ; 


        }
    }
    }

public class MyLocationListener implements LocationListener{

    @Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub

        if(location!=null){
            lat = location.getLatitude();
            lon = location.getLongitude();
            Toast.makeText(getApplicationContext(), ""+lat+"\n"+lon, Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }}

}


Satellites don't really have names that you can grab. The best you can get is the PRN, which your code already shows you getting.

Edit After some more reading, I have found that some people have attempted to map PRN numbers even though sometimes this is incorrect. Try http://www.losangeles.af.mil/shared/media/document/AFD-070530-036.pdf


You could map the PRN number to the satellite name using your own code, based on some reference on the internet (e.g. List of GPS satellites). I'm not aware of any kind of automatic PRN decoding service that decodes the PRN number to a satellite name. Please note that the Department of Defense is free to re-allocate PRN numbers to different satellites when they see fit. So for example, if USA-66 dies tomorrow, they are likely to re-allocate (eventually) another satellite to PRN 32.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜