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