2012-01-13 12 views
1

緯度、経度1〜2の建物を離れて正確な緯度と経度を取得していません。1〜2メートルの精度現在の場所の緯度と経度の値です。これはコードです現在地の緯度と経度の値を1〜2メートルの精度で取得する方法

public class GPSLocatorActivity extends MapActivity implements OnClickListener { 
MapView mapView = null; 
MapController mapController = null; 
MyLocationOverlay whereAmI = null; 
private Button bdiffaddr, bnext; 
MyLocation myLocation; 
GeoPoint p = null; 
MapController mc = null; 
public static LocationManager locManager; 
protected ProgressDialog progressDialog; 
public static double latitude, longitude; 
public String TAG = "GPSLocatorActivity"; 

protected boolean isLocationDisplayed() { 
    return whereAmI.isMyLocationEnabled(); 
} 
protected boolean isRouteDisplayed() { 
    return false; 
} 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.gpslocation); 
    initialiseviews(); 
    // onclick listeners 
    onclicklisteners(); 
    currentLocLatLong(); 
    // new GoogleMapAsyncTask().execute(); 
    GPSLocatorActivity.this.runOnUiThread(new Runnable() { 
     public void run() { 
      mapView = (MapView) findViewById(R.id.mapView); 
      mapView.setBuiltInZoomControls(true); 
      mapController = mapView.getController(); 
      mapController.setZoom(15); 
      whereAmI = new MyLocationOverlay(GPSLocatorActivity.this, 
        mapView); 
      mapView.getOverlays().add(whereAmI); 
      mapView.postInvalidate(); 
     } 
    }); 

} 
public class GoogleMapAsyncTask extends AsyncTask<Void, Void, Void> { 
    protected Void doInBackground(Void... voids) { 
     mapView = (MapView) findViewById(R.id.mapView); 
     mapView.setBuiltInZoomControls(true); 
     mapController = mapView.getController(); 
     mapController.setZoom(15); 
     whereAmI = new MyLocationOverlay(GPSLocatorActivity.this, mapView); 
     mapView.getOverlays().add(whereAmI); 
     mapView.postInvalidate(); 
     return null; 
    } 

} 
private void currentLocLatLong() { 
    locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100L, 
      100.0f, locationListener); 
    Location location = locManager 
      .getLastKnownLocation(LocationManager.GPS_PROVIDER); 
    if (location != null) { 
     latitude = location.getLatitude(); 
     longitude = location.getLongitude(); 
    } 
} 
private void updateWithNewLocation(Location location) { 
     String latLongString = ""; 
    Log.d("Lat: + latitude + \nLong: + longitude", "Lat:" + latitude 
      + "\nLong:" + longitude); 
    if (location != null) { 
     latitude = location.getLatitude(); 
     longitude = location.getLongitude(); 
     latLongString = "Lat:" + latitude + "\nLong:" + longitude; 
    } else { 
     latLongString = "No location found"; 
    } 
} 
public void onResume() { 
    super.onResume(); 
    whereAmI.enableMyLocation(); 
    whereAmI.runOnFirstFix(new Runnable() { 
     public void run() { 
      mapController.setCenter(whereAmI.getMyLocation()); 
     } 
    }); 

} 
public void onPause() { 
    super.onPause(); 
    whereAmI.disableMyLocation(); 
} 
public void onLocationChanged(Location location) { 
    if (location != null) { 
     latitude = location.getLatitude(); 
     longitude = location.getLongitude(); 
     @SuppressWarnings("unused") 
     String currentLocation = "Lat: " + latitude + " Lng: " + longitude; 
     // txted.setText(currentLocation); 
     p = new GeoPoint((int) latitude * 1000000, 
       (int) longitude * 1000000); 
     mc.animateTo(p); 
    } 
} 
public final LocationListener locationListener = new LocationListener() { 
    public void onLocationChanged(Location location) { 
     updateWithNewLocation(location); 
    } 
    public void onProviderDisabled(String provider) { 
     updateWithNewLocation(null); 
    } 
    public void onProviderEnabled(String provider) { 
    } 
    public void onStatusChanged(String provider, int status, Bundle extras) { 
    } 
}; 

please help if anyone has idea how to get the accuracy upto one or two meter distance. 

答えて

2

申し訳ありませんが、プログラミングによって精度を上げることはできません。より多くの衛星を受信するか、より良いGPSハードウェアまたは拡張システム(航空を使用するWAASなど)を使用することによって精度が向上します。さらに、受信は、建物の外で、そして衛星への直接視線内の障害から離れている方が良い。

は、あなたが受けているどのように多くの衛星を決定するには、ここを見て: https://stackoverflow.com/a/8747795/1127492

ところで、2メートルはかなり困難です。精度の詳細については、こちらをご覧ください:http://www.gps.gov/systems/gps/performance/accuracy/#difference