/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
// NaN() is a more convenient function name. inlinedouble NaN() { return mozilla::UnspecifiedNaN<double>(); }
//////////////////////////////////////////////////// // nsGeoPositionCoords ////////////////////////////////////////////////////
nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed)
: mLat(aLat),
mLong(aLong),
mAlt(aAlt),
mHError((aHError >= 0) ? aHError : 0) // altitudeAccuracy without an altitude doesn't make any sense.
,
mVError((aVError >= 0 && !std::isnan(aAlt)) ? aVError : NaN()) // If the hosting device is stationary (i.e. the value of the speed // attribute is 0), then the value of the heading attribute must be NaN // (or null).
,
mHeading((aHeading >= 0 && aHeading < 360 && aSpeed > 0) ? aHeading
: NaN()),
mSpeed(aSpeed >= 0 ? aSpeed : NaN()) { // Sanity check the location provider's results in debug builds. If the // location provider is returning bogus results, we'd like to know, but // we prefer to return some position data to JavaScript over a // POSITION_UNAVAILABLE error.
MOZ_ASSERT(aLat >= -90 && aLat <= 90);
MOZ_ASSERT(aLong >= -180 && aLong <= 180);
MOZ_ASSERT(!(aLat == 0 && aLong == 0)); // valid but probably a bug
GeolocationCoordinates* GeolocationPosition::Coords() { if (!mCoordinates) {
nsCOMPtr<nsIDOMGeoPositionCoords> coords;
mGeoPosition->GetCoords(getter_AddRefs(coords));
MOZ_ASSERT(coords, "coords should not be null");
mCoordinates = new GeolocationCoordinates(this, coords);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.