Skip to content

Conversation

@mikeller
Copy link
Member

Describe the pull request:

  • Bug fix
  • Functional change
  • New feature
  • Code cleanup
  • Build system change
  • Documentation change
  • Language translation

Pull request long description:

Pro forma pull request to generate test artifacts for the changes in the
libdivecomputer submodule.

Changes made:

Related issues:

Implements libdivecomputer/libdivecomputer#53.
Fixes subsurface/libdc#97.

Additional information:

Documentation change:

Mentions:

@github-actions
Copy link

Artifacts:
Subsurface-Linux-AppImage-6.0.5505-patch.1.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5505-patch.1.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Windows-6.0.5505-patch.1.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

Copy link
Collaborator

@dirkhh dirkhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a sane person would want this to be a float and not an integer is beyond me, but whatever. Appoved

@chaehni
Copy link

chaehni commented Dec 28, 2025

Thanks for opening the PR. I installed the Subsurface version created from this commit and imported a dive from my Perdix 2. However, i cannot see the coordinates anywhere. They are not in the location textbox nor under "Extra Info." This is my first computer with GPS capabilities, so it might be that I just don't know where to look.

@github-actions
Copy link

This pull request has merge conflicts, please resolve them in order to make this pull request ready for review / merge.

@mikeller
Copy link
Member Author

Thanks for opening the PR. I installed the Subsurface version created from this commit and imported a dive from my Perdix 2. However, i cannot see the coordinates anywhere. They are not in the location textbox nor under "Extra Info." This is my first computer with GPS capabilities, so it might be that I just don't know where to look.

Thanks for the feedback - as it turns out Subsurface uses a format for location reporting that predates location support in libdivecomputer. This will need some changes in Subsurface to make location support work for dive computers other than Garmin.

@dirkhh
Copy link
Collaborator

dirkhh commented Dec 29, 2025

I would rather fix the libdc code and match the way we get gps days from the Garmin
Random floats are not a reasonable way to do this.

This has been an ongoing debate and fundamental disagreement for a decade with many other examples.

@mikeller
Copy link
Member Author

why a sane person would want this to be a float and not an integer is beyond me, but whatever. Appoved

If I got a dollar each time I saw floats used for lat / lon in 'commercial grade' software I'd be filthy rich by now...

@dirkhh
Copy link
Collaborator

dirkhh commented Dec 29, 2025

If I got a cent (US$ or NZ$, doesn't matter), for every time I saw a stupid choice of data type and data transfer protocol or data encapsulation protocol, I could buy myself quite a few nice toys...

@mikeller
Copy link
Member Author

I would rather fix the libdc code and match the way we get gps days from the Garmin Random floats are not a reasonable way to do this.

This has been an ongoing debate and fundamental disagreement for a decade with many other examples.

Piggybacking on an 'extra info' filed with a specific name seems to be somewhat of a workaround - to me using a dedicated field for location seems to a more robust approach.

And doing our own thing here also comes with the risk that whenever libdivecomputer adds support for a dive computer, this will not push through into Subsurface unless somebody picks up on it and adds our own way - as has already happened for the DiveSystem, Divesoft, and Halcyon dive computers...

@mikeller
Copy link
Member Author

mikeller commented Jan 7, 2026

@dirkhh: Not sure where we want to take this from here?

I can see the following options:

  1. extend existing approach in Subsurface to use an Extra Info field with a special name to convey location information, and retrofit this to all dive computers that report location information (for now);
  2. leverage the the DC_FIELD_LOCATION approach that libdivecomputer has implemented for the dive computers supporting location (except for Garmin), and accept that using floats for lat / lon is a flawed approach;
  3. leverage DC_FIELD_LOCATION, but change it to use a fixed decimal notation for lat / lon.

The way I see it, 1. is not particularly sustainable as this will get us to play catch up whenever a new dive computer has got location support. And I really don't think that 'leverage special names for Extra Info to transmit data' is an approach that should be turned into best practice and used more widely. 2. gets us to swallow the frog of float lat / lons, but at least new dive computers will work out of the box. 3. is most work, but then it will fail fast and get us to update the backend for new dive computers if they support location, in order to make them build in Subsurface.

@dirkhh
Copy link
Collaborator

dirkhh commented Jan 7, 2026

I am frustrated with the choices that Jef makes. They are inconsistent and weird - but that hasn't changed in 15 years and is unlikely to change in the future. Let's go with the lowest effort approach of (2) and just move on.

@dirkhh
Copy link
Collaborator

dirkhh commented Jan 7, 2026

I would rather fix the libdc code and match the way we get gps days from the Garmin Random floats are not a reasonable way to do this.

This has been an ongoing debate and fundamental disagreement for a decade with many other examples.

in other words... this response is technically correct and something I still believe, but the effort isn't worth it

Pro forma pull request to generate test artifacts for the changes in the
libdivecomputer submodule.

Signed-off-by: Michael Keller <[email protected]>
Copilot AI review requested due to automatic review settings January 13, 2026 00:44
@mikeller mikeller force-pushed the add_shearwater_gps_location branch from 2fb56f1 to 10817fe Compare January 13, 2026 00:44
@github-actions
Copy link

Thank you for resolving the merge conflicts.

@github-actions
Copy link

Artifacts:
Subsurface-Linux-AppImage-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Windows-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@mikeller
Copy link
Member Author

@chaehni Can you please try importing again, with the latest artifacts?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@chaehni
Copy link

chaehni commented Jan 13, 2026

Hi @mikeller
Thank you for the update. I downloaded some of the newest dives to a fresh logbook. Unfortunately, I still can't see any location information.
One small thing I noticed, the linked artifact here in Github is called patch.2 whereas the file contained in the zip is patch.3.
Not sure if that is intended and makes a difference here.

@mikeller mikeller requested a review from Copilot January 13, 2026 21:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
bool got_location = false;
if (rc == DC_STATUS_SUCCESS) {
location_t location;
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The location variable is uninitialized before this check. The code should first populate location from dc_location (e.g., location.lat.udeg = dc_location.latitude; location.lon.udeg = dc_location.longitude;) before checking and using its values.

Suggested change
location_t location;
location_t location{};
// Populate the location from the dc_location obtained above.
location.lat.udeg = dc_location.latitude;
location.lon.udeg = dc_location.longitude;

Copilot uses AI. Check for mistakes.

if (location.lat.udeg && location.lon.udeg) {
char location_string[64];
snprintf(location_string, sizeof(location_string), "%.6f, %.6f", location.lat.udeg / 1000000.0, location.lon.udeg / 1000000.0);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 1000000.0 is used for coordinate conversion. Consider defining a named constant (e.g., MICRO_DEGREES_DIVISOR) to improve code clarity and maintainability.

Copilot uses AI. Check for mistakes.
Add support for importing the location of a dive from libdivecomputer's
DC_FIELD_LOCATION. Note that the backends that currently support this
are limited to only reporting one location (presumably the start
location of the dive), so any other information, like the end location,
is not imported.

Signed-off-by: Michael Keller <[email protected]>
@mikeller mikeller force-pushed the add_shearwater_gps_location branch from 10817fe to 62aaebd Compare January 13, 2026 21:23
@mikeller
Copy link
Member Author

Thanks @chaehni.

Hi @mikeller Thank you for the update. I downloaded some of the newest dives to a fresh logbook. Unfortunately, I still can't see any location information.

My bad, I removed the code that populates the location when I did the final cleanup of my test code before pushing. Fixed now.

One small thing I noticed, the linked artifact here in Github is called patch.2 whereas the file contained in the zip is patch.3. Not sure if that is intended and makes a difference here.

That's expected. It's a consequence of GitHub running the CICD build on a speculative merge of the pull request content into the target branch - so there's an extra commit in the version that is built.

@mikeller mikeller requested a review from Copilot January 13, 2026 21:32
@github-actions
Copy link

Artifacts:
Subsurface-Linux-AppImage-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

location.lon.udeg = lrint(dc_location.longitude * 1000000);

char location_string[64];
snprintf(location_string, sizeof(location_string), "%.6f, %.6f", location.lat.udeg / 1000000.0, location.lon.udeg / 1000000.0);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion from udeg (micro-degrees) to decimal degrees is duplicated here and in the subsequent create() call. Consider extracting this formatting logic into a helper function to avoid repetition and potential inconsistencies.

Copilot uses AI. Check for mistakes.

unregister_dive_from_dive_site(dive);
devdata->log->sites.create(location_string, location)->add_dive(dive);

Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label 'Start location' differs from the GPS string field labels (e.g., 'GPS', 'GPS1') used elsewhere in the code. Consider using a consistent naming convention such as 'GPS' or documenting why 'Start location' is used for DC_FIELD_LOCATION data.

Suggested change
// Store the structured libdivecomputer DC_FIELD_LOCATION as "Start location" to
// distinguish it from GPS string fields (e.g., "GPS", "GPS1") parsed via DC_FIELD_STRING.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Windows-6.0.5514-patch.2.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@chaehni
Copy link

chaehni commented Jan 13, 2026

Now it works!
Really cool. Thanks everyone. :)

Add location information on test files after libdivecomputer location
support has been added.

Signed-off-by: Michael Keller <[email protected]>
@github-actions
Copy link

Artifacts:
Subsurface-Linux-AppImage-6.0.5514-patch.3.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Android-6.0.5514-patch.3.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

@github-actions
Copy link

Artifacts:
Subsurface-Windows-6.0.5514-patch.3.pull-request.add-shearwater-gps-location
WARNING: Use at your own risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Swift GPS

3 participants