Commit 0f54503d authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Updated P4C.js, allowed to filter pictures pointing to center in search

parent 06d0487a
......@@ -38,6 +38,7 @@ exports.default = function(req, res) {
* @apiParam {Long} [maxdate] The maximum timestamp for a given time range, in milliseconds since 1st january 1970 (Epoch)
* @apiParam {String} [use] The list of fetchers to use (comma-separated)
* @apiParam {String} [ignore] The list of fetchers to ignore (comma-separated)
* @apiParam {Number} [tocenter] Set to 1 to keep only pictures directed to given coordinates
*
* @apiSuccess {String} status The response status (OK)
* @apiSuccess {Array} pictures The retrieved pictures, see <a href="https://framagit.org/Pic4Carto/Pic4Carto.js/blob/master/doc/API.md#picture">details about the Picture object</a>.
......@@ -66,7 +67,8 @@ exports.searchAround = function(req, res) {
mindate: req.query.mindate ? parseInt(req.query.mindate) : undefined,
maxdate: req.query.maxdate ? parseInt(req.query.maxdate) : undefined,
usefetchers: req.query.use ? req.query.use.split(',') : undefined,
ignorefetchers: req.query.ignore ? req.query.ignore.split(',') : undefined
ignorefetchers: req.query.ignore ? req.query.ignore.split(',') : undefined,
towardscenter: req.query.tocenter ? req.query.tocenter === "1" : undefined
}
)
.then(pictures => {
......
......@@ -88,6 +88,13 @@ define({ "api": [
"optional": true,
"field": "ignore",
"description": "<p>The list of fetchers to ignore (comma-separated)</p>"
},
{
"group": "Parameter",
"type": "Number",
"optional": true,
"field": "tocenter",
"description": "<p>Set to 1 to keep only pictures directed to given coordinates</p>"
}
]
}
......
......@@ -88,6 +88,13 @@
"optional": true,
"field": "ignore",
"description": "<p>The list of fetchers to ignore (comma-separated)</p>"
},
{
"group": "Parameter",
"type": "Number",
"optional": true,
"field": "tocenter",
"description": "<p>Set to 1 to keep only pictures directed to given coordinates</p>"
}
]
}
......
......@@ -8,7 +8,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2017-10-20T18:21:56.557Z",
"time": "2017-12-07T19:44:45.092Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
......
......@@ -8,7 +8,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2017-10-20T18:21:56.557Z",
"time": "2017-12-07T19:44:45.092Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
......
......@@ -10,7 +10,7 @@
},
"repository": {
"type": "git",
"url": "git@framagit.org:PanierAvide/P4CaaS.git"
"url": "git@framagit.org:Pic4Carto/P4CaaS.git"
},
"keywords": [
"Pic4Carto",
......@@ -34,7 +34,7 @@
"body-parser": "^1.17.2",
"cors": "^2.8.4",
"express": "^4.15.3",
"pic4carto": "^2.0.1",
"pic4carto": "^2.0.2",
"use-strict": "^1.0.1",
"xmlhttprequest": "^1.8.0"
},
......
......@@ -210,6 +210,32 @@ describe('Server routes', function() {
done();
});
}).timeout(15000);
it("should return pictures on GET filtered by looking to center", function(done){
request(server)
.get("/search/around?lat=48.125&lng=-1.69&radius=250&mindate=1493596800000&maxdate=1498867200000")
.expect("Content-type",/json/)
.expect(200)
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.body.status, "OK");
assert.ok(res.body.pictures.length > 0);
const firstPics = res.body.pictures;
request(server)
.get("/search/around?lat=48.125&lng=-1.69&radius=250&mindate=1493596800000&maxdate=1498867200000&tocenter=1")
.expect("Content-type",/json/)
.expect(200)
.end(function(err, res){
assert.ok(res.status, 200);
assert.equal(res.body.status, "OK");
assert.ok(res.body.pictures.length > 0);
assert.ok(res.body.pictures.length < firstPics.length);
done();
});
});
}).timeout(30000);
});
describe('/fetchers', function() {
......
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