如何在小数点之前获得经度高达15的数字

mac*_*ch2 0 gps android android-gps

我正在写一个代码,它给了我纬度,经度和地址.但经度和经度在小数点后只显示7个位置,我希望它更准确,即.小数点后最多15个数字请帮助并谢谢以下是我的代码,我通过getLatitude和getLongitude获取价值

final String location = locationText.getText().toString();

            RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
            StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    Toast.makeText(MainActivity.this, "dfdsfsd"+response, Toast.LENGTH_SHORT).show();
                    Log.i("My success",""+response);

                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                    Toast.makeText(MainActivity.this, "my error :"+error, Toast.LENGTH_LONG).show();
                    Log.i("My error",""+error);
                }
            }){
                @Override
                protected Map<String, String> getParams() throws AuthFailureError {

                    Map<String,String> map = new HashMap<String, String>();
                    map.put("locationText",location );



                    return map;
                }
            };
            queue.add(request);

        }
    });


    if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, 101);

    }


    getLocationBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getLocation();
        }
    });
}
private void launchCall() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName(package_name, class_name));
    try {
        startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

void getLocation() {
    try {
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 5, this);
    }
    catch(SecurityException e) {
        e.printStackTrace();
    }
}

@Override
public void onLocationChanged(Location location) {
    locationText.setText("Latitude: " + location.getLatitude() + "\n Longitude: " + location.getLongitude());
    try {
        Geocoder geocoder = new Geocoder(this, Locale.getDefault());
        List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
        locationText.setText(locationText.getText() + "\n"+addresses.get(0).getAddressLine(0)+", "+
                addresses.get(0).getAddressLine(1)+", "+addresses.get(0).getAddressLine(2));
    }catch(Exception e)
    {

    }


}
Run Code Online (Sandbox Code Playgroud)

Com*_*are 5

但经度和经度在小数点后仅显示7个位置

在赤道,纬度和经度均为~111公里.纬度越接近极点越小.

小数点后7位是~111/10000000公里= ~0.0000111公里= ~0.0111米= ~1.11厘米.

即使达到这个水平,GPS也不准确,更不用说15个地方了.

  • 要标记到此 - 您需要了解精度和准确度之间的差异.更多数字是更高的精度.它的准确度并不高.0.2可以比0.1825733920更高的精度.GPS读数的实际准确度作为回调的一部分返回.它将以米为单位给出准确度,并且有67%的可能性在距离它返回的那么多米的范围内.GPS的典型精度为10-20米.网络位置的典型精度为100-1000米. (2认同)