Skip to content

Commit cd5a951

Browse files
author
gondzo
committed
Merge branch 'nfzManagement' into dev
2 parents 70fdf3d + 1b61895 commit cd5a951

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

data/no-fly-zones.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"isPermanent": true,
4949
"mission": "594d77ec37275a4d97dddb0c",
5050
"style": {
51-
"fillColor": "#FF0000"
51+
"fillColor": "red"
5252
}
5353
},
5454
{
@@ -108,7 +108,7 @@
108108
"isPermanent": true,
109109
"mission": "594d77ec37275a4d97dddb0c",
110110
"style": {
111-
"fillColor": "#FF0000"
111+
"fillColor": "red"
112112
}
113113
},
114114
{
@@ -189,7 +189,7 @@
189189
"startTime": "2016-12-11T17:46:23.169Z",
190190
"endTime": "2030-12-11T17:46:23.169Z",
191191
"style": {
192-
"fillColor": "#FF0000"
192+
"fillColor": "yellow"
193193
}
194194
}
195195
]

models/NoFlyZone.js

+8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ const helper = require('../common/helper');
1616
const ObjectId = mongoose.Schema.Types.ObjectId;
1717
const Mixed = mongoose.Schema.Types.Mixed;
1818

19+
const CircleSchema = new mongoose.Schema({
20+
center: [Number],
21+
radius: Number,
22+
});
23+
1924
const NoFlyZoneSchema = new mongoose.Schema({
2025
location: {type: Mixed, required: true, index: '2dsphere'},
26+
// if defined, the polygon is an approximated circle
27+
// circle contains data for frontend
28+
circle: {type: CircleSchema, default: null},
2129
description: String,
2230
startTime: Date,
2331
endTime: Date,

services/MissionService.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ function* search(entity) {
6060
// the joi schema for getSingle
6161
getSingle.schema = {
6262
id: joi.string().required(),
63-
userId: joi.string().required(),
6463
};
6564

6665
/**
6766
* Get a mission identified by id
6867
*/
69-
function* getSingle(id, userId) {
68+
function* getSingle(id) {
7069
const mission = yield Mission.findOne({_id: id});
7170
if (!mission) {
7271
throw new errors.NotFoundError(`mission not found with specified id ${id}`);

services/NoFlyZoneService.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function* search(criteria) {
8989
$or: [
9090
{
9191
isPermanent: false,
92-
startTime: {$gte: new Date()},
93-
endTime: {$lte: new Date()},
92+
startTime: {$lte: new Date()},
93+
endTime: {$gte: new Date()},
9494
},
9595
{
9696
isPermanent: true,
@@ -105,6 +105,7 @@ function* search(criteria) {
105105
items: NoFlyZone
106106
.find(filter)
107107
.skip(criteria.offset)
108+
.sort('-id')
108109
.limit(criteria.limit),
109110
};
110111
}
@@ -134,9 +135,13 @@ function* create(values) {
134135
create.schema = {
135136
values: joi.object().keys({
136137
location: joi.geoJSON().required(),
138+
circle: {
139+
center: joi.array().items(joi.number()),
140+
radius: joi.number(),
141+
},
137142
description: joi.string().required(),
138-
startTime: joi.date().iso(),
139-
endTime: joi.date().iso(),
143+
startTime: joi.date().iso().allow(null),
144+
endTime: joi.date().iso().allow(null),
140145
style: joi.object(),
141146
isActive: joi.bool().required(),
142147
isPermanent: joi.bool().required(),
@@ -161,6 +166,10 @@ update.schema = {
161166
values: {
162167
id: joi.any().strip(),
163168
location: joi.geoJSON().required(),
169+
circle: joi.object({
170+
center: joi.array().items(joi.number()),
171+
radius: joi.number(),
172+
}).allow(null),
164173
description: joi.string().required(),
165174
startTime: joi.date().iso(),
166175
endTime: joi.date().iso(),

0 commit comments

Comments
 (0)