修复定位数据锁定错误问题
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Fri Mar 21 09:01:41 GMT 2025 | ||||
| #Fri Mar 21 13:06:16 GMT 2025 | ||||
| stageCount=0 | ||||
| libraryProject= | ||||
| baseVersion=1.0 | ||||
| publishVersion=1.0.0 | ||||
| buildCount=355 | ||||
| buildCount=365 | ||||
| baseBetaVersion=1.0.1 | ||||
|   | ||||
| @@ -66,8 +66,9 @@ public class PositionsFragment extends Fragment { | ||||
|     static Location _LocationPhoneGPSLock; | ||||
|  | ||||
|     LocationManager locationManagerPhoneGPS; | ||||
|     volatile static int nFixActivationCountValue = 20; | ||||
|     volatile static int nFixActivationCountValue = 70; | ||||
|     volatile static int nCurrentFixActivationCountValue = 0; | ||||
|     volatile static int nGPSUpdateCount = 0; | ||||
|  | ||||
| //    public static PositionsFragment newInstance(int page) { | ||||
| //        Bundle args = new Bundle(); | ||||
| @@ -93,6 +94,7 @@ public class PositionsFragment extends Fragment { | ||||
|         View viewMain = inflater.inflate(R.layout.fragment_positions, container, false); | ||||
|  | ||||
|         nCurrentFixActivationCountValue = 0; | ||||
|         nGPSUpdateCount = 0; | ||||
|  | ||||
| //        Toolbar toolbar = viewMain.findViewById(R.id.toolbar); | ||||
| //        getActivity().getMenuInflater().inflate(R.menu.toolbar_positions,  toolbar.getMenu()); | ||||
| @@ -121,8 +123,6 @@ public class PositionsFragment extends Fragment { | ||||
|                         _LocationPhoneGPSLock.setLongitude(Double.parseDouble(metLockLongitude.getText().toString())); | ||||
|                         ToastUtils.show("定位手动设定位置"); | ||||
|                     } else { | ||||
|                         // 用腾讯定位数据与GPS定位数据的数据差修复模型,来修复一下GPS定位数据。 | ||||
|                         mPostionFixModel = PostionFixModel.loadPostionFixModel(); | ||||
|                         Location locationFix = fixGPSLocationFromPostionFixModel(_LocationPhoneGPS); | ||||
|                         //_LocationPhoneGPSLock = _LocationTX; | ||||
|                         _LocationPhoneGPSLock = locationFix; | ||||
| @@ -154,7 +154,7 @@ public class PositionsFragment extends Fragment { | ||||
|  | ||||
|     void showLocationPhoneGPS() { | ||||
|         if (_LocationPhoneGPS != null) { | ||||
|             String szTemp = String.format("\nPhoneGPS MyLocation Info\nLatitude %f\nLongitude %f\nAccuracy %f\n", _LocationPhoneGPS.getLatitude(), _LocationPhoneGPS.getLongitude(), _LocationPhoneGPS.getAccuracy()); | ||||
|             String szTemp = String.format("\n(%d)PhoneGPS MyLocation Info\nLatitude %f\nLongitude %f\nAccuracy %f\n", nGPSUpdateCount, _LocationPhoneGPS.getLatitude(), _LocationPhoneGPS.getLongitude(), _LocationPhoneGPS.getAccuracy()); | ||||
|             mtvPhoneMyLocationInfo.append(szTemp); | ||||
|             LogUtils.d(TAG, szTemp); | ||||
|         } | ||||
| @@ -162,7 +162,8 @@ public class PositionsFragment extends Fragment { | ||||
|  | ||||
|     void showPostionFixModelInfo() { | ||||
|         if (mPostionFixModel != null && _LocationTX != null && _LocationPhoneGPS != null) { | ||||
|             String szTemp = String.format("\nFixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\n\n", | ||||
|             String szTemp = String.format("\n(%d)FixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\n\n", | ||||
|                                           nCurrentFixActivationCountValue, | ||||
|                                           _LocationTX.getLatitude(), | ||||
|                                           _LocationPhoneGPS.getLatitude(), | ||||
|                                           mPostionFixModel.getLatitudeFixModel(), | ||||
| @@ -176,14 +177,16 @@ public class PositionsFragment extends Fragment { | ||||
|  | ||||
|     void showLockPostionInfo() { | ||||
|         if (mPostionFixModel != null && _LocationTX != null && _LocationPhoneGPSLock != null) { | ||||
|             String szTemp = String.format("\n%s\nFixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\n\n", | ||||
|             String szTemp = String.format("\n%s\nFixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLatitude GPSLock %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\nLongitude GPSLock %f\n\n", | ||||
|                                           TimeUtils.getCurrentTimeString(), | ||||
|                                           _LocationTX.getLatitude(), | ||||
|                                           _LocationPhoneGPS.getLatitude(), | ||||
|                                           mPostionFixModel.getLatitudeFixModel(), | ||||
|                                           _LocationPhoneGPSLock.getLatitude(), | ||||
|                                           _LocationTX.getLongitude(), | ||||
|                                           _LocationPhoneGPS.getLongitude(), | ||||
|                                           mPostionFixModel.getLongitudeFixModel()); | ||||
|                                           mPostionFixModel.getLongitudeFixModel(), | ||||
|                                           _LocationPhoneGPSLock.getLongitude()); | ||||
|             mtvLockPostionInfo.append(szTemp); | ||||
|             LogUtils.d(TAG, szTemp); | ||||
|         } | ||||
| @@ -265,6 +268,9 @@ public class PositionsFragment extends Fragment { | ||||
|     } | ||||
|  | ||||
|     private Location fixGPSLocationFromPostionFixModel(Location location) { | ||||
|         // 用腾讯定位数据与GPS定位数据的数据差修复模型,来修复一下GPS定位数据。 | ||||
|         mPostionFixModel = PostionFixModel.loadPostionFixModel(); | ||||
|          | ||||
|         //Location location = locationTX; | ||||
|         Location locationFix = new Location("GPS_Fix_Map_Manual"); | ||||
|  | ||||
| @@ -273,17 +279,18 @@ public class PositionsFragment extends Fragment { | ||||
|         locationFix.setLongitude(location.getLongitude() - mPostionFixModel.getLongitudeFixModel()); | ||||
|  | ||||
|         // 设置必要元数据 | ||||
|         location.setTime(System.currentTimeMillis()); | ||||
|         location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); | ||||
|         location.setAccuracy(5.0f); // 手动点击精度设为5米 | ||||
|         locationFix.setTime(System.currentTimeMillis()); | ||||
|         locationFix.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); | ||||
|         locationFix.setAccuracy(5.0f); // 手动点击精度设为5米 | ||||
|  | ||||
|         return location; | ||||
|         return locationFix; | ||||
|     } | ||||
|  | ||||
|     private LocationListener phoneGPSLocationListener = new LocationListener() { | ||||
|         @Override | ||||
|         public void onLocationChanged(Location location) { | ||||
|             // 处理GPS定位结果 | ||||
|             nGPSUpdateCount++; | ||||
|             updateGPSLocation(location); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ package cc.winboll.studio.positions.fragments; | ||||
|  * @Date 2025/02/25 12:44:39 | ||||
|  * @Describe 腾讯地图服务视图 | ||||
|  */ | ||||
| import com.tencent.tencentmap.mapsdk.maps.model.LatLng; | ||||
| import android.Manifest; | ||||
| import android.content.pm.PackageManager; | ||||
| import android.graphics.Bitmap; | ||||
| @@ -55,7 +56,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; | ||||
| import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener { | ||||
| public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener,TencentMap.OnMapClickListener { | ||||
|  | ||||
|     public static final String TAG = "TXMSFragment"; | ||||
|  | ||||
| @@ -100,24 +101,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi | ||||
|         checkLocationPermission(); | ||||
|  | ||||
|         // 设置地图点击监听 | ||||
|         tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener(){ | ||||
|  | ||||
|                 @Override | ||||
|                 public void onMapClick(com.tencent.tencentmap.mapsdk.maps.model.LatLng latLng) { | ||||
|                     //创建Marker对象之前,设置属性 | ||||
|                     //LatLng position = new LatLng(40.011313,116.391907); | ||||
|                     BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); | ||||
|                     Location location = createTXLocationFromLatLng(latLng); | ||||
|                     addLocationToMap(location); | ||||
|                     Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng)); | ||||
|  | ||||
|                     //创建Marker对象之后,修改属性 | ||||
| //                    Animation animation = new AlphaAnimation(0.7f, 0f); | ||||
| //                    animation.setDuration(2000); | ||||
| //                    mCustomMarker.setAnimation(animation); | ||||
| //                    mCustomMarker.startAnimation(); | ||||
|                 } | ||||
|             }); | ||||
|         tencentMap.setOnMapClickListener(this); | ||||
|  | ||||
|         loadLocations(); | ||||
|  | ||||
| @@ -140,6 +124,22 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi | ||||
|  | ||||
|         return viewRoot; | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void onMapClick(LatLng latLng) { | ||||
|         //创建Marker对象之前,设置属性 | ||||
|         //LatLng position = new LatLng(40.011313,116.391907); | ||||
|         BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); | ||||
|         Location location = createTXLocationFromLatLng(latLng); | ||||
|         addLocationToMap(location); | ||||
|         Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng)); | ||||
|  | ||||
|         //创建Marker对象之后,修改属性 | ||||
| //                    Animation animation = new AlphaAnimation(0.7f, 0f); | ||||
| //                    animation.setDuration(2000); | ||||
| //                    mCustomMarker.setAnimation(animation); | ||||
| //                    mCustomMarker.startAnimation(); | ||||
|     } | ||||
|  | ||||
|     void genLocationFixModel() { | ||||
|  | ||||
| @@ -356,7 +356,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi | ||||
|         CameraUpdate cameraSigma = | ||||
|             CameraUpdateFactory.newCameraPosition(new CameraPosition( | ||||
|                                                       convertLocationToLatLng(location), | ||||
|                                                       19f, | ||||
|                                                       20f, | ||||
|                                                       0f, | ||||
|                                                       0f)); | ||||
|         //移动地图 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen