Use switch statement instead of if ... else if ... else ...
This commit is contained in:
parent
8907082a85
commit
e9bc0732c0
@ -575,15 +575,22 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) {
|
|||||||
|
|
||||||
assert.response(self.server, request, expectedResponse, function(res, err) {
|
assert.response(self.server, request, expectedResponse, function(res, err) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
var body;
|
|
||||||
|
|
||||||
if (res.headers['content-type'] === 'image/png') {
|
var body;
|
||||||
body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
switch (res.headers['content-type']) {
|
||||||
} else if (res.headers['content-type'] === 'application/x-protobuf') {
|
case 'image/png':
|
||||||
body = new mapnik.VectorTile(z, x, y);
|
body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||||
body.setDataSync(new Buffer(res.body, 'binary'));
|
break;
|
||||||
} else if (res.headers['content-type'] === 'application/json; charset=utf-8') {
|
case 'application/x-protobuf':
|
||||||
body = JSON.parse(res.body);
|
body = new mapnik.VectorTile(z, x, y);
|
||||||
|
body.setDataSync(new Buffer(res.body, 'binary'));
|
||||||
|
break;
|
||||||
|
case 'application/json; charset=utf-8':
|
||||||
|
body = JSON.parse(res.body);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
body = res.body
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(null, res, body);
|
next(null, res, body);
|
||||||
|
Loading…
Reference in New Issue
Block a user