久久久久久久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. 獲取緯度和經(jīng)度的小數(shù)點(diǎn)后十二位

      Get twelve digits after decimal for latitude and longitude(獲取緯度和經(jīng)度的小數(shù)點(diǎn)后十二位)
      <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. 本文介紹了獲取緯度和經(jīng)度的小數(shù)點(diǎn)后十二位的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我有一個(gè)應(yīng)用程序,我必須從緯度和經(jīng)度中獲取用戶的當(dāng)前位置.對(duì)于這兩個(gè)值,我必須得到小數(shù)點(diǎn)后 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;
                    }
                }
                

                這是我從中訪問(wèn) GPSTracker 類的服務(wù)類:

                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();
                    }
                
                
                }
                

                目前,經(jīng)度和緯度都得到小數(shù)點(diǎn)后 4 位數(shù)字.我應(yīng)該怎么做才能在緯度和經(jīng)度值之后獲得 12 位數(shù)字?

                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?

                推薦答案

                用十進(jìn)制度量度時(shí),逗號(hào)后不必取 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 位在毫米范圍內(nèi).

                12 位是千分之一毫米.

                12 digits is a ten thousandth of a millimeter.

                保留 7 位數(shù)字,也可以表示為整數(shù).

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

                這篇關(guān)于獲取緯度和經(jīng)度的小數(shù)點(diǎn)后十二位的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計(jì)算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                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 返回負(fù)速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)

                <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>
                          主站蜘蛛池模板: 久久久久久久久久久一区二区 | 国产在线一区二区 | 国产精品一区二区久久 | 国产精品一区二区在线播放 | 国产精品2区| 日韩av视屏 | 欧美精品久久久久 | www成年人视频| 国产亚洲一区二区在线观看 | 国产精品久久久久久久久久久久久 | 久久视频精品 | 国产亚洲精品久久久久动 | 久久久久亚洲av毛片大全 | 秋霞电影院午夜伦 | 亚洲国产精品一区在线观看 | 麻豆国产一区二区三区四区 | 亚洲性视频网站 | 亚洲精品国产一区 | 91亚洲一区| 少妇一区在线观看 | 亚洲精品电影在线观看 | 欧美日韩电影一区二区 | www.99热 | 九九国产在线观看 | 国产精品久久久久久久久久久久 | 九九热免费在线观看 | 久久久www成人免费无遮挡大片 | 毛片站| 国内自拍偷拍 | 国产精品麻 | 国产精品综合久久 | 国产精品久久久久久久久 | 国产精品亚洲第一区在线暖暖韩国 | 99精品一区二区 | 国产精品一区二区三区四区 | 欧美理论片在线观看 | 亚洲国产一区二区三区 | 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 | 国产自产21区 | 日韩欧美久久 | 鸡毛片|