Chromium Code Reviews| Index: content/public/common/geoposition.cc |
| diff --git a/content/public/common/geoposition.cc b/content/public/common/geoposition.cc |
| index 3a0f1f08b1847e4e6b616a38b7e7813bc99f4446..775dd7b17f75f6e52a88a47997863bf8485ca770 100644 |
| --- a/content/public/common/geoposition.cc |
| +++ b/content/public/common/geoposition.cc |
| @@ -36,4 +36,28 @@ bool Geoposition::Validate() const { |
| !timestamp.is_null(); |
| } |
| +Geoposition Geoposition::ApplyPrecision(const int choice) const { |
|
meacer
2014/08/15 22:20:25
In fact, it looks like Since this method returns
mhm
2014/08/15 23:18:57
Done.
|
| + Geoposition newGeoposition = *this; |
| + switch (choice) { |
| + case 1: |
| + // City granuality. |
| + newGeoposition.latitude = |
| + ((int)(newGeoposition.latitude + 0.5 * 10.0)) / 10.0; |
| + newGeoposition.longitude = |
| + ((int)(newGeoposition.longitude + 0.5 * 10.0)) / 10.0; |
| + break; |
| + case 2: |
| + // State granuality. |
| + newGeoposition.latitude = (int)newGeoposition.latitude; |
|
meacer
2014/08/15 22:20:25
May be better: static_cast<int>(std::floor(newGeop
mhm
2014/08/15 23:18:57
Done.
|
| + newGeoposition.longitude = (int)newGeoposition.longitude; |
| + break; |
| + case 3: |
| + // Country granuality. |
| + newGeoposition.latitude = (int)(newGeoposition.latitude / 10.0); |
| + newGeoposition.longitude = (int)(newGeoposition.longitude / 10.0); |
|
meacer
2014/08/15 22:20:25
You might want to add that this is a POC, and the
mhm
2014/08/15 23:18:57
Done.
|
| + break; |
| + } |
| + return newGeoposition; |
| +} |
| + |
| } // namespace content |