You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by no...@apache.org on 2023/09/15 02:52:04 UTC
[cordova-plugin-geolocation] branch master updated: fix: heading speed w3c spec (#270)
This is an automated email from the ASF dual-hosted git repository.
normanbreau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-geolocation.git
The following commit(s) were added to refs/heads/master by this push:
new 13f2a20 fix: heading speed w3c spec (#270)
13f2a20 is described below
commit 13f2a203c4c6194da2feb5e5f41241fb8ce3a7bc
Author: Norman Breau <no...@nbsolutions.ca>
AuthorDate: Thu Sep 14 23:51:59 2023 -0300
fix: heading speed w3c spec (#270)
* CB-11462: (all) Make sure Coordinates#speed follows the w3c specification.
Speed can have a negative value on iOS devices when the OS is not able to determine the current speed.
This is against the w3c specification. Which only allows null and a number value >= 0.
See the following links for further informations:
* https://dev.w3.org/geo/api/spec-source.html#speed
* https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/#//apple_ref/occ/instp/CLLocation/speed
* CB-11462: (all) Make sure Coordinates#heading follows the w3c specification.
Heading (course) can have a negative value on iOS devices when the OS is not able to determine the current heading.
This is against the w3c specification. Which only allows null and a number value >= 0 and <= 360.
See the following links for further informations:
* https://dev.w3.org/geo/api/spec-source.html#heading
* https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/#//apple_ref/occ/instp/CLLocation/course
---------
Co-authored-by: Malte Legenhausen <ml...@gmail.com>
---
www/Coordinates.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/www/Coordinates.js b/www/Coordinates.js
index 59ee6e2..6ef2166 100644
--- a/www/Coordinates.js
+++ b/www/Coordinates.js
@@ -50,11 +50,11 @@ const Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
/**
* The direction the device is moving at the position.
*/
- this.heading = head !== undefined ? head : null;
+ this.heading = (typeof head === 'number' && head >= 0 && head <= 360 ? head : null);
/**
* The velocity with which the device is moving at the position.
*/
- this.speed = vel !== undefined ? vel : null;
+ this.speed = (typeof vel === 'number' && vel >= 0 ? vel : null);
if (this.speed === 0 || this.speed === null) {
this.heading = NaN;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org