using final url /api/v1/map

This commit is contained in:
javi 2014-02-06 14:25:47 +01:00
parent 526de286a6
commit 95fcbffefc
2 changed files with 23 additions and 8 deletions

View File

@ -31,6 +31,10 @@
if (this.options.data_aggregation) {
this.options.cumulative = this.options.data_aggregation === 'cumulative';
}
if (this.options.auth_token) {
var e = this.options.extra_params || (this.options.extra_params = {});
e.auth_token = this.options.auth_token;
}
this._fetchMap();
};
@ -307,13 +311,13 @@
_fetchMap: function(callback) {
var self = this;
var layergroup = {};
var url = this._tilerHost() + "/api/v1/maps";
var url = this._tilerHost() + "/api/v1/map";
var named = this.options.named_map;
if(named) {
//tiles/template
url = this._tilerHost() + "/api/v1/maps/named/" + named.name + "/jsonp"
//url = this._tilerHost() + "/maps/" + named.name + "/jsonp"
url = this._tilerHost() + "/api/v1/map/named/" + named.name + "/jsonp"
//url = this._tilerHost() + "/map/" + named.name + "/jsonp"
} else {
layergroup = {
"version": "1.0.1",
@ -342,13 +346,12 @@
torque.net.jsonp(url, function (data) {
if (data) {
//TODO: update options with layer metadata
var torque_key = Object.keys(data.metadata.torque)[0]
var opt = data.metadata.torque[torque_key];
for(var k in opt) {
self.options[k] = opt[k];
}
self.templateUrl = self.url() + "/api/v1/maps/" + data.layergroupid + "/" + torque_key + "/{z}/{x}/{y}.json.torque";
self.templateUrl = self.url() + "/api/v1/map/" + data.layergroupid + "/" + torque_key + "/{z}/{x}/{y}.json.torque";
self._setReady(true);
}
});

View File

@ -45,7 +45,7 @@ module('provider.windshaft', {
}]
};
var url = "http://rambo.cartodb.com:80/tiles/layergroup?config=" + encodeURIComponent(JSON.stringify(layergroup)) + "&callback="
var url = "http://rambo.cartodb.com:80/api/v1/map?config=" + encodeURIComponent(JSON.stringify(layergroup)) + "&callback="
equal(lastCall.indexOf(url), 0);
equal(windshaft.options.data_steps, 10);
@ -68,15 +68,27 @@ module('provider.windshaft', {
name: 'test_named'
}
});
var url = "http://rambo.cartodb.com:80/tiles/template/test_named/jsonp?config";
var url = "http://rambo.cartodb.com:80/api/v1/map/named/test_named/jsonp?config";
equal(lastCall.indexOf(url), 0);
});
test("fetch tile", function() {
windshaft._ready = true;
windshaft.getTileData({x: 0, y: 1}, 2, function() {});
equal(lastCall,"http://rambo.cartodb.com:80/tiles/layergroup/testlg/0/2/0/1.json.torque?testing=abcd%25");
equal(lastCall,"http://rambo.cartodb.com:80/api/v1/map/testlg/0/2/0/1.json.torque?testing=abcd%25");
});
test("include auth_token", function() {
windshaft_named = new torque.providers.windshaft({
table: 'test',
user: "rambo",
auth_token: 'test_auth_token',
named_map: {
name: 'test_named'
}
});
ok(lastCall.indexOf("auth_token=test_auth_token") !== -1);
})