Skip to content
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

Geozones RC2 fixes #2248

Merged
merged 2 commits into from
Nov 16, 2024
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
6 changes: 5 additions & 1 deletion js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,11 @@ var mspHelper = (function () {
break;

case MSPCodes.MSP2_INAV_GEOZONE:
var geozone = new Geozone(

if (data.buffer.byteLength == 0) {
break;
}
var geozone = new Geozone(
data.getUint8(1),
data.getUint8(2),
data.getInt32(3, true),
Expand Down
6 changes: 6 additions & 0 deletions locale/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4838,6 +4838,12 @@
"geozoneInvalidzone": {
"message": "Invalid Geozone(s) detected:"
},
"geozoneInvalidLat": {
"message": "Invalid latitude"
},
"geozoneInvalidLon": {
"message": "Invalid longitude"
},
"gezoneInvalidReasonNotCC": {
"message": "Not counter clockwise"
},
Expand Down
2 changes: 1 addition & 1 deletion tabs/advanced_tuning.html
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
-->
</div>
</div>
<div class="config-section gui_box grey">
<div id="geozoneSettings" class="config-section gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="GeozoneSettings"></div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions tabs/advanced_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ TABS.advanced_tuning.initialize = function (callback) {
$('.notFixedWingTuning').show();
}

if (!FC.isFeatureEnabled('GEOZONE')) {
$('#geozoneSettings').hide();
}

GUI.simpleBind();

i18n.localize();;
Expand Down
50 changes: 41 additions & 9 deletions tabs/mission_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,11 @@ TABS.mission_control.initialize = function (callback) {
width: 3,
})
})
]
],
});

vectorLayer.kind = "geozoneline";
vectorLayer.selection = false;
vectorLayer.kind = "geozonecircle";
vectorLayer.selection = true;

geozoneLines.push(vectorLayer);
map.addLayer(vectorLayer);
Expand Down Expand Up @@ -1748,17 +1748,49 @@ TABS.mission_control.initialize = function (callback) {
<span class="vertexNumber"></span> \
</td> \
<td> \
<input type="number" class="vertexLat" readonly/> \
<input type="number" class="vertexLat"/> \
</td> \
<td> \
<input type="number" class="vertexLon" readonly/> \
<input type="number" class="vertexLon"/> \
</td> \
</tr> \
');
const $row = $verticesTable.find('tr:last');
$row.find('.vertexNumber').text(vertex.getNumber() + 1);
$row.find('.vertexLat').val((vertex.getLatMap()).toLocaleString(['en-US'], {minimumFractionDigits: 7}));
$row.find('.vertexLon').val((vertex.getLonMap()).toLocaleString(['en-US'], {minimumFractionDigits: 7}));

$row.find('.vertexLat')
.val((vertex.getLatMap())
.toLocaleString(['en-US'], {minimumFractionDigits: 7}))
.on('change', event => {
const lat = $(event.currentTarget).val();
if (isNaN(lat) || lat < -90 || lat > 90) {
GUI.alert(i18n.getMessage("geozoneInvalidLat"));
$(event.currentTarget).val(vertex.getLatMap());
return;
}
vertex.setLat(lat * 1e7);
renderGeozoneOptions();
renderGeozonesOnMap();
updateGeozoneInfo();

});

$row.find('.vertexLon')
.val((vertex.getLonMap())
.toLocaleString(['en-US'], {minimumFractionDigits: 7}))
.on('change', event => {
const lat = $(event.currentTarget).val();
if (isNaN(lat) || lat < -180 || lat > 180) {
GUI.alert(i18n.getMessage("geozoneInvalidLon"));
$(event.currentTarget).val(vertex.getLonMap());
return;
}
vertex.setLon(lat * 1e7);
renderGeozoneOptions();
renderGeozonesOnMap();
updateGeozoneInfo();
});

$row.find('#removeVertex').on('click', event => {
if (selectedGeozone.getVerticesCount() > 3) {
selectedGeozone.dropVertex(vertex.getNumber());
Expand Down Expand Up @@ -2150,7 +2182,7 @@ TABS.mission_control.initialize = function (callback) {
*/
app.Drag.prototype.handleDragEvent = function (evt) {

if (tempMarker.kind == "safehomecircle") {
if (tempMarker.kind == "safehomecircle" || tempMarker.kind == "geozonecircle") {
return;
}

Expand Down Expand Up @@ -2213,7 +2245,7 @@ TABS.mission_control.initialize = function (callback) {
renderGeozoneOptions();
renderGeozonesOnMap();
updateGeozoneInfo();
}
}
};

/**
Expand Down