久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='CslSl'></bdo><ul id='CslSl'></ul>

      <tfoot id='CslSl'></tfoot>
    1. <small id='CslSl'></small><noframes id='CslSl'>

      <legend id='CslSl'><style id='CslSl'><dir id='CslSl'><q id='CslSl'></q></dir></style></legend>
    2. <i id='CslSl'><tr id='CslSl'><dt id='CslSl'><q id='CslSl'><span id='CslSl'><b id='CslSl'><form id='CslSl'><ins id='CslSl'></ins><ul id='CslSl'></ul><sub id='CslSl'></sub></form><legend id='CslSl'></legend><bdo id='CslSl'><pre id='CslSl'><center id='CslSl'></center></pre></bdo></b><th id='CslSl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CslSl'><tfoot id='CslSl'></tfoot><dl id='CslSl'><fieldset id='CslSl'></fieldset></dl></div>
    3. 獲取緯度和經度的小數點后十二位

      Get twelve digits after decimal for latitude and longitude(獲取緯度和經度的小數點后十二位)
      <tfoot id='yIO8W'></tfoot>

        • <legend id='yIO8W'><style id='yIO8W'><dir id='yIO8W'><q id='yIO8W'></q></dir></style></legend>
          • <i id='yIO8W'><tr id='yIO8W'><dt id='yIO8W'><q id='yIO8W'><span id='yIO8W'><b id='yIO8W'><form id='yIO8W'><ins id='yIO8W'></ins><ul id='yIO8W'></ul><sub id='yIO8W'></sub></form><legend id='yIO8W'></legend><bdo id='yIO8W'><pre id='yIO8W'><center id='yIO8W'></center></pre></bdo></b><th id='yIO8W'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yIO8W'><tfoot id='yIO8W'></tfoot><dl id='yIO8W'><fieldset id='yIO8W'></fieldset></dl></div>

              <bdo id='yIO8W'></bdo><ul id='yIO8W'></ul>
                <tbody id='yIO8W'></tbody>

              <small id='yIO8W'></small><noframes id='yIO8W'>

              1. 本文介紹了獲取緯度和經度的小數點后十二位的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個應用程序,我必須從緯度和經度中獲取用戶的當前位置.對于這兩個值,我必須得到小數點后 12 位.

                I have an application in which I have to get user's current location from latitude and longitude. For both the values, I have to get 12 digits after decimal.

                這是用于獲取用戶位置的 gps 跟蹤器類:

                This is the gps tracker class for getting the user location:

                public class GPSTracker extends Service implements LocationListener {
                
                    private final Context mContext;
                
                    // flag for GPS status
                    boolean isGPSEnabled = false;
                
                    // flag for network status
                    boolean isNetworkEnabled = false;
                
                    // flag for GPS status
                    boolean canGetLocation = false;
                
                    Location location; // location
                    double latitude; // latitude
                    double longitude; // longitude
                    private String locationUsing;
                
                    // The minimum distance to change Updates in meters
                    private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
                
                    // The minimum time between updates in milliseconds
                    private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
                
                    // Declaring a Location Manager
                    protected LocationManager locationManager;
                
                    public GPSTracker(Context context) {
                        this.mContext = context;
                        getLocation();
                    }
                
                    public Location getLocation() {
                        try {
                            locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);
                
                            // getting GPS status
                            isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
                
                            // getting network status
                            isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
                
                            if (!isGPSEnabled && !isNetworkEnabled) 
                            {
                                // no network provider and GPS is enabled
                                Log.d("No GPS & Network", "no network provider and GPS is enabled");
                            } 
                
                            else 
                            {
                                this.canGetLocation = true;
                //==================================================================================================================
                //First it will try to get Location using GPS if it not going to get GPS 
                //then it will get Location using Tower Location of your network provider
                //==================================================================================================================
                
                                // if GPS Enabled get lat/long using GPS Services
                                if (isGPSEnabled) 
                                {
                                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                                    Log.d("GPS", "Get loc using GPS");
                                    if (locationManager != null) 
                                    {
                                        Log.d("locationManager", "locationManager not null");
                                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                                        if (location != null) 
                                        {
                                            Log.d("location", "location Not null");
                                            latitude  = location.getLatitude();
                                            longitude = location.getLongitude();
                                            setLocationUsing("GPS");
                                        }
                                    }
                                }
                                //if GPS is Off then get lat/long using Network
                                if (isNetworkEnabled) 
                                {                   
                                    if (location == null) 
                                    {
                                        Log.d("Network", "Get loc using Network");
                                        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                
                                        if (locationManager != null) 
                                        {
                                            location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                                            if (location != null) 
                                            {
                                                latitude = location.getLatitude();
                                                longitude = location.getLongitude();
                                                setLocationUsing("Network");
                                            }
                                        }
                                    }
                                }
                
                            }
                
                        } 
                        catch (Exception e) 
                        {
                            e.printStackTrace();
                        }
                
                        return location;
                    }
                
                    /**
                     * Stop using GPS listener
                     * Calling this function will stop using GPS in your app
                     * */
                    /*public void stopUsingGPS()
                    {
                        if(locationManager != null)
                        {
                            locationManager.removeUpdates(GPSTracker.this);
                        }       
                    }*/
                
                    /**
                     * Function to get latitude
                     * */
                    public double getLatitude()
                    {
                        if(location != null)
                        {
                            latitude = location.getLatitude();
                        }
                
                        // return latitude
                        return latitude;
                    }
                
                    /**
                     * Function to get longitude
                     * */
                    public double getLongitude()
                    {
                        if(location != null)
                        {
                            longitude = location.getLongitude();
                        }
                
                        // return longitude
                        return longitude;
                    }
                
                    /**
                     * Function to check GPS/Network enabled
                     * @return boolean
                     * */
                    public boolean canGetLocation() {
                        return this.canGetLocation;
                    }
                
                    /**
                     * Function to show settings alert dialog
                     * On pressing Settings button will launch Settings Options
                     * */
                    public void showSettingsAlert(){
                        AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
                
                        // Setting Dialog Title
                        alertDialog.setTitle("GPS is settings");
                
                        // Setting Dialog Message
                        alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
                
                        // On pressing Settings button
                        alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,int which) {
                                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                mContext.startActivity(intent);
                            }
                        });
                
                        // on pressing cancel button
                        alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                            }
                        });
                
                        // Showing Alert Message
                        alertDialog.show();
                    }
                
                    @Override
                    public void onLocationChanged(Location location) {
                    }
                
                    @Override
                    public void onProviderDisabled(String provider) {
                    }
                
                    @Override
                    public void onProviderEnabled(String provider) {
                    }
                
                    @Override
                    public void onStatusChanged(String provider, int status, Bundle extras) {
                    }
                
                    @Override
                    public IBinder onBind(Intent arg0) {
                        return null;
                    }
                
                    public String getLocationUsing() {
                        return locationUsing;
                    }
                
                    void setLocationUsing(String locationUsing) {
                        this.locationUsing = locationUsing;
                    }
                }
                

                這是我從中訪問 GPSTracker 類的服務類:

                This is the service class from which I am accessing the GPSTracker class:

                public class MyAlarmService extends Service {
                
                        String device_id;
                    // GPSTracker class
                       GPSTracker gps;
                
                       String date_time;
                
                       String lat_str;
                       String lon_str;
                
                       static String response_str=null;
                        static String response_code=null;
                @Override
                public void onCreate() {
                 // TODO Auto-generated method stub
                    //Toast.makeText(this, "Service created", Toast.LENGTH_LONG).show();
                
                    //---get a Record---
                
                    }
                
                @Override
                public IBinder onBind(Intent intent) {
                 // TODO Auto-generated method stub
                 //Toast.makeText(this, "MyAlarmService.onBind()", Toast.LENGTH_LONG).show();
                 return null;
                }
                
                @Override
                public void onDestroy() {
                 // TODO Auto-generated method stub
                 super.onDestroy();
                 //this.stopSelf();
                 //Toast.makeText(this, "Service Destroyed.", Toast.LENGTH_LONG).show();
                }
                
                @Override
                public void onStart(Intent intent, int startId) {
                 // TODO Auto-generated method stub
                 super.onStart(intent, startId);
                
                 //Toast.makeText(this, "Service Started.", Toast.LENGTH_LONG).show();
                
                
                //create class object
                
                 gps = new GPSTracker(this);
                
                     // check if GPS enabled        
                     if(gps.canGetLocation())
                     {
                
                
                
                        //double latitude = gps.getLatitude();
                        double latitude = gps.getLatitude();
                        double longitude =gps.getLongitude();
                        String locationUsing = gps.getLocationUsing();
                
                        makeAToast("Latitude: "+latitude+", "+" Longitude: "+longitude);
                
                         final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
                
                         String deviceid = tm.getDeviceId();
                
                
                
                
                         Date formattedDate = new Date(System.currentTimeMillis());
                
                         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.US);
                
                         date_time = sdf.format(formattedDate);
                
                
                         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
                         final String part_id=preferences.getString("Part_Id","");
                
                         final String Tracker = preferences.getString("Tracker_enabled","");
                
                        lat_str=""+latitude;
                        lon_str=""+longitude;
                
                
                        if(haveNetworkConnection())
                        {
                            if (Tracker.contains("true"))
                            {
                
                            Log.i("Tracker value: ", Tracker);  
                            sendPostRequest(part_id,deviceid,lat_str,lon_str,date_time);
                            }
                        }
                        else
                        {
                            //Toast.makeText( getApplicationContext(),"No Internet connection or Wifi available",Toast.LENGTH_LONG).show();
                        }
                     }
                     else
                     {
                        // GPS or Network is not enabled
                        Toast.makeText(getApplicationContext(), "No Network or GPS", Toast.LENGTH_LONG).show();
                     }
                }
                
                @Override
                public boolean onUnbind(Intent intent) {
                 // TODO Auto-generated method stub
                 // Toast.makeText(this, "Service binded", Toast.LENGTH_LONG).show();
                 return super.onUnbind(intent);
                }
                
                //=======================================================================================================
                //check packet data and wifi
                //=======================================================================================================
                private boolean haveNetworkConnection() 
                {
                    boolean haveConnectedWifi = false;
                    boolean haveConnectedMobile = false;
                
                    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
                    for (NetworkInfo ni : netInfo) 
                    {
                        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
                            if (ni.isConnected())
                                haveConnectedWifi = true;
                        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
                            if (ni.isConnected())
                                haveConnectedMobile = true;
                    }
                    return haveConnectedWifi || haveConnectedMobile;
                }
                //=======================================================================================================
                    //checking packet data and wifi END
                    //=======================================================================================================
                
                
                //sending async post request---------------------------------------------------------------------------------------
                    private void sendPostRequest(final String part_id, final String device_id,final String lat,final String lon, final String status_datetime) {
                
                        class SendPostReqAsyncTask extends AsyncTask<String, Void, String>{
                
                            @Override
                            protected String doInBackground(String... params) {
                
                                String result = "";
                                HttpClient hc = new DefaultHttpClient();
                                String message;
                
                                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MyAlarmService.this);
                                  final String url_first = preferences.getString("URLFirstPart","");
                
                
                                HttpPost p = new HttpPost(url_first+"SetTrakerLatLon");
                                JSONObject object = new JSONObject();
                
                                try {
                                    object.put("PartId",part_id);
                                    object.put("DeviceId",device_id);
                                    object.put("Lat", lat);
                                    object.put("Lon", lon);
                                    object.put("DateTime", status_datetime);
                
                                } catch (Exception ex) {
                
                                }
                
                                try {
                                message = object.toString();
                
                                p.setEntity(new StringEntity(message, "UTF8"));
                                p.setHeader("Content-type", "application/json");
                                    HttpResponse resp = hc.execute(p);
                
                                    response_code=""+ resp.getStatusLine().getStatusCode();
                
                                        InputStream inputStream = resp.getEntity().getContent();
                                        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                                        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                                        StringBuilder stringBuilder = new StringBuilder();
                                        String bufferedStrChunk = null;
                
                                        while((bufferedStrChunk = bufferedReader.readLine()) != null){
                                            stringBuilder.append(bufferedStrChunk);
                                        }
                
                                        response_str= stringBuilder.toString();
                
                                        Log.i("Tracker Response: ",response_str);
                
                
                
                
                
                                    if (resp != null) {
                                        if (resp.getStatusLine().getStatusCode() == 204)
                                            result = "true";
                
                
                                    }
                
                
                                } catch (Exception e) {
                                    e.printStackTrace();
                
                
                                }
                
                                return result;
                
                            }
                
                            @Override
                            protected void onPostExecute(String result) {
                                super.onPostExecute(result);
                
                
                
                
                            }           
                        }
                
                        SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
                        sendPostReqAsyncTask.execute();     
                    }
                
                
                    //-----------------------------------------------------------------------------------------------
                
                
                
                //public void sendDataToServer(String time, String date) {
                public void sendDataToServer(String deviceid,String date_time,String latitude,String longitude) {
                    // TODO Auto-generated method stub
                
                
                    try {
                        HttpClient client = new DefaultHttpClient();  
                        String postURL = "http://192.168.1.60/trackme/trackservice.svc/SetLatLon?";
                        HttpPost post = new HttpPost(postURL); 
                            List<NameValuePair> params = new ArrayList<NameValuePair>();
                            params.add(new BasicNameValuePair("mobileId", deviceid));
                            params.add(new BasicNameValuePair("lat", latitude));
                            params.add(new BasicNameValuePair("lon", longitude));
                            params.add(new BasicNameValuePair("udate", date_time));
                            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
                            post.setEntity(ent);
                            Log.i("URL: ",EntityUtils.toString(ent));
                            HttpResponse responsePOST = client.execute(post);  
                            HttpEntity resEntity = responsePOST.getEntity();  
                            if (resEntity != null) {    
                                Log.i("RESPONSE",EntityUtils.toString(resEntity));
                            }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                
                private StringBuilder inputStreamToString(InputStream is) {
                String line="";
                StringBuilder total=new StringBuilder();
                BufferedReader buf=new BufferedReader(new InputStreamReader(is));
                try {
                    while ((line=buf.readLine())!=null) {
                        total.append(line); 
                    }
                } catch (Exception e) {
                    // TODO: handle exception
                    makeAToast("Cannot connect to server from your device");
                }
                return total;
                }
                
                //to display a toast in case of message
                    public void makeAToast(String str) {
                        //yet to implement
                        Toast toast = Toast.makeText(this,str, Toast.LENGTH_SHORT);
                        toast.setGravity(Gravity.CENTER, 0, 0);
                        toast.show();
                    }
                
                
                }
                

                目前,經度和緯度都得到小數點后 4 位數字.我應該怎么做才能在緯度和經度值之后獲得 12 位數字?

                Currently I am getting 4 digits after decimal for both latitude and longitude. What should I do to get 12 digits after latitude and longitude values?

                推薦答案

                用十進制度量度時,逗號后不必取 12 位,這是常用的表示法.這不是任何人做的.

                You do not have to get 12 digits after comma when measuring in decimal degrees, which is the common representation. It is not being done by any one.

                7 位在毫米范圍內.

                12 位是千分之一毫米.

                12 digits is a ten thousandth of a millimeter.

                保留 7 位數字,也可以表示為整數.

                Stay with 7 digits, which can be represented as integer too.

                這篇關于獲取緯度和經度的小數點后十二位的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)

                <tfoot id='Orftg'></tfoot>
                  <tbody id='Orftg'></tbody>

                • <legend id='Orftg'><style id='Orftg'><dir id='Orftg'><q id='Orftg'></q></dir></style></legend>
                  <i id='Orftg'><tr id='Orftg'><dt id='Orftg'><q id='Orftg'><span id='Orftg'><b id='Orftg'><form id='Orftg'><ins id='Orftg'></ins><ul id='Orftg'></ul><sub id='Orftg'></sub></form><legend id='Orftg'></legend><bdo id='Orftg'><pre id='Orftg'><center id='Orftg'></center></pre></bdo></b><th id='Orftg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Orftg'><tfoot id='Orftg'></tfoot><dl id='Orftg'><fieldset id='Orftg'></fieldset></dl></div>

                    • <small id='Orftg'></small><noframes id='Orftg'>

                        <bdo id='Orftg'></bdo><ul id='Orftg'></ul>
                          主站蜘蛛池模板: 91免费入口 | 国产在线观看网站 | 欧美成人一级视频 | 精品久久久久久久人人人人传媒 | 在线色网站 | 91精品一区二区三区久久久久 | 欧美日韩国产在线观看 | 中文字幕久久精品 | 久久久国产一区二区三区 | 欧美一区二区三区在线观看 | 亚洲在线免费观看 | 天天天操操操 | 国产精品成人一区二区 | 亚洲最新在线视频 | 中文字幕一区二区三区不卡在线 | 免费国产一区二区 | 极品一区 | 中文字幕亚洲欧美日韩在线不卡 | 一级做a爰片性色毛片16 | 国产在线一区观看 | 中文字幕第5页 | 精品国产欧美一区二区三区成人 | 国产精品视频一区二区三 | 午夜一区二区三区视频 | 日韩欧美国产一区二区三区 | 欧美成人a∨高清免费观看 老司机午夜性大片 | 国产精品久久二区 | 色综合欧美 | 在线观看视频亚洲 | 色爱av| 日本精品一区二区三区在线观看 | 欧美一区二区三区在线观看 | 精品久久久久久亚洲综合网 | 亚洲国产欧美在线人成 | 国产色99| 乱码av午夜噜噜噜噜动漫 | 黄色三级在线播放 | 日日日视频 | 久久久精品日本 | 精品小视频 | 91亚洲国产亚洲国产 |