Skip to content

Commit

Permalink
Avoid confusing use of "waypoints" for GPS log data
Browse files Browse the repository at this point in the history
The HX870's GPS log functionality stores a history of past positions. This is completely unrelated to the radio's navigation functionality with routes and waypoints. To avoid confusion, the term "waypoints" should be avoided in the context of the GPS log.

This change replaces "waypoints" with "trackpoints", which is used by GPX for this purpose. Alternatives include simply "points" or "positions".
  • Loading branch information
johannessen committed Oct 24, 2019
1 parent aeff5ec commit 5b3309a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hxtool/cli/gpslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run(self):

stat = hx.comm.read_gps_log_status()
logger.info(f"Log size {stat['pages_used'] * 4}kB, "
f"{stat['slots_used']} waypoints, "
f"{stat['slots_used']} trackpoints, "
f"{stat['usage_percent']}% full")
if stat["full_stop"]:
logger.warning("Log is full. Logging is halted until erased")
Expand Down Expand Up @@ -116,14 +116,14 @@ def decode_gps_log(data: bytes) -> dict or None:
log = {
"header": hexlify(log_header).decode("ascii"),
"unknown": hexlify(unknown).decode("ascii"),
"waypoints": []
"trackpoints": []
}

offset = 0x40
while offset <= len(data) - 20:
if data[offset:offset+4] == b"\xff\xff\xff\xff":
break
log["waypoints"].append(unpack_log_line(data[offset:offset+20]))
log["trackpoints"].append(unpack_log_line(data[offset:offset+20]))
offset += 20

return log
Expand All @@ -146,7 +146,7 @@ def write_gpx(log_data: bytes, file_name: str) -> int:
gpx_track.segments.append(gpx_segment)

# Create points:
for point in log["waypoints"]:
for point in log["trackpoints"]:
p = gpxpy.gpx.GPXTrackPoint(
latitude=point["latitude"],
longitude=point["longitude"],
Expand All @@ -169,7 +169,7 @@ def write_json(log_data: bytes, file_name: str) -> int:
if log is None:
logger.warning("Log is blank. Not writing empty JSON log")
return 0
for w in log["waypoints"]:
for w in log["trackpoints"]:
w["utc_time"] = w["utc_time"].isoformat()
with open(file_name, "w") as f:
dump(log, f, indent=4)
Expand All @@ -195,7 +195,7 @@ def dump_log(log_data):
if log is None:
logger.info("Log is blank. Nothing to print")
return 0
for wp in log["waypoints"]:
for wp in log["trackpoints"]:
lat_deg, lat_min = to_hm(wp['latitude'])
lat_dir = 'N' if lat_deg >= 0 else 'S'
lon_deg, lon_min = to_hm(wp['longitude'])
Expand Down

0 comments on commit 5b3309a

Please sign in to comment.