| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/geolocation/geoposition.h" |
| 6 |
| 7 namespace { |
| 8 // Sentinel values to mark invalid data. (WebKit carries companion is_valid |
| 9 // bools for this purpose; we may eventually follow that approach, but |
| 10 // sentinels worked OK in the gears code this is based on.) |
| 11 const double kBadLatLng = 200; |
| 12 // Lowest point on land is at approximately -400 metres. |
| 13 const int kBadAltitude = -1000; |
| 14 const int kBadAccuracy = -1; // Accuracy must be non-negative. |
| 15 const int64 kBadTimestamp = kint64min; |
| 16 } |
| 17 |
| 18 Position::Position() |
| 19 : latitude(kBadLatLng), |
| 20 longitude(kBadLatLng), |
| 21 altitude(kBadAltitude), |
| 22 accuracy(kBadAccuracy), |
| 23 altitude_accuracy(kBadAccuracy), |
| 24 timestamp(kBadTimestamp), |
| 25 error_code(ERROR_CODE_NONE) { |
| 26 } |
| 27 |
| 28 bool Position::is_valid_latlong() const { |
| 29 return latitude >= -90.0 && latitude <= 90.0 && |
| 30 longitude >= -180.0 && longitude <= 180.0; |
| 31 } |
| 32 |
| 33 bool Position::is_valid_altitude() const { |
| 34 return altitude > kBadAltitude; |
| 35 } |
| 36 |
| 37 bool Position::is_valid_accuracy() const { |
| 38 return accuracy >= 0.0; |
| 39 } |
| 40 |
| 41 bool Position::is_valid_altitude_accuracy() const { |
| 42 return altitude_accuracy >= 0.0; |
| 43 } |
| 44 |
| 45 bool Position::is_valid_timestamp() const { |
| 46 return timestamp != kBadTimestamp; |
| 47 } |
| 48 |
| 49 bool Position::IsValidFix() const { |
| 50 return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp(); |
| 51 } |
| 52 |
| 53 bool Position::IsInitialized() const { |
| 54 return error_code != ERROR_CODE_NONE || IsValidFix(); |
| 55 } |
| OLD | NEW |