add tileId in uploadData
This commit is contained in:
@@ -8,6 +8,7 @@ import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -29,77 +30,79 @@ public class MogoRTKLocation {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
locationManager = ( LocationManager ) AbsMogoApplication.getApp().getApplicationContext().getSystemService( Context.LOCATION_SERVICE );
|
||||
String provider = locationManager.getBestProvider( getCriteria(), true );
|
||||
Logger.d( TAG, "init provider : " + provider );
|
||||
if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
|
||||
locationManager = (LocationManager) AbsMogoApplication.getApp().getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = locationManager.getBestProvider(getCriteria(), true);
|
||||
Logger.d(TAG, "init provider : " + provider);
|
||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
try {
|
||||
locationManager.requestLocationUpdates( provider, 0, 0, locationListener );
|
||||
Location location = locationManager.getLastKnownLocation( provider );
|
||||
if ( location != null ) {
|
||||
Logger.i( TAG, "location : " + location.toString() );
|
||||
locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
if (location != null) {
|
||||
Logger.i(TAG, "location : " + location.toString());
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.d( TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage() );
|
||||
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
Logger.d( TAG, "RTK LocationManager Provider GPS_PROVIDER unable" );
|
||||
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
|
||||
}
|
||||
}
|
||||
|
||||
private Criteria getCriteria() {
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.setAccuracy( Criteria.ACCURACY_FINE ); //高精
|
||||
criteria.setAltitudeRequired( false );
|
||||
criteria.setBearingRequired( true );
|
||||
criteria.setSpeedRequired( true );
|
||||
criteria.setPowerRequirement( Criteria.POWER_LOW );
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE); //高精
|
||||
criteria.setAltitudeRequired(false);
|
||||
criteria.setBearingRequired(true);
|
||||
criteria.setSpeedRequired(true);
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private final LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged( Location location ) {
|
||||
if ( location != null ) {
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
if(location.getLatitude() != 0.0 && location.getLongitude() != 0.0){
|
||||
cloudLocationInfo.setAlt( location.getAltitude() );
|
||||
cloudLocationInfo.setHeading( location.getBearing() );
|
||||
cloudLocationInfo.setLat( location.getLatitude() );
|
||||
cloudLocationInfo.setLon( location.getLongitude() );
|
||||
cloudLocationInfo.setSpeed( location.getSpeed() );
|
||||
cloudLocationInfo.setSatelliteTime( location.getTime() );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo );
|
||||
if (location.getLatitude() != 0.0 && location.getLongitude() != 0.0) {
|
||||
cloudLocationInfo.setAlt(location.getAltitude());
|
||||
cloudLocationInfo.setHeading(location.getBearing());
|
||||
cloudLocationInfo.setLat(location.getLatitude());
|
||||
cloudLocationInfo.setLon(location.getLongitude());
|
||||
cloudLocationInfo.setSpeed(location.getSpeed());
|
||||
cloudLocationInfo.setSatelliteTime(location.getTime());
|
||||
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
|
||||
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
|
||||
.getTileId(location.getLongitude(), location.getLatitude())));
|
||||
SnapshotLocationController.getInstance().syncLocationInfo(cloudLocationInfo);
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "location == null" );
|
||||
Logger.e(TAG, "location == null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( String provider, int status, Bundle extras ) {
|
||||
Logger.d( TAG, "onStatusChanged status: " + status );
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
Logger.d(TAG, "onStatusChanged status: " + status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled( String provider ) {
|
||||
Logger.d( TAG, "onProviderEnabled" );
|
||||
public void onProviderEnabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled( String provider ) {
|
||||
Logger.d( TAG, "onProviderEnabled" );
|
||||
public void onProviderDisabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
}
|
||||
};
|
||||
|
||||
public void stop() {
|
||||
Logger.d( TAG, "stop RTK Location" );
|
||||
if ( locationManager != null && locationListener != null ) {
|
||||
locationManager.removeUpdates( locationListener );
|
||||
Logger.d(TAG, "stop RTK Location");
|
||||
if (locationManager != null && locationListener != null) {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
} else {
|
||||
Logger.d( TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null" );
|
||||
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user