Commit 90c681ad authored by Roque's avatar Roque

erp5_officejs_drone_capture_flag: fix coordinates backward compatibility issue

parent 80699d25
......@@ -317,11 +317,16 @@ var DroneManager = /** @class */ (function () {
DroneManager.prototype.getCurrentPosition = function () {
if (this._controlMesh) {
// swap y and z axis so z axis represents altitude
return this._API.getCurrentPosition(
var position = this._API.getCurrentPosition(
this._controlMesh.position.x,
this._controlMesh.position.z,
this._controlMesh.position.y
);
//Backward compatibility sanitation
position.x = position.latitude;
position.y = position.longitude;
position.z = position.altitude;
return position;
}
return null;
};
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1011.46053.12382.23005</string> </value>
<value> <string>1011.57487.9176.36369</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1696871380.85</float>
<float>1697558075.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -82,10 +82,7 @@ var MapUtils = /** @class */ (function () {
return {
latitude: lat,
longitude: lon,
altitude: z,
x: lat,
y: lon,
z: z
altitude: z
};
};
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1011.50252.61779.34440</string> </value>
<value> <string>1011.57448.22674.29627</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1697123604.37</float>
<float>1697557365.44</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -50,34 +50,22 @@ var OperatorAPI = /** @class */ (function () {
"flag_list": [{"position":
{"latitude": 45.6464947316632,
"longitude": 14.270747186236491,
"altitude": 10,
"x": 45.6464947316632,
"y": 14.270747186236491,
"z": 10},
"altitude": 10},
"score": 1,
"weight": 1}],
"obstacle_list": [{"type": "box",
"position": {"latitude": 45.6456815316444,
"longitude": 14.274667031215898,
"altitude": 15,
"x": 45.6456815316444,
"y": 14.274667031215898,
"z": 15},
"altitude": 15},
"scale": {"x": 132, "y": 56, "z": 10},
"rotation": {"x": 0, "y": 0, "z": 0}}],
"enemy_list": [{"type": "EnemyDroneAPI",
"position": {"latitude": 45.6455531,
"longitude": 14.270747186236491,
"altitude": 15,
"x": 45.6455531,
"y": 14.270747186236491,
"z": 15}}],
"altitude": 15}}],
"initial_position": {"latitude": 45.642813275,
"longitude": 14.270231599999988,
"altitude": 15,
"x": 45.642813275,
"y": 14.270231599999988,
"z": 15}
"altitude": 15}
},
DEFAULT_SPEED = 16,
MAX_ACCELERATION = 6,
......@@ -190,9 +178,9 @@ var OperatorAPI = /** @class */ (function () {
' var random = Math.random() < 0.5, dodge_point = {};\n' +
' Object.assign(dodge_point, me.flag_positions[me.next_checkpoint].position);\n' +
' if (random) {\n' +
' dodge_point.x = dodge_point.x * -1;\n' +
' dodge_point.latitude = dodge_point.latitude * -1;\n' +
' } else {\n' +
' dodge_point.y = dodge_point.y * -1;\n' +
' dodge_point.longitude = dodge_point.longitude * -1;\n' +
' }\n' +
' me.setTargetCoordinates(dodge_point.latitude, dodge_point.longitude, me.getCurrentPosition().altitude);\n' +
' return;\n' +
......@@ -307,6 +295,27 @@ var OperatorAPI = /** @class */ (function () {
function renderMapParameterView(gadget) {
var form_gadget;
renderGadgetHeader(gadget, true);
//Drop backward compatibility sanitation
function sanitize(position) {
delete position.x;
delete position.y;
delete position.z;
return position;
}
var map_json = JSON.parse(gadget.state.map_json);
map_json.initial_position = sanitize(map_json.initial_position);
map_json.flag_list.forEach(function (flag, index) {
flag.position = sanitize(flag.position);
});
map_json.obstacle_list.forEach(function (obstacle, index) {
obstacle.position = sanitize(obstacle.position);
});
map_json.enemy_list.forEach(function (enemy, index) {
enemy.position = sanitize(enemy.position);
});
gadget.state.map_json = JSON.stringify(map_json, undefined, 4);
return gadget.declareGadget("gadget_erp5_form.html", {
scope: "parameter_form"
})
......@@ -739,6 +748,10 @@ var OperatorAPI = /** @class */ (function () {
position.latitude = position.x;
position.longitude = position.y;
position.altitude = position.z;
} else if (!position.x) {
position.x = position.latitude;
position.y = position.longitude;
position.z = position.altitude;
}
return position;
}
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1011.50269.22753.36317</string> </value>
<value> <string>1011.57494.145.60023</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1697124355.48</float>
<float>1697558059.95</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment