Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: content/public/common/geoposition.cc

Issue 10316007: Make the Geoposition helper class public (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/common/geoposition.cc
diff --git a/content/public/common/geoposition.cc b/content/public/common/geoposition.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a0f1f08b1847e4e6b616a38b7e7813bc99f4446
--- /dev/null
+++ b/content/public/common/geoposition.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/common/geoposition.h"
+
+namespace {
+// Sentinel values to mark invalid data. (WebKit carries companion is_valid
+// bools for this purpose; we may eventually follow that approach, but
+// sentinels worked OK in the Gears code this is based on.)
+const double kBadLatitudeLongitude = 200;
+// Lowest point on land is at approximately -400 meters.
+const int kBadAltitude = -10000;
+const int kBadAccuracy = -1; // Accuracy must be non-negative.
+const int kBadHeading = -1; // Heading must be non-negative.
+const int kBadSpeed = -1;
+}
+
+namespace content {
+
+Geoposition::Geoposition()
+ : latitude(kBadLatitudeLongitude),
+ longitude(kBadLatitudeLongitude),
+ altitude(kBadAltitude),
+ accuracy(kBadAccuracy),
+ altitude_accuracy(kBadAccuracy),
+ heading(kBadHeading),
+ speed(kBadSpeed),
+ error_code(ERROR_CODE_NONE) {
+}
+
+bool Geoposition::Validate() const {
+ return latitude >= -90. && latitude <= 90. &&
+ longitude >= -180. && longitude <= 180. &&
+ accuracy >= 0. &&
+ !timestamp.is_null();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698