2010-06-04 14:14:43 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
#include "nsGeoPosition.h"
|
2011-10-03 12:11:31 -07:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2012-07-20 09:42:08 -07:00
|
|
|
#include "nsIClassInfo.h"
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPositionCoords
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
2010-09-20 21:16:37 -07:00
|
|
|
double aSpeed)
|
|
|
|
: mLat(aLat)
|
|
|
|
, mLong(aLong)
|
|
|
|
, mAlt(aAlt)
|
|
|
|
, mHError(aHError)
|
|
|
|
, mVError(aVError)
|
|
|
|
, mHeading(aHeading)
|
|
|
|
, mSpeed(aSpeed)
|
2010-06-04 14:14:43 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGeoPositionCoords::~nsGeoPositionCoords()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMCI_DATA(GeoPositionCoords, nsGeoPositionCoords)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsGeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCoords)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2010-09-21 19:36:58 -07:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsGeoPositionCoords)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsGeoPositionCoords)
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetLatitude(double *aLatitude)
|
|
|
|
{
|
|
|
|
*aLatitude = mLat;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetLongitude(double *aLongitude)
|
|
|
|
{
|
|
|
|
*aLongitude = mLong;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAltitude(double *aAltitude)
|
|
|
|
{
|
|
|
|
*aAltitude = mAlt;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAccuracy(double *aAccuracy)
|
|
|
|
{
|
|
|
|
*aAccuracy = mHError;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAltitudeAccuracy(double *aAltitudeAccuracy)
|
|
|
|
{
|
|
|
|
*aAltitudeAccuracy = mVError;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetHeading(double *aHeading)
|
|
|
|
{
|
|
|
|
*aHeading = mHeading;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetSpeed(double *aSpeed)
|
|
|
|
{
|
|
|
|
*aSpeed = mSpeed;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPosition
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed, long long aTimestamp) :
|
|
|
|
mTimestamp(aTimestamp)
|
|
|
|
{
|
|
|
|
mCoords = new nsGeoPositionCoords(aLat, aLong,
|
|
|
|
aAlt, aHError,
|
|
|
|
aVError, aHeading,
|
|
|
|
aSpeed);
|
|
|
|
}
|
2010-09-20 21:16:37 -07:00
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
long long aTimestamp) :
|
2010-10-14 09:12:57 -07:00
|
|
|
mTimestamp(aTimestamp),
|
|
|
|
mCoords(aCoords)
|
2010-09-20 21:16:37 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
DOMTimeStamp aTimestamp) :
|
|
|
|
mTimestamp(aTimestamp),
|
2012-03-08 22:16:25 -08:00
|
|
|
mCoords(aCoords)
|
2010-09-20 21:16:37 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
nsGeoPosition::~nsGeoPosition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMCI_DATA(GeoPosition, nsGeoPosition)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsGeoPosition)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPosition)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2010-09-21 19:36:58 -07:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsGeoPosition)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition)
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
|
|
|
|
{
|
|
|
|
*aTimestamp = mTimestamp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPosition::GetCoords(nsIDOMGeoPositionCoords * *aCoords)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aCoords = mCoords);
|
|
|
|
return NS_OK;
|
|
|
|
}
|