Commit 154821e1 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Updating P4C.js version (breaking changes)

parent e5d5231d
......@@ -40,7 +40,7 @@ exports.default = function(req, res) {
* @apiParam {String} [ignore] The list of fetchers to ignore (comma-separated)
*
* @apiSuccess {String} status The response status (OK)
* @apiSuccess {Array} pictures The retrieved pictures, see <a href="https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture">details about the Picture object</a>.
* @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>.
*/
exports.searchAround = function(req, res) {
/*console.log("[SEARCH] "
......@@ -53,11 +53,6 @@ exports.searchAround = function(req, res) {
const picManager = new P4C.PicturesManager({ fetcherCredentials: CREDENTIALS });
//Prepare event for when pictures are downloaded
picManager.on("picsready", function(pictures) {
res.json({ "status": "OK", "pictures": pictures });
});
picManager.on("fetcherfailed", function(fetcherId) {
console.log("[SEARCH] Failed on fetcher "+fetcherId);
});
......@@ -73,7 +68,13 @@ exports.searchAround = function(req, res) {
usefetchers: req.query.use ? req.query.use.split(',') : undefined,
ignorefetchers: req.query.ignore ? req.query.ignore.split(',') : undefined
}
);
)
.then(pictures => {
res.json({ "status": "OK", "pictures": pictures });
})
.catch(e => {
throw e;
});
}
catch(e) {
res.status(500).send({ "status": "NOTOK", "error": e.toString() });
......@@ -96,7 +97,7 @@ exports.searchAround = function(req, res) {
* @apiParam {String} [ignore] The list of fetchers to ignore (comma-separated)
*
* @apiSuccess {String} status The response status (OK)
* @apiSuccess {Array} pictures The retrieved pictures, see <a href="https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture">details about the Picture object</a>.
* @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>.
*/
exports.searchBbox = function(req, res) {
/*console.log("[SEARCH] BBox "
......@@ -107,11 +108,6 @@ exports.searchBbox = function(req, res) {
const picManager = new P4C.PicturesManager({ fetcherCredentials: CREDENTIALS });
//Prepare event for when pictures are downloaded
picManager.on("picsready", function(pictures) {
res.json({ "status": "OK", "pictures": pictures });
});
picManager.on("fetcherfailed", function(fetcherId) {
console.log("[SEARCH] Failed on fetcher "+fetcherId);
});
......@@ -126,7 +122,13 @@ exports.searchBbox = function(req, res) {
usefetchers: req.query.use ? req.query.use.split(',') : undefined,
ignorefetchers: req.query.ignore ? req.query.ignore.split(',') : undefined
}
);
)
.then(pictures => {
res.json({ "status": "OK", "pictures": pictures });
})
.catch(e => {
throw e;
});
}
catch(e) {
res.status(500).send({ "status": "NOTOK", "error": e.toString() });
......@@ -173,11 +175,6 @@ exports.summaryBbox = function(req, res) {
const picManager = new P4C.PicturesManager({ fetcherCredentials: CREDENTIALS });
//Prepare event for when summary is ready
picManager.on("summaryready", function(summary) {
res.json({ "status": "OK", "summary": summary });
});
picManager.on("fetcherfailed", function(fetcherId) {
console.log("[SUMMARY] Failed on fetcher "+fetcherId);
});
......@@ -190,7 +187,13 @@ exports.summaryBbox = function(req, res) {
mindate: req.query.mindate ? parseInt(req.query.mindate) : undefined,
maxdate: req.query.maxdate ? parseInt(req.query.maxdate) : undefined
}
);
)
.then(summary => {
res.json({ "status": "OK", "summary": summary });
})
.catch(e => {
throw e;
});
}
catch(e) {
res.status(500).send({ "status": "NOTOK", "error": e.toString() });
......
......@@ -107,7 +107,7 @@ define({ "api": [
"type": "Array",
"optional": false,
"field": "pictures",
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/Pic4Carto/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
}
]
}
......@@ -200,7 +200,7 @@ define({ "api": [
"type": "Array",
"optional": false,
"field": "pictures",
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/Pic4Carto/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
}
]
}
......
......@@ -107,7 +107,7 @@
"type": "Array",
"optional": false,
"field": "pictures",
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/Pic4Carto/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
}
]
}
......@@ -200,7 +200,7 @@
"type": "Array",
"optional": false,
"field": "pictures",
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/PanierAvide/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
"description": "<p>The retrieved pictures, see <a href=\"https://framagit.org/Pic4Carto/Pic4Carto.js/blob/master/doc/API.md#picture\">details about the Picture object</a>.</p>"
}
]
}
......
......@@ -8,7 +8,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2017-10-20T18:00:42.670Z",
"time": "2017-10-20T18:20:13.809Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
......
......@@ -8,7 +8,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2017-10-20T18:00:42.670Z",
"time": "2017-10-20T18:20:13.809Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
......
......@@ -98,14 +98,14 @@ describe('Server routes', function() {
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.body.status, "OK");
assert.equal(res.body.pictures.length, 31);
assert.equal(res.body.pictures[0].pictureUrl, "https://d1cuyjsrcm0gby.cloudfront.net/eJMBmO6ndsHysDHsSHdhuQ/thumb-2048.jpg");
assert.equal(res.body.pictures.length, 30);
assert.equal(res.body.pictures[0].pictureUrl, "https://d1cuyjsrcm0gby.cloudfront.net/vtsgTa39W_TuXTOrFBgD8A/thumb-2048.jpg");
assert.ok(res.body.pictures[0].date > 0);
assert.ok(res.body.pictures[0].coordinates !== undefined);
assert.equal(res.body.pictures[0].provider, "Mapillary");
assert.equal(res.body.pictures[0].author, "panieravide");
assert.equal(res.body.pictures[0].license, "CC By-SA 4.0");
assert.equal(res.body.pictures[0].detailsUrl, "https://www.mapillary.com/app/?pKey=eJMBmO6ndsHysDHsSHdhuQ&lat=48.127471560000004&lng=-1.6850350500000104&focus=photo");
assert.equal(res.body.pictures[0].detailsUrl, "https://www.mapillary.com/app/?pKey=vtsgTa39W_TuXTOrFBgD8A&lat=48.12742294999998&lng=-1.685248060000049&focus=photo");
done();
});
}).timeout(15000);
......@@ -144,7 +144,7 @@ describe('Server routes', function() {
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.body.status, "OK");
assert.equal(res.body.pictures.length, 20);
assert.equal(res.body.pictures.length, 19);
for(const p of res.body.pictures) {
assert.equal(p.provider, "OpenStreetCam");
}
......
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