OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 // This file declares the Geoposition structure, used to represent a position |
| 6 // fix. It was originally derived from: |
| 7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h |
| 8 |
| 9 #ifndef CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ |
| 10 #define CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ |
| 11 |
| 12 #include <string> |
| 13 |
| 14 #include "base/time/time.h" |
| 15 #include "content/common/content_export.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 struct CONTENT_EXPORT Geoposition { |
| 20 public: |
| 21 // These values follow the W3C geolocation specification and can be returned |
| 22 // to JavaScript without the need for a conversion. |
| 23 enum ErrorCode { |
| 24 ERROR_CODE_NONE = 0, // Chrome addition. |
| 25 ERROR_CODE_PERMISSION_DENIED = 1, |
| 26 ERROR_CODE_POSITION_UNAVAILABLE = 2, |
| 27 ERROR_CODE_TIMEOUT = 3, |
| 28 ERROR_CODE_LAST = ERROR_CODE_TIMEOUT |
| 29 }; |
| 30 |
| 31 // All fields are initialized to sentinel values marking them as invalid. The |
| 32 // error code is set to ERROR_CODE_NONE. |
| 33 Geoposition(); |
| 34 |
| 35 Geoposition(const Geoposition& other); |
| 36 |
| 37 // A valid fix has a valid latitude, longitude, accuracy and timestamp. |
| 38 bool Validate() const; |
| 39 |
| 40 // These properties correspond to those of the JavaScript Position object |
| 41 // although their types may differ. |
| 42 // Latitude in decimal degrees north (WGS84 coordinate frame). |
| 43 double latitude; |
| 44 // Longitude in decimal degrees west (WGS84 coordinate frame). |
| 45 double longitude; |
| 46 // Altitude in meters (above WGS84 datum). |
| 47 double altitude; |
| 48 // Accuracy of horizontal position in meters. |
| 49 double accuracy; |
| 50 // Accuracy of altitude in meters. |
| 51 double altitude_accuracy; |
| 52 // Heading in decimal degrees clockwise from true north. |
| 53 double heading; |
| 54 // Horizontal component of device velocity in meters per second. |
| 55 double speed; |
| 56 // Time of position measurement in milisecons since Epoch in UTC time. This is |
| 57 // taken from the host computer's system clock (i.e. from Time::Now(), not the |
| 58 // source device's clock). |
| 59 base::Time timestamp; |
| 60 |
| 61 // Error code, see enum above. |
| 62 ErrorCode error_code; |
| 63 // Human-readable error message. |
| 64 std::string error_message; |
| 65 }; |
| 66 |
| 67 } // namespace content |
| 68 |
| 69 #endif // CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ |
OLD | NEW |