Regression: Accept layer option in the static map urls

This commit is contained in:
Raul Marin 2018-06-06 13:50:11 +02:00 committed by Raul Marin
parent db946b93ec
commit 102244f467
3 changed files with 28 additions and 3 deletions

View File

@ -11,7 +11,7 @@ Begin by instantiating either a Named or Anonymous Map using the `layergroupid t
#### Definition
```bash
GET /api/v1/map/static/center/{token}/{z}/{lat}/{lng}/{width}/{height}.{format}
GET /api/v1/map/static/center/{token}/{z}/{lat}/{lng}/{width}/{height}.{format}{{?}extra_options}
```
#### Params
@ -58,6 +58,9 @@ Note: you can see this endpoint as
GET /api/v1/map/static/bbox/{token}/{west},{south},{east},{north}/{width}/{height}.{format}`
```
#### Extra options
* Layer: List of layers to be shown in the image (by default `all`), for example `?layer=0,1`.
### Named Map
#### Definition

View File

@ -10,12 +10,13 @@ module.exports = function createMapStoreMapConfigProvider (
return function createMapStoreMapConfigProviderMiddleware (req, res, next) {
const { user, token, cache_buster, api_key } = res.locals;
const { dbuser, dbname, dbpassword, dbhost, dbport } = res.locals;
const { layer, z, x, y, scale_factor, format } = req.params;
const { layer: layerFromParams, z, x, y, scale_factor, format } = req.params;
const { layer: layerFromQuery } = req.query;
const params = {
user, token, cache_buster, api_key,
dbuser, dbname, dbpassword, dbhost, dbport,
layer, z, x, y, scale_factor, format
layer: (layerFromQuery || layerFromParams), z, x, y, scale_factor, format
};
if (forcedFormat) {

View File

@ -261,6 +261,27 @@ describe('named-maps analysis', function() {
);
});
it('should fail to retrieve static map preview via layergroup ' +
'when filtering by invalid layers', function(done) {
assert.response(
server,
{
url: '/api/v1/map/static/center/' + layergroupid + '/4/42/-3/320/240.png?layer=1',
method: 'GET',
encoding: 'binary',
headers: {
host: username
}
},
{
status: 400
},
function(res, err) {
done(err);
}
);
});
it('should return and an error requesting unsupported image format', function(done) {
assert.response(
server,