Backed out changeset eaa0d64e544e (bug 996998) for B2G bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 27 Apr 2014 17:47:12 -0400
changeset 180894 fefcd48d83131da9be48603fc1e5eecfe8f65bce
parent 180893 b50bcf913c9b249b3aa8fcd82d70be65176f9bef
child 180895 cffe91e36df340670c56160e1bc656b87d8ef2a1
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
bugs996998
milestone31.0a1
backs outeaa0d64e544e0dd8ba29ed2ec66e8ecdb5ab248e
Backed out changeset eaa0d64e544e (bug 996998) for B2G bustage.
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/GonkGPSGeolocationProvider.h
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -665,56 +665,27 @@ GonkGPSGeolocationProvider::NetworkLocat
     GonkGPSGeolocationProvider::GetSingleton();
 
   nsCOMPtr<nsIDOMGeoPositionCoords> coords;
   position->GetCoords(getter_AddRefs(coords));
   if (!coords) {
     return NS_ERROR_FAILURE;
   }
 
+  // if we haven't seen anything from the GPS device for 1s,
+  // use this network derived location.
+  int64_t diff = PR_Now() - provider->mLastGPSDerivedLocationTime;
+  if (provider->mLocationCallback && diff > kDefaultPeriod) {
+    provider->mLocationCallback->Update(position);
+  }
+
   double lat, lon, acc;
   coords->GetLatitude(&lat);
   coords->GetLongitude(&lon);
   coords->GetAccuracy(&acc);
-
-  double delta = MAXFLOAT;
-  if (mLastMLSPosition) {
-    double oldLat, oldLon;
-    mLastMLSPosition->GetLatitude(&oldLat);
-    mLastMLSPosition->GetLongitude(&oldLon);
-
-    // Use spherical law of cosines to calculate difference
-    // Not quite as correct as the Haversine but simpler and cheaper
-    // Should the following be a utility function? Others might need this calc.
-    double radsInDeg = 3.14159265 / 180.0;
-    double rNewLat = newLat * radsInDeg;
-    double rNewLon = newLon * radsInDeg;
-    double rOldLat = oldLat * radsInDeg;
-    double rOldLon = oldLon * radsInDeg;
-    // WGS84 equatorial radius of earth = 6378137m
-    delta = acos( (sin(rNewLat) * sin(rOldLat)) +
-                         (cos(rNewLat) * cos(rOldLat) * cos(rOldLon - rNewLon)) )
-                        * 6378137;
-  }
-
-  // if the MLS coord change is smaller than this arbitrarily small value
-  // assume the MLS coord is unchanged, and stick with the GPS location
-  const double kMinMLSCoordChangeInMeters = 10;
-
-  // if we haven't seen anything from the GPS device for 1s,
-  // use this network derived location.
-  int64_t diff = PR_Now() - provider->mLastGPSDerivedLocationTime;
-  if (provider->mLocationCallback && diff > kDefaultPeriod
-      && delta > kMinMLSCoordChangeInMeters)
-  {
-    provider->mLocationCallback->Update(position);
-  }
-
-  mLastMLSPosition = position;
-
   provider->InjectLocation(lat, lon, acc);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::NetworkLocationUpdate::LocationUpdatePending()
 {
   return NS_OK;
--- a/dom/system/gonk/GonkGPSGeolocationProvider.h
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.h
@@ -109,17 +109,16 @@ private:
   const AGpsInterface* mAGpsInterface;
   const AGpsRilInterface* mAGpsRilInterface;
   nsCOMPtr<nsIRadioInterface> mRadioInterface;
 #endif
   nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
   PRTime mLastGPSDerivedLocationTime;
   nsCOMPtr<nsIThread> mInitThread;
   nsCOMPtr<nsIGeolocationProvider> mNetworkLocationProvider;
-  nsCOMPtr<nsIDOMGeoPositionCoords> mLastMLSPosition;
 
   class NetworkLocationUpdate : public nsIGeolocationUpdate
   {
     public:
       NS_DECL_ISUPPORTS
       NS_DECL_NSIGEOLOCATIONUPDATE
 
       NetworkLocationUpdate() {}