@bluedot-innovation/models 10.0.0-beta-6 → 10.0.0-beta-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,6 +33,14 @@ testCase('Circle', () => {
|
|
|
33
33
|
const res = await Circle.validate()
|
|
34
34
|
assert.notExists(res)
|
|
35
35
|
})
|
|
36
|
+
|
|
37
|
+
assertions('should transfer integer coordinate to double', async () => {
|
|
38
|
+
circle.center.longitude = 144
|
|
39
|
+
circle.center.latitude = -37
|
|
40
|
+
let Circle = new CircleModelBuiltInMongoose(circle)
|
|
41
|
+
assert.equal(Circle.center.longitude, 144.0000001)
|
|
42
|
+
assert.equal(Circle.center.latitude, -37.0000001)
|
|
43
|
+
})
|
|
36
44
|
})
|
|
37
45
|
|
|
38
46
|
testCase('Invalid Circle', () => {
|
package/helpers.js
CHANGED
|
@@ -268,12 +268,7 @@ helpers.validateNoDuplicateReportConfigurations = function(reportConfigArray) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
helpers.transformNumbertoDouble = (value) => {
|
|
271
|
-
|
|
272
|
-
return value === null ? null : parseFloat(value).toFixed(6)
|
|
273
|
-
} catch(err) {
|
|
274
|
-
return value
|
|
275
|
-
}
|
|
276
|
-
|
|
271
|
+
return Number.isInteger(value) ? Number.parseFloat(`${value}.0000001`) : value
|
|
277
272
|
}
|
|
278
273
|
|
|
279
274
|
module.exports = helpers
|
|
@@ -2,7 +2,6 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
let ZoneEnum = require('@bluedot-innovation/enums').ZoneEnum
|
|
3
3
|
let Point = require('../../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
|
-
const { transformNumbertoDouble } = require('../../helpers')
|
|
6
5
|
|
|
7
6
|
let schema = {
|
|
8
7
|
_id: {type: String, default: uuidv4},
|
|
@@ -12,7 +11,6 @@ let schema = {
|
|
|
12
11
|
accuracy: {type: String, enum: Object.values(ZoneEnum.fenceAccuracy)},
|
|
13
12
|
radius: {
|
|
14
13
|
type: Number,
|
|
15
|
-
set: transformNumbertoDouble,
|
|
16
14
|
required: [true, 'radius is required. '],
|
|
17
15
|
validate: {
|
|
18
16
|
validator: function(v) {
|
package/package.json
CHANGED