Skip to content

Update latlon #4349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2957,9 +2957,13 @@
"gpsAltitude": {
"message": "Altitude:"
},
"gpsLatLon": {
"message": "Current Latitude / Longitude:",
"description": "Show GPS position - Latitude / Longitude"
"gpsLatitude": {
"message": "Latitude:",
"description": "Show GPS position - Latitude"
},
"gpsLongitude": {
"message": "Longitude:",
"description": "Show GPS position - Longitude"
Comment on lines +2960 to +2966
Copy link
Member

Choose a reason for hiding this comment

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

The Current is not needed anymore? I think remember it was "included" some time ago to differentiate with the Home Latitude / Longitude.

Copy link
Member

Choose a reason for hiding this comment

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

It seems it was a not merged PR... #3486

},
"gpsHeading": {
"message": "Heading IMU / GPS:",
Expand Down
4 changes: 2 additions & 2 deletions src/js/VirtualFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ const VirtualFC = {
const sampleGpsData = {
fix: 2,
numSat: 10,
lat: 474919409,
lon: 190539766,
latitude: 474919409,
longitude: 190539766,
alt: 0,
speed: 0,
ground_course: 1337,
Expand Down
4 changes: 2 additions & 2 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ const FC = {
this.GPS_DATA = {
fix: 0,
numSat: 0,
lat: 0,
lon: 0,
latitude: 0,
longitude: 0,
alt: 0,
speed: 0,
ground_course: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ MspHelper.prototype.process_data = function (dataHandler) {
case MSPCodes.MSP_RAW_GPS:
FC.GPS_DATA.fix = data.readU8();
FC.GPS_DATA.numSat = data.readU8();
FC.GPS_DATA.lat = data.read32();
FC.GPS_DATA.lon = data.read32();
FC.GPS_DATA.latitude = data.read32();
FC.GPS_DATA.longitude = data.read32();
FC.GPS_DATA.alt = data.readU16();
FC.GPS_DATA.speed = data.readU16();
FC.GPS_DATA.ground_course = data.readU16();
Expand Down
17 changes: 10 additions & 7 deletions src/js/tabs/gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ gps.initialize = async function (callback) {
}

function update_ui() {
const lat = FC.GPS_DATA.lat / 10000000;
const lon = FC.GPS_DATA.lon / 10000000;
const url = `https://maps.google.com/?q=${lat},${lon}`;
const latitude = FC.GPS_DATA.latitude / 10000000;
const longitude = FC.GPS_DATA.longitude / 10000000;
const url = `https://maps.google.com/?q=${latitude},${longitude}`;
const imuHeadingDegrees = FC.SENSOR_DATA.kinematics[2];
// Convert to radians and add 180 degrees to make icon point in the right direction
const imuHeadingRadians = ((imuHeadingDegrees + 180) * Math.PI) / 180;
Expand All @@ -353,9 +353,12 @@ gps.initialize = async function (callback) {

const gpsUnitText = i18n.getMessage("gpsPositionUnit");
$(".GPS_info td.alt").text(`${alt} m`);
$(".GPS_info td.latLon a")
$(".GPS_info td.latitude a")
.prop("href", url)
.text(`${lat.toFixed(6)} / ${lon.toFixed(6)} ${gpsUnitText}`);
.text(`${latitude.toFixed(6)} ${gpsUnitText}`);
$(".GPS_info td.longitude a")
.prop("href", url)
.text(`${longitude.toFixed(6)} ${gpsUnitText}`);
$(".GPS_info td.heading").text(`${imuHeadingDegrees.toFixed(0)} / ${gpsHeading.toFixed(0)} ${gpsUnitText}`);
$(".GPS_info td.speed").text(`${FC.GPS_DATA.speed} cm/s`);
$(".GPS_info td.sats").text(FC.GPS_DATA.numSat);
Expand Down Expand Up @@ -384,12 +387,12 @@ gps.initialize = async function (callback) {
if (ispConnected()) {
$("#connect").hide();

gpsFoundPosition = !!(lon && lat);
gpsFoundPosition = !!(longitude && latitude);

if (gpsFoundPosition) {
(hasMag ? iconStyleMag : iconStyleGPS).getImage().setRotation(imuHeadingRadians);
iconFeature.setStyle(hasMag ? iconStyleMag : iconStyleGPS);
const center = fromLonLat([lon, lat]);
const center = fromLonLat([longitude, latitude]);
mapView.setCenter(center);
iconGeometry.setCoordinates(center);
} else {
Expand Down
13 changes: 8 additions & 5 deletions src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,16 @@ setup.initialize = function (callback) {
gpsFix_e.toggleClass("ready", FC.GPS_DATA.fix != 0);
gpsSats_e.text(FC.GPS_DATA.numSat);

const lat = FC.GPS_DATA.lat / 10000000;
const lon = FC.GPS_DATA.lon / 10000000;
const url = `https://maps.google.com/?q=${lat},${lon}`;
const latitude = FC.GPS_DATA.latitude / 10000000;
const longitude = FC.GPS_DATA.longitude / 10000000;
const url = `https://maps.google.com/?q=${latitude},${longitude}`;
const gpsUnitText = i18n.getMessage("gpsPositionUnit");
$(".GPS_info td.latLon a")
$(".GPS_info td.latitude a")
.prop("href", url)
.text(`${lat.toFixed(4)} / ${lon.toFixed(4)} ${gpsUnitText}`);
.text(`${latitude.toFixed(4)} ${gpsUnitText}`);
$(".GPS_info td.longitude a")
.prop("href", url)
.text(`${longitude.toFixed(4)} ${gpsUnitText}`);
}

function get_fast_data() {
Expand Down
8 changes: 6 additions & 2 deletions src/tabs/gps.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@
<td class="heading"></td>
</tr>
<tr>
<td i18n="gpsLatLon"></td>
<td class="latLon"><a href="#" target="_blank">0.0000 deg</a></td>
<td i18n="gpsLatitude"></td>
<td class="latitude"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr>
<td i18n="gpsLongitude"></td>
<td class="longitude"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr>
<td i18n="gpsDistToHome"></td>
Expand Down
8 changes: 6 additions & 2 deletions src/tabs/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@
<td class="gpsSats"></td>
</tr>
<tr>
<td i18n="gpsLatLon"></td>
<td class="latLon"><a href="#" target="_blank">0.0000 deg</a></td>
<td i18n="gpsLatitude"></td>
<td class="latitude"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
<tr>
<td i18n="gpsLongitude"></td>
<td class="longitude"><a href="#" target="_blank">0.0000 deg</a></td>
</tr>
</tbody>
</table>
Expand Down