Skip to content

Commit 9a51c47

Browse files
(models) remove format parameter in findBoxById
1 parent 2502491 commit 9a51c47

File tree

4 files changed

+2
-31
lines changed

4 files changed

+2
-31
lines changed

packages/models/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @sensebox/opensensemap-api-models Changelog
22

33
## Unreleased
4+
- Remove format argument of findBoxById
45

56
## v0.0.9
67
- Fix measurements with 'content-type: json' not parsed with JSON.parse.

packages/models/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"dependencies": {
88
"@sensebox/osem-protos": "^1.1.0",
99
"@sensebox/sketch-templater": "^1.1.1",
10-
"@turf/helpers": "^4.6.0",
1110
"bcrypt": "^1.0.2",
1211
"bunyan": "^1.8.12",
1312
"config": "^1.29.2",

packages/models/src/box/box.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const { mongoose } = require('../db'),
1616
ModelError = require('../modelError'),
1717
Sketcher = require('@sensebox/sketch-templater'),
1818
fs = require('fs'),
19-
{ point } = require('@turf/helpers'),
2019
log = require('../log');
2120

2221
const templateSketcher = new Sketcher();
@@ -242,7 +241,7 @@ boxSchema.statics.initNew = function ({
242241

243242
};
244243

245-
boxSchema.statics.findBoxById = function findBoxById (id, { lean = true, populate = true, includeSecrets = false, onlyLastMeasurements = false, onlyLocations = false, format, projection = {} } = {}) {
244+
boxSchema.statics.findBoxById = function findBoxById (id, { lean = true, populate = true, includeSecrets = false, onlyLastMeasurements = false, onlyLocations = false, projection = {} } = {}) {
246245
let fullBox = populate;
247246
if (populate) {
248247
Object.assign(projection, BOX_PROPS_FOR_POPULATION);
@@ -281,14 +280,6 @@ boxSchema.statics.findBoxById = function findBoxById (id, { lean = true, populat
281280
throw new ModelError('Box not found', { type: 'NotFoundError' });
282281
}
283282

284-
if (format === 'geojson') {
285-
const coordinates = box.currentLocation.coordinates;
286-
box.currentLocation = undefined;
287-
box.loc = undefined;
288-
289-
return point(coordinates, box);
290-
}
291-
292283
if (fullBox === true) {
293284
// fill in box.loc manually, as toJSON & virtuals are not supported in lean queries.
294285
box.loc = [{ geometry: box.currentLocation, type: 'Feature' }];

packages/models/test/tests/1-box.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -299,26 +299,6 @@ describe('Box model', function () {
299299
});
300300
});
301301

302-
it('should allow to return box as geojson', function () {
303-
const boxId = Object.keys(testBoxes)[0];
304-
305-
return Box.findBoxById(boxId, { format: 'geojson' }).then(function (
306-
geojsonBox
307-
) {
308-
expect(geojsonBox).an('object');
309-
expect(geojsonBox.type).equal('Feature');
310-
expect(geojsonBox.geometry).an('object');
311-
312-
expect(geojsonBox.geometry.coordinates).an('array');
313-
expect(geojsonBox.geometry.coordinates).lengthOf.within(2, 3);
314-
for (const coord of geojsonBox.geometry.coordinates) {
315-
expect(coord).a('number');
316-
}
317-
expect(Math.abs(geojsonBox.geometry.coordinates[0])).most(180);
318-
expect(Math.abs(geojsonBox.geometry.coordinates[1])).most(90);
319-
});
320-
});
321-
322302
it('should allow to disable population and specify own projection', function () {
323303
const boxId = Object.keys(testBoxes)[0];
324304

0 commit comments

Comments
 (0)