From 6d23de128766441d6ebb5ad62f92d1328d9a40ab Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Mon, 13 May 2024 13:39:53 +1000 Subject: [PATCH 01/10] Correction: Update acquisition algorithm to define data types and handle cached positions Enhance the "Acquire a Position" algorithm to include explicit data type definitions and unit specifications for each piece of acquired position data, aligning with the [[WGS84]] coordinate system standards. This update ensures each parameter (latitude, longitude, altitude, etc.) is clearly defined at the point of data acquisition. Additionally, refine the handling of cached position data within the algorithm. Introduce conditional logic to terminate the algorithm early if a valid cached position is used, preventing unnecessary data acquisition steps. This change improves efficiency and clarity in the geolocation process, ensuring that position data is handled correctly based on its freshness and accuracy requirements. Key Changes: - Define explicit data types and units for latitude, longitude, altitude, accuracy, altitude accuracy, speed, and heading. - Implement conditional checks to skip unnecessary acquisition steps when using cached positions. - Update parameters passed to the `GeolocationPosition` constructor to include all newly defined data points. --- index.html | 207 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 133 insertions(+), 74 deletions(-) diff --git a/index.html b/index.html index 484647e..06c8e95 100644 --- a/index.html +++ b/index.html @@ -838,12 +838,27 @@

value of the |options|.{{PositionOptions/maximumAge}} member. -
  • If |cachedPosition|'s - {{GeolocationPosition/timestamp}}'s value is greater than - |cacheTime|, and +
  • If + |cachedPosition|.{{GeolocationPosition/timestamp}}'s + value is greater than |cacheTime|, and |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} - equals |options|.{{PositionOptions/enableHighAccuracy}}, - set |position| to |cachedPosition|. + equals |options|.{{PositionOptions/enableHighAccuracy}}: +
    + Candidate Correction: + Updated to ensure that the algorithm terminates + immediately if a valid cached position is used, + avoiding unnecessary steps. +
      +
    1. + [=Queue a task=] on the [=geolocation task + source=] with a step that [=invokes=] + |successCallback| with |cachedPosition|. +
    2. +
    3. + Terminate this algorithm. +
    4. +
    +
  • @@ -867,9 +882,63 @@

  • If acquiring the position data from the system succeeds:
      -
    1. Set |position| be [=a new `GeolocationPosition`=] - passing |acquisitionTime| and - |options|.{{PositionOptions/enableHighAccuracy}}. +
    2. +
      + Candidate Correction: + Each acquired data type is now explicitly defined + with units and standards. +
        +
      1. + Let |latitude:double| be a real number of + degrees, in the [[WGS84]] coordinate + system. +
      2. +
      3. + Let |longitude:double| be a real number of + degrees, in the [[WGS84]] coordinate + system. +
      4. +
      5. + Let |altitude:double?| be a height, in + meters, above the [[WGS84]] ellipsoid or `null` + if not available. +
      6. +
      7. + Let |accuracy:double| be a non-negative real + number representing a 95% confidence level. +
      8. +
      9. + Let |altitudeAccuracy:double?| be a + non-negative real number or `null` if not + available, representing a 95% confidence + level. +
      10. +
      11. + Let |speed:double?| be a non-negative real + number of meters per second or `null` if not + available. +
      12. +
      13. + Let |heading:double?| be a real number of + degrees or `null` if not available. If the device + is stationary, set to NaN. +
      14. +
      +
      +
    3. +
    4. +
      + Candidate Correction: + Updated the parameters passed to the + `GeolocationPosition` constructor to align with the + new data specifications. + Set |position| to be [=a new + `GeolocationPosition`=] passing |latitude|, + |longitude|, |altitude|, |accuracy|, + |altitudeAccuracy|, |speed|, |heading|, + |acquisitionTime|, and + |options|.{{PositionOptions/enableHighAccuracy}}. +
    5. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to |position|. @@ -1203,79 +1272,69 @@

      Constructing a `GeolocationPosition`

      +

      - A new `GeolocationPosition` is constructed with - {{EpochTimeStamp}} |timestamp:EpochTimeStamp| and boolean - |isHighAccuracy| by performing the following steps: + A new `GeolocationPosition` is constructed with a {{double}} |latitude:double|, + {{double}} |longitude:double|, {{double?}} |altitude:double?|, + {{double}} |accuracy:double|, {{double?}} + |altitudeAccuracy:double?|, {{double?}} |speed:double?|, + {{double?}} |heading:double?|, {{EpochTimeStamp}} + |timestamp:EpochTimeStamp|, {{boolean}} + |isHighAccuracy:boolean| by performing the following steps:

      - -
      1. Let |coords:GeolocationCoordinates| be a newly created {{GeolocationCoordinates}} instance: -
          -
        1. Initialize |coord|'s {{GeolocationCoordinates/latitude}} - attribute to a geographic coordinate in decimal - degrees. attribute to a latitude, specified - as a real number of degrees, in the [[WGS84]] coordinate - system. -
        2. -
        3. Initialize |coord|'s {{GeolocationCoordinates/longitude}} - attribute to a geographic coordinate in decimal - degrees. attribute to a longitude, - specified as a real number of degrees, in the [[WGS84]] - coordinate system. -
        4. -
        5. Initialize |coord|'s {{GeolocationCoordinates/altitude}} - attribute in meters above the [[WGS84]] - ellipsoid, or `null` if the implementation cannot provide - altitude information. attribute to a - height, in meters, above the [[WGS84]] ellipsoid, or `null` if - the implementation cannot provide altitude information. -
        6. -
        7. Initialize |coord|'s {{GeolocationCoordinates/speed}} - attribute to a non-negative real number, or as - `null` if the implementation cannot provide speed - information. attribute to a speed, as a - non-negative real number of meters per second, or as `null` if - the implementation cannot provide speed information. -
        8. -
        9. Initialize |coord|'s {{GeolocationCoordinates/heading}} - attribute in degrees, or `null` if the - implementation cannot provide heading information. If the hosting - device is stationary (i.e., the value of the - {{GeolocationCoordinates/speed}} attribute is 0), then initialize - the {{GeolocationCoordinates/heading}} to `NaN`. - attribute to a heading, in degrees, or `null` - if the implementation cannot provide heading information. If - the hosting device is stationary (i.e., the value of the +
          + Candidate Correction: Enhanced the + constructor steps for {{GeolocationCoordinates}} to take + arguments from call site. +
            +
          1. Initialize |coord|'s {{GeolocationCoordinates/latitude}} + attribute to a geographic coordinate in decimal + degrees. |latitude|. +
          2. +
          3. Initialize |coord|'s {{GeolocationCoordinates/longitude}} + attribute to a geographic coordinate in decimal + degrees. |longitude|. +
          4. +
          5. Initialize |coord|'s {{GeolocationCoordinates/altitude}} + attribute in meters above the [[WGS84]] ellipsoid, or + `null` if the implementation cannot provide altitude + information. attribute to |altitude|. +
          6. +
          7. Initialize |coord|'s {{GeolocationCoordinates/speed}} + attribute to a non-negative real number, or as `null` if + the implementation cannot provide speed information. + |speed|. +
          8. +
          9. Initialize |coord|'s {{GeolocationCoordinates/heading}} + attribute in degrees, or `null` if the implementation + cannot provide heading information. If the hosting device is + stationary (i.e., the value of the {{GeolocationCoordinates/speed}} attribute is 0), then initialize the {{GeolocationCoordinates/heading}} to - `NaN`. -
          10. -
          11. Initialize |coord|'s {{GeolocationCoordinates/accuracy}} - attribute to a non-negative real number. The value SHOULD - correspond to a 95% confidence level with respect to the - longitude and latitude values. -
          12. -
          13. Initialize |coord|'s - {{GeolocationCoordinates/altitudeAccuracy}} attribute as - non-negative real number, or to `null` if the implementation - cannot provide altitude information. If the altitude accuracy - information is provided, it SHOULD correspond to a 95% confidence - level. -
          14. -
          + `NaN`. attribute to |heading|. +
        10. +
        11. Initialize |coord|'s {{GeolocationCoordinates/accuracy}} + attribute to a non-negative real number. The value SHOULD + correspond to a 95% confidence level with respect to the + longitude and latitude values. |accuracy|. +
        12. +
        13. Initialize |coord|'s + {{GeolocationCoordinates/altitudeAccuracy}} attribute as + non-negative real number, or to `null` if the implementation + cannot provide altitude information. If the altitude accuracy + information is provided, it SHOULD correspond to a 95% + confidence level. to |altitudeAccuracy|. +
        14. +
        +
      2. Return a newly created {{GeolocationPosition}} instance with its {{GeolocationPosition/coords}} attribute initialized to |coords| and From fb86f6b6349c12e65f40b2dbea602d06b261e6fd Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Tue, 4 Jun 2024 13:32:41 +1000 Subject: [PATCH 02/10] Rewrite and use map --- index.html | 277 ++++++++++++++++++++++++++++------------------------- 1 file changed, 144 insertions(+), 133 deletions(-) diff --git a/index.html b/index.html index 06c8e95..463cfbf 100644 --- a/index.html +++ b/index.html @@ -838,27 +838,29 @@

        value of the |options|.{{PositionOptions/maximumAge}} member.

      3. -
      4. If - |cachedPosition|.{{GeolocationPosition/timestamp}}'s - value is greater than |cacheTime|, and - |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} - equals |options|.{{PositionOptions/enableHighAccuracy}}: -
        +
      5. + If |cachedPosition|'s + {{GeolocationPosition/timestamp}}'s value is greater + than |cacheTime|, and + |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} + equals + |options|.{{PositionOptions/enableHighAccuracy}}, set + |position| to |cachedPosition|. equals + |options|.{{PositionOptions/enableHighAccuracy}}: +
          +
        1. [=Queue a task=] on the [=geolocation task + source=] with a step that [=invokes=] + |successCallback| with |cachedPosition|. +
        2. +
        3. Terminate this algorithm. +
        4. +
    6. @@ -881,69 +883,70 @@

  • If acquiring the position data from the system succeeds: -
      -
    1. -
      - Candidate Correction: - Each acquired data type is now explicitly defined - with units and standards. -
        -
      1. - Let |latitude:double| be a real number of - degrees, in the [[WGS84]] coordinate - system. -
      2. -
      3. - Let |longitude:double| be a real number of - degrees, in the [[WGS84]] coordinate - system. -
      4. -
      5. - Let |altitude:double?| be a height, in - meters, above the [[WGS84]] ellipsoid or `null` - if not available. -
      6. -
      7. - Let |accuracy:double| be a non-negative real - number representing a 95% confidence level. -
      8. -
      9. - Let |altitudeAccuracy:double?| be a - non-negative real number or `null` if not - available, representing a 95% confidence - level. -
      10. -
      11. - Let |speed:double?| be a non-negative real - number of meters per second or `null` if not - available. -
      12. -
      13. - Let |heading:double?| be a real number of - degrees or `null` if not available. If the device - is stationary, set to NaN. -
      14. -
      -
      + +
        +
      1. Let |positionData| be a [=map=] that will hold the + acquired position data.
      2. -
      3. -
        - Candidate Correction: - Updated the parameters passed to the - `GeolocationPosition` constructor to align with the - new data specifications. - Set |position| to be [=a new - `GeolocationPosition`=] passing |latitude|, - |longitude|, |altitude|, |accuracy|, - |altitudeAccuracy|, |speed|, |heading|, - |acquisitionTime|, and - |options|.{{PositionOptions/enableHighAccuracy}}. -
        +
      4. Set |positionData|["longitude"] to represent the + longitude coordinates on the Earth's surface as a + {{double}} in degrees, using the [[WGS84]] coordinate + system. Longitude measures how far east or west a point + is from the Prime Meridian. +
      5. +
      6. Set |positionData|["altitude"] to represent the + altitude as a {{double?}} in meters above the [[WGS84]] + ellipsoid or `null` if not available. Altitude measures + the height above sea level. +
      7. +
      8. Set |positionData|["accuracy"] to represent the + accuracy as a non-negative {{double}} indicating the 95% + confidence level in meters. Accuracy measures how close + the measured coordinates are to the true position. +
      9. +
      10. Set |positionData|["altitudeAccuracy"] to represent + the altitude accuracy as a non-negative {{double?}} or + `null` if not available, indicating the 95% confidence + level in meters. Altitude accuracy measures how close the + measured altitude is to the true altitude. +
      11. +
      12. Set |positionData|["speed"] to represent the speed as + a non-negative {{double?}} in meters per second or `null` + if not available. Speed measures how fast the device is + moving. +
      13. +
      14. Set |positionData|["heading"] to represent the + heading as a {{double?}} in degrees or `null` if not + available. If the device is stationary, set to NaN. + Heading measures the direction in which the device is + moving relative to true north. +
      15. +
      16. Set |position| be [=a new `GeolocationPosition`=] + passing |positionData|, |acquisitionTime| and + |options|.{{PositionOptions/enableHighAccuracy}}.
      17. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to |position|.
      18. -
      +
    +
      +
    1. Set |position| be [=a new `GeolocationPosition`=] + passing |acquisitionTime| and + |options|.{{PositionOptions/enableHighAccuracy}}. +
    2. +
    3. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to + |position|. +
    4. +
  • Stop the |timeout|.
  • @@ -1272,69 +1275,77 @@

    Constructing a `GeolocationPosition`

    -
      -
    1. Let |positionData| be a [=map=] that will hold the - acquired position data. +
    2. Let |positionData| be a [=map=] with the following + name/value pairs based on the acquired the position data: +
      +
      +
      +
      + "longitude" +
      +
      + A {{double}} that represents the longitude + coordinates on the Earth's surface in degrees, + using the [[WGS84]] coordinate system. + Longitude measures how far east or west a point + is from the Prime Meridian. +
      +
      + "altitude" +
      +
      + A {{double?}} that represents the altitude in + meters above the [[WGS84]] ellipsoid, or `null` + if not available. Altitude measures the height + above sea level. +
      +
      + "accuracy" +
      +
      + A non-negative {{double}} that represents the + accuracy value indicating the 95% confidence + level in meters. Accuracy measures how close + the measured coordinates are to the true + position. +
      +
      + "altitudeAccuracy" +
      +
      + A non-negative {{double?}} that represents the + altitude accuracy, or `null` if not available, + indicating the 95% confidence level in meters. + Altitude accuracy measures how close the + measured altitude is to the true altitude. +
      +
      + "speed" +
      +
      + A non-negative {{double?}} that represents the + speed in meters per second, or `null` if not + available. Speed measures how fast the device + is moving. +
      +
      + "heading" +
      +
      + A {{double?}} that represents the heading in + degrees, or `null` if not available, or `NaN` + if the device is stationary. Heading measures + the direction in which the device is moving + relative to true north. +
      +
      +
      +
    3. -
    4. Set |positionData|["longitude"] to represent the - longitude coordinates on the Earth's surface as a - {{double}} in degrees, using the [[WGS84]] coordinate - system. Longitude measures how far east or west a point - is from the Prime Meridian. -
    5. -
    6. Set |positionData|["altitude"] to represent the - altitude as a {{double?}} in meters above the [[WGS84]] - ellipsoid or `null` if not available. Altitude measures - the height above sea level. -
    7. -
    8. Set |positionData|["accuracy"] to represent the - accuracy as a non-negative {{double}} indicating the 95% - confidence level in meters. Accuracy measures how close - the measured coordinates are to the true position. -
    9. -
    10. Set |positionData|["altitudeAccuracy"] to represent - the altitude accuracy as a non-negative {{double?}} or - `null` if not available, indicating the 95% confidence - level in meters. Altitude accuracy measures how close the - measured altitude is to the true altitude. -
    11. -
    12. Set |positionData|["speed"] to represent the speed as - a non-negative {{double?}} in meters per second or `null` - if not available. Speed measures how fast the device is - moving. -
    13. -
    14. Set |positionData|["heading"] to represent the - heading as a {{double?}} in degrees or `null` if not - available. If the device is stationary, set to NaN. - Heading measures the direction in which the device is - moving relative to true north. -
    15. -
    16. Set |position| be [=a new `GeolocationPosition`=] +
    17. Set |position| to [=a new `GeolocationPosition`=] passing |positionData|, |acquisitionTime| and |options|.{{PositionOptions/enableHighAccuracy}}.
    18. @@ -939,7 +970,7 @@

      -
    1. Set |position| be [=a new `GeolocationPosition`=] +
    2. Set |position| to [=a new `GeolocationPosition`=] passing |acquisitionTime| and |options|.{{PositionOptions/enableHighAccuracy}}.
    3. @@ -1278,8 +1309,8 @@

      A new `GeolocationPosition` is constructed with [=map=] From fa388fdf2074af335d81f0866a16caf96ac8abb4 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 5 Jun 2024 09:17:25 +1000 Subject: [PATCH 08/10] fixup --- index.html | 115 +++++++++++++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 60 deletions(-) diff --git a/index.html b/index.html index 2bd5c1f..0a53973 100644 --- a/index.html +++ b/index.html @@ -897,67 +897,62 @@

    4. Let |positionData| be a [=map=] with the following name/value pairs based on the acquired the position data:
      +
      + "longitude" +
      -
      -
      - "longitude" -
      -
      - A {{double}} that represents the longitude - coordinates on the Earth's surface in degrees, - using the [[WGS84]] coordinate system. - Longitude measures how far east or west a point - is from the Prime Meridian. -
      -
      - "altitude" -
      -
      - A {{double?}} that represents the altitude in - meters above the [[WGS84]] ellipsoid, or `null` - if not available. Altitude measures the height - above sea level. -
      -
      - "accuracy" -
      -
      - A non-negative {{double}} that represents the - accuracy value indicating the 95% confidence - level in meters. Accuracy measures how close - the measured coordinates are to the true - position. -
      -
      - "altitudeAccuracy" -
      -
      - A non-negative {{double?}} that represents the - altitude accuracy, or `null` if not available, - indicating the 95% confidence level in meters. - Altitude accuracy measures how close the - measured altitude is to the true altitude. -
      -
      - "speed" -
      -
      - A non-negative {{double?}} that represents the - speed in meters per second, or `null` if not - available. Speed measures how fast the device - is moving. -
      -
      - "heading" -
      -
      - A {{double?}} that represents the heading in - degrees, or `null` if not available, or `NaN` - if the device is stationary. Heading measures - the direction in which the device is moving - relative to true north. -
      -
      + A {{double}} that represents the longitude + coordinates on the Earth's surface in degrees, + using the [[WGS84]] coordinate system. Longitude + measures how far east or west a point is from the + Prime Meridian. +
      +
      + "altitude" +
      +
      + A {{double?}} that represents the altitude in + meters above the [[WGS84]] ellipsoid, or `null` if + not available. Altitude measures the height above + sea level. +
      +
      + "accuracy" +
      +
      + A non-negative {{double}} that represents the + accuracy value indicating the 95% confidence level + in meters. Accuracy measures how close the measured + coordinates are to the true position. +
      +
      + "altitudeAccuracy" +
      +
      + A non-negative {{double?}} that represents the + altitude accuracy, or `null` if not available, + indicating the 95% confidence level in meters. + Altitude accuracy measures how close the measured + altitude is to the true altitude. +
      +
      + "speed" +
      +
      + A non-negative {{double?}} that represents the + speed in meters per second, or `null` if not + available. Speed measures how fast the device is + moving. +
      +
      + "heading" +
      +
      + A {{double?}} that represents the heading in + degrees, or `null` if not available, or `NaN` if + the device is stationary. Heading measures the + direction in which the device is moving relative to + true north.
    5. From e6885cce63065a7fd0fb94fd01e2a8baa5d0d143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 14 Jun 2024 17:01:41 +1000 Subject: [PATCH 09/10] Update index.html Co-authored-by: Reilly Grant --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 0a53973..e338abb 100644 --- a/index.html +++ b/index.html @@ -963,7 +963,7 @@

    6. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to |position|.
    7. -

    +
    1. Set |position| to [=a new `GeolocationPosition`=] passing |acquisitionTime| and From 06a78810cbfa6a235fa54683425b27ca2e24357d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 14 Jun 2024 17:02:24 +1000 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Reilly Grant --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index e338abb..e81ac2a 100644 --- a/index.html +++ b/index.html @@ -895,7 +895,7 @@

      1. Let |positionData| be a [=map=] with the following - name/value pairs based on the acquired the position data: + name/value pairs based on the acquired position data:
        "longitude" @@ -1307,16 +1307,16 @@

        indicating high accuracy as arguments. We iterate over the map to set the attributes of the {{GeolocationCoordinates}}. -

        +

        A new `GeolocationPosition` is constructed with [=map=] |positionData|, {{EpochTimeStamp}} |timestamp:EpochTimeStamp| and boolean |isHighAccuracy| by performing the following steps: -

        +

        1. Let |coords:GeolocationCoordinates| be a newly created {{GeolocationCoordinates}} instance.
        2. -
        3. [=map/For Each=] |key| → |value| in |positionData|: +
        4. [=map/For each=] |key| → |value| in |positionData|:
          1. Set |coords|'s attribute named |key| to |value|.