Skip to content

Commit

Permalink
fix: heading speed w3c spec (#270)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
breautek and Malte Legenhausen authored Sep 15, 2023
1 parent 1ed8b33 commit 13f2a20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions www/Coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 13f2a20

Please sign in to comment.