Skip to content

Commit 13f2a20

Browse files
breautekMalte Legenhausen
and
Malte Legenhausen
authored
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 <[email protected]>
1 parent 1ed8b33 commit 13f2a20

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: www/Coordinates.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ const Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
5050
/**
5151
* The direction the device is moving at the position.
5252
*/
53-
this.heading = head !== undefined ? head : null;
53+
this.heading = (typeof head === 'number' && head >= 0 && head <= 360 ? head : null);
5454
/**
5555
* The velocity with which the device is moving at the position.
5656
*/
57-
this.speed = vel !== undefined ? vel : null;
57+
this.speed = (typeof vel === 'number' && vel >= 0 ? vel : null);
5858

5959
if (this.speed === 0 || this.speed === null) {
6060
this.heading = NaN;

0 commit comments

Comments
 (0)