| Index: content/public/common/geoposition.cc
|
| diff --git a/content/public/common/geoposition.cc b/content/public/common/geoposition.cc
|
| index 3a0f1f08b1847e4e6b616a38b7e7813bc99f4446..39174222202029b5a312519d5cad8b2437574414 100644
|
| --- a/content/public/common/geoposition.cc
|
| +++ b/content/public/common/geoposition.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "content/public/common/geoposition.h"
|
| +#include <math.h>
|
|
|
| namespace {
|
| // Sentinel values to mark invalid data. (WebKit carries companion is_valid
|
| @@ -36,4 +37,29 @@ bool Geoposition::Validate() const {
|
| !timestamp.is_null();
|
| }
|
|
|
| +// The calculations in this function are experimental and not fully accurate.
|
| +/* static */
|
| +Geoposition Geoposition::ApplyPrecision(const Geoposition& position,
|
| + const int precision) {
|
| + Geoposition newGeoposition = position;
|
| + switch (precision) {
|
| + case 1:
|
| + // City granuality.
|
| + newGeoposition.latitude = round(newGeoposition.latitude * 10.0) / 10.0;
|
| + newGeoposition.longitude = round(newGeoposition.longitude * 10.0) / 10.0;
|
| + break;
|
| + case 2:
|
| + // State granuality.
|
| + newGeoposition.latitude = round(newGeoposition.latitude);
|
| + newGeoposition.longitude = round(newGeoposition.longitude);
|
| + break;
|
| + case 3:
|
| + // Country granuality.
|
| + newGeoposition.latitude = round(newGeoposition.latitude / 10.0);
|
| + newGeoposition.longitude = round(newGeoposition.longitude / 10.0);
|
| + break;
|
| + }
|
| + return newGeoposition;
|
| +}
|
| +
|
| } // namespace content
|
|
|