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#include <wtf/RefCounted.h>
30#include <wtf/RefPtr.h>
31
32namespace WebCore {
33
34class GeolocationPosition : public RefCounted<GeolocationPosition> {
35public:
36 static Ref<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy)
37 {
38 return adoptRef(*new GeolocationPosition(timestamp, latitude, longitude, accuracy));
39 }
40
41 static Ref<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)
42 {
43 return adoptRef(*new GeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
44 }
45
46 double timestamp() const { return m_timestamp; }
47
48 double latitude() const { return m_latitude; }
49 double longitude() const { return m_longitude; }
50 double accuracy() const { return m_accuracy; }
51 double altitude() const { return m_altitude; }
52 double altitudeAccuracy() const { return m_altitudeAccuracy; }
53 double heading() const { return m_heading; }
54 double speed() const { return m_speed; }
55
56 bool canProvideAltitude() const { return m_canProvideAltitude; }
57 bool canProvideAltitudeAccuracy() const { return m_canProvideAltitudeAccuracy; }
58 bool canProvideHeading() const { return m_canProvideHeading; }
59 bool canProvideSpeed() const { return m_canProvideSpeed; }
60
61private:
62 GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy)
63 : m_timestamp(timestamp)
64 , m_latitude(latitude)
65 , m_longitude(longitude)
66 , m_accuracy(accuracy)
67 , m_altitude(0)
68 , m_altitudeAccuracy(0)
69 , m_heading(0)
70 , m_speed(0)
71 , m_canProvideAltitude(false)
72 , m_canProvideAltitudeAccuracy(false)
73 , m_canProvideHeading(false)
74 , m_canProvideSpeed(false)
75 {
76 }
77
78 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)
79 : m_timestamp(timestamp)
80 , m_latitude(latitude)
81 , m_longitude(longitude)
82 , m_accuracy(accuracy)
83 , m_altitude(altitude)
84 , m_altitudeAccuracy(altitudeAccuracy)
85 , m_heading(heading)
86 , m_speed(speed)
87 , m_canProvideAltitude(providesAltitude)
88 , m_canProvideAltitudeAccuracy(providesAltitudeAccuracy)
89 , m_canProvideHeading(providesHeading)
90 , m_canProvideSpeed(providesSpeed)
91 {
92 }
93
94 double m_timestamp;
95
96 double m_latitude;
97 double m_longitude;
98 double m_accuracy;
99 double m_altitude;
100 double m_altitudeAccuracy;
101 double m_heading;
102 double m_speed;
103
104 bool m_canProvideAltitude;
105 bool m_canProvideAltitudeAccuracy;
106 bool m_canProvideHeading;
107 bool m_canProvideSpeed;
108};
109
110} // namespace WebCore
111
112#endif // GeolocationPosition_h
113