想bulid考勤跟踪系统,GPS lattitude和经度 [英] want to bulid attendance tracking system with gps lattitude and longitude

查看:241
本文介绍了想bulid考勤跟踪系统,GPS lattitude和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

建立一个算法通过四套经纬度长时间才找到一个多边形构建..并通过当前纬度长时间才找到一套Lat Long网是否属于该多边形与否。但当前lattiitude和经度是不准确的。在Android中使用全球定位系统和网络系统跟踪电流lattitude和纬度。

build a algorithm to find a polygon build by four sets of lat long.. and passing current lat long to find whether a set of lat long belong to that polygon or not. But the the current lattiitude and longitude is not accurate . in android using gps and network system to tracking current lattitude and longitude.

 public void find current_lat_long(){
com.example.gps.AppLocationService appLocationService = new com.example.gps.AppLocationService(
            Map_Location.this);
    Location gpsLocation = appLocationService
            .getLocation(LocationManager.GPS_PROVIDER);
    Location nwLocation = appLocationService
            .getLocation(LocationManager.NETWORK_PROVIDER);
    if (gpsLocation != null) {
        latitude_gps_calc_lat = gpsLocation.getLatitude();
        longitude_gpa_calc_lng = gpsLocation.getLongitude();
        constant.lat=String.valueOf(gpsLocation.getLatitude());
        constant.longitude=String.valueOf(gpsLocation.getLongitude());
        constant.flag_gps=false;
        String latlong_gps = String.valueOf(gpsLocation.getLatitude())+String.valueOf( gpsLocation.getLongitude());
//       lat1_string=constant.lat;
//          long_1_string=constant.longitude;

           lat4_string=constant.lat;
            long_4_string=constant.longitude;

        return true;
    }
    else if (nwLocation != null)
        {
                latitude_network_provider = nwLocation.getLatitude();
                longitude_network_provider = nwLocation.getLongitude();
                constant.flag_network=false;
                latlong__network_provider =String.valueOf(latitude_network_provider)+String.valueOf(longitude_network_provider);

                constant.lat=String.valueOf(latitude_network_provider);
                constant.longitude=String.valueOf(longitude_network_provider);
                   lat4.setText(constant.lat+constant.longitude);
                   lat4_string=constant.lat;
                    long_4_string=constant.longitude;

            return true;


    } 

}

请帮忙找准确经纬度长时间跟踪的Lat Long网属于特定的多边形。

Please help to find accurate lat long to tracking that lat long belong to the particular polygon.

推荐答案

您可以使用下面的code找到位置:

You can find location using the below code:

声明变量:

LocationManager lm;
LocationListener ll;

开始位置监听器:

    lm = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    ll = new startLocationListener();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,ll);

位置监听器:

class gpsLocationListener implements LocationListener {

    public void onLocationChanged(Location location) {
        if (location != null) {
            String latitude =  location.getLatitude();
            String longitude = location.getLongitude();                
        }
    }

    public void onProviderDisabled(String provider) {
    }

    public void onProviderEnabled(String provider) {
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
    }

}

找到位置后,您可以在onLocationChanged使用该停止监听器:

 lm.removeUpdates(ll);
 lm = null;

这篇关于想bulid考勤跟踪系统,GPS lattitude和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆