1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef GeolocationPosition_h 27 #define GeolocationPosition_h 28 29 #if ENABLE(CLIENT_BASED_GEOLOCATION) 30 31 #include <wtf/PassRefPtr.h> 32 #include <wtf/RefCounted.h> 33 #include <wtf/RefPtr.h> 34 35 namespace WebCore { 36 37 class GeolocationPosition : public RefCounted<GeolocationPosition> { 38 public: 39 static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy)); } 40 41 static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed)); } 42 43 double timestamp() const { return m_timestamp; } 44 45 double latitude() const { return m_latitude; } 46 double longitude() const { return m_longitude; } 47 double accuracy() const { return m_accuracy; } 48 double altitude() const { return m_altitude; } 49 double altitudeAccuracy() const { return m_altitudeAccuracy; } 50 double heading() const { return m_heading; } 51 double speed() const { return m_speed; } 52 53 bool canProvideAltitude() const { return m_canProvideAltitude; } 54 bool canProvideAltitudeAccuracy() const { return m_canProvideAltitudeAccuracy; } 55 bool canProvideHeading() const { return m_canProvideHeading; } 56 bool canProvideSpeed() const { return m_canProvideSpeed; } 57 58 private: 59 GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy) 60 : m_timestamp(timestamp) 61 , m_latitude(latitude) 62 , m_longitude(longitude) 63 , m_accuracy(accuracy) 64 , m_altitude(0) 65 , m_altitudeAccuracy(0) 66 , m_heading(0) 67 , m_speed(0) 68 , m_canProvideAltitude(false) 69 , m_canProvideAltitudeAccuracy(false) 70 , m_canProvideHeading(false) 71 , m_canProvideSpeed(false) 72 { 73 } 74 75 GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) 76 : m_timestamp(timestamp) 77 , m_latitude(latitude) 78 , m_longitude(longitude) 79 , m_accuracy(accuracy) 80 , m_altitude(altitude) 81 , m_altitudeAccuracy(altitudeAccuracy) 82 , m_heading(heading) 83 , m_speed(speed) 84 , m_canProvideAltitude(providesAltitude) 85 , m_canProvideAltitudeAccuracy(providesAltitudeAccuracy) 86 , m_canProvideHeading(providesHeading) 87 , m_canProvideSpeed(providesSpeed) 88 { 89 } 90 91 double m_timestamp; 92 93 double m_latitude; 94 double m_longitude; 95 double m_accuracy; 96 double m_altitude; 97 double m_altitudeAccuracy; 98 double m_heading; 99 double m_speed; 100 101 bool m_canProvideAltitude; 102 bool m_canProvideAltitudeAccuracy; 103 bool m_canProvideHeading; 104 bool m_canProvideSpeed; 105 }; 106 107 } // namespace WebCore 108 109 #endif // ENABLE(CLIENT_BASED_GEOLOCATION) 110 111 #endif // GeolocationPosition_h 112