Merge branch 'master' into aequus
This commit is contained in:
commit
30e7f3fca9
4
NEWS
4
NEWS
@ -1,6 +1,10 @@
|
|||||||
|
2.11.3
|
||||||
|
- Limited sprite radius to a maximum of 255px
|
||||||
|
- Fixed custom marker-file functionality in Firefox
|
||||||
2.11.2
|
2.11.2
|
||||||
- Added error handling to Torque
|
- Added error handling to Torque
|
||||||
- Fixed 'remove' event triggering when removing a Torque layer.
|
- Fixed 'remove' event triggering when removing a Torque layer.
|
||||||
|
- Value is now capped at 255 instead of performing modulo on higher values.
|
||||||
2.11.1
|
2.11.1
|
||||||
- Adapts usage of marker-opacity to Mapnik's functionality
|
- Adapts usage of marker-opacity to Mapnik's functionality
|
||||||
- Added getValueForBBox to TorqueLayer's API
|
- Added getValueForBBox to TorqueLayer's API
|
||||||
|
14
dist/torque.full.js
vendored
14
dist/torque.full.js
vendored
File diff suppressed because one or more lines are too long
104
dist/torque.full.uncompressed.js
vendored
104
dist/torque.full.uncompressed.js
vendored
@ -669,6 +669,7 @@ module.exports.TorqueLayer = TorqueLayer;
|
|||||||
// types
|
// types
|
||||||
var types = {
|
var types = {
|
||||||
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
||||||
|
Uint8ClampedArray: typeof(global['Uint8ClampedArray']) !== 'undefined' ? global.Uint8ClampedArray: Array,
|
||||||
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
||||||
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
||||||
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
||||||
@ -1613,6 +1614,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
|
|
||||||
this.provider = new this.providers[this.options.provider](this.options);
|
this.provider = new this.providers[this.options.provider](this.options);
|
||||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
||||||
|
this.renderer.options.errorCallback = this.options.errorCallback;
|
||||||
|
|
||||||
// this listener should be before tile loader
|
// this listener should be before tile loader
|
||||||
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
||||||
@ -1643,6 +1645,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSQL: function(sql) {
|
setSQL: function(sql) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||||
if (!this.provider || !this.provider.setSQL) {
|
if (!this.provider || !this.provider.setSQL) {
|
||||||
throw new Error("this provider does not support SQL");
|
throw new Error("this provider does not support SQL");
|
||||||
}
|
}
|
||||||
@ -1787,6 +1790,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
* set the cartocss for the current renderer
|
* set the cartocss for the current renderer
|
||||||
*/
|
*/
|
||||||
setCartoCSS: function(cartocss) {
|
setCartoCSS: function(cartocss) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||||
var shader = new carto.RendererJS().render(cartocss);
|
var shader = new carto.RendererJS().render(cartocss);
|
||||||
this.shader = shader;
|
this.shader = shader;
|
||||||
if (this.renderer) {
|
if (this.renderer) {
|
||||||
@ -1815,6 +1819,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
|
this.fire('remove');
|
||||||
CanvasLayer.prototype.onRemove.call(this);
|
CanvasLayer.prototype.onRemove.call(this);
|
||||||
this.animator.stop();
|
this.animator.stop();
|
||||||
this._removeTileLoader();
|
this._removeTileLoader();
|
||||||
@ -1855,6 +1860,11 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function (callback) {
|
||||||
|
this.options.errorCallback = callback;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -2138,6 +2148,11 @@ L.CanvasLayer = L.Class.extend({
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
error: function (callback) {
|
||||||
|
this.provider.options.errorCallback = callback;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
setOpacity: function (opacity) {
|
setOpacity: function (opacity) {
|
||||||
this.options.opacity = opacity;
|
this.options.opacity = opacity;
|
||||||
this._updateOpacity();
|
this._updateOpacity();
|
||||||
@ -2493,6 +2508,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function(map) {
|
onRemove: function(map) {
|
||||||
|
this.fire('remove');
|
||||||
this._removeTileLoader();
|
this._removeTileLoader();
|
||||||
map.off({
|
map.off({
|
||||||
'zoomend': this._clearCaches,
|
'zoomend': this._clearCaches,
|
||||||
@ -2533,6 +2549,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSQL: function(sql) {
|
setSQL: function(sql) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||||
if (!this.provider || !this.provider.setSQL) {
|
if (!this.provider || !this.provider.setSQL) {
|
||||||
throw new Error("this provider does not support SQL");
|
throw new Error("this provider does not support SQL");
|
||||||
}
|
}
|
||||||
@ -2693,6 +2710,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
* set the cartocss for the current renderer
|
* set the cartocss for the current renderer
|
||||||
*/
|
*/
|
||||||
setCartoCSS: function(cartocss) {
|
setCartoCSS: function(cartocss) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||||
if (!this.renderer) throw new Error('renderer is not valid');
|
if (!this.renderer) throw new Error('renderer is not valid');
|
||||||
var shader = new carto.RendererJS().render(cartocss);
|
var shader = new carto.RendererJS().render(cartocss);
|
||||||
this.renderer.setShader(shader);
|
this.renderer.setShader(shader);
|
||||||
@ -3867,6 +3885,7 @@ var Profiler = require('../profiler');
|
|||||||
var Uint8Array = torque.types.Uint8Array;
|
var Uint8Array = torque.types.Uint8Array;
|
||||||
var Int32Array = torque.types.Int32Array;
|
var Int32Array = torque.types.Int32Array;
|
||||||
var Uint32Array = torque.types.Uint32Array;
|
var Uint32Array = torque.types.Uint32Array;
|
||||||
|
var Uint8ClampedArray = torque.types.Uint8ClampedArray;
|
||||||
|
|
||||||
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
||||||
function format(str) {
|
function format(str) {
|
||||||
@ -3879,7 +3898,7 @@ var Profiler = require('../profiler');
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = function (options) {
|
var windshaft = function (options) {
|
||||||
this._ready = false;
|
this._ready = false;
|
||||||
this._tileQueue = [];
|
this._tileQueue = [];
|
||||||
this.options = options;
|
this.options = options;
|
||||||
@ -3889,6 +3908,13 @@ var Profiler = require('../profiler');
|
|||||||
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
||||||
this.options.tiler_port = options.tiler_port || 80;
|
this.options.tiler_port = options.tiler_port || 80;
|
||||||
|
|
||||||
|
// backwards compatible
|
||||||
|
if (!options.maps_api_template) {
|
||||||
|
this._buildMapsApiTemplate(this.options);
|
||||||
|
} else {
|
||||||
|
this.options.maps_api_template = options.maps_api_template;
|
||||||
|
}
|
||||||
|
|
||||||
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
||||||
|
|
||||||
if (this.options.data_aggregation) {
|
if (this.options.data_aggregation) {
|
||||||
@ -3903,7 +3929,7 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
json.prototype = {
|
windshaft.prototype = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the torque tile encoded in an efficient javascript
|
* return the torque tile encoded in an efficient javascript
|
||||||
@ -3938,7 +3964,7 @@ var Profiler = require('../profiler');
|
|||||||
dates = (1 + maxDateSlots) * rows.length;
|
dates = (1 + maxDateSlots) * rows.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = this.options.cumulative ? Uint32Array: Uint8Array;
|
var type = this.options.cumulative ? Uint32Array: Uint8ClampedArray;
|
||||||
|
|
||||||
// reserve memory for all the dates
|
// reserve memory for all the dates
|
||||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||||
@ -4202,31 +4228,53 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_tilerHost: function() {
|
_buildMapsApiTemplate: function(opts) {
|
||||||
var opts = this.options;
|
var user = opts.user_name || opts.user;
|
||||||
var user = (opts.user_name || opts.user);
|
opts.maps_api_template = opts.tiler_protocol +
|
||||||
return opts.tiler_protocol +
|
"://" + ((user) ? "{user}.":"") +
|
||||||
"://" + (user ? user + "." : "") +
|
|
||||||
opts.tiler_domain +
|
opts.tiler_domain +
|
||||||
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
||||||
},
|
},
|
||||||
|
|
||||||
url: function() {
|
_tilerHost: function() {
|
||||||
|
var opts = this.options;
|
||||||
|
var user = opts.user_name || opts.user;
|
||||||
|
return opts.maps_api_template.replace('{user}', user);
|
||||||
|
},
|
||||||
|
|
||||||
|
url: function () {
|
||||||
var opts = this.options;
|
var opts = this.options;
|
||||||
var protocol = opts.tiler_protocol || 'http';
|
|
||||||
if (!this.options.cdn_url || this.options.no_cdn) {
|
|
||||||
return this._tilerHost();
|
|
||||||
}
|
|
||||||
var h = protocol + "://"
|
|
||||||
if (protocol === 'http') {
|
|
||||||
h += "{s}.";
|
|
||||||
}
|
|
||||||
var cdn_host = opts.cdn_url;
|
var cdn_host = opts.cdn_url;
|
||||||
if(!cdn_host.http && !cdn_host.https) {
|
var has_empty_cdn = !cdn_host || (cdn_host && (!cdn_host.http && !cdn_host.https));
|
||||||
throw new Error("cdn_host should contain http and/or https entries");
|
|
||||||
|
if (opts.no_cdn || has_empty_cdn) {
|
||||||
|
return this._tilerHost();
|
||||||
|
} else {
|
||||||
|
var protocol = this.isHttps() ? 'https': 'http';
|
||||||
|
var h = protocol + "://";
|
||||||
|
if (!this.isHttps()) {
|
||||||
|
h += "{s}.";
|
||||||
|
}
|
||||||
|
var cdn_url = cdn_host[protocol];
|
||||||
|
// build default template url if the cdn url is not templatized
|
||||||
|
// this is for backwards compatiblity, ideally we should use the url
|
||||||
|
// that tiler sends to us right away
|
||||||
|
if (!this._isUserTemplateUrl(cdn_url)) {
|
||||||
|
cdn_url = cdn_url + "/{user}";
|
||||||
|
}
|
||||||
|
var user = opts.user_name || opts.user;
|
||||||
|
h += cdn_url.replace('{user}', user)
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
h += cdn_host[protocol] + "/" + (opts.user_name || opts.user);
|
|
||||||
return h;
|
},
|
||||||
|
|
||||||
|
_isUserTemplateUrl: function(t) {
|
||||||
|
return t && t.indexOf('{user}') !== -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
isHttps: function() {
|
||||||
|
return this.options.maps_api_template.indexOf('https') === 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_generateCartoCSS: function() {
|
_generateCartoCSS: function() {
|
||||||
@ -4293,6 +4341,10 @@ var Profiler = require('../profiler');
|
|||||||
torque.net.jsonp(url, function (data) {
|
torque.net.jsonp(url, function (data) {
|
||||||
map_instance_time.end();
|
map_instance_time.end();
|
||||||
if (data) {
|
if (data) {
|
||||||
|
if (data.errors){
|
||||||
|
self.options.errorCallback && self.options.errorCallback(data.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var torque_key = Object.keys(data.metadata.torque)[0]
|
var torque_key = Object.keys(data.metadata.torque)[0]
|
||||||
var opt = data.metadata.torque[torque_key];
|
var opt = data.metadata.torque[torque_key];
|
||||||
for(var k in opt) {
|
for(var k in opt) {
|
||||||
@ -4314,7 +4366,7 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = json;
|
module.exports = windshaft;
|
||||||
|
|
||||||
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
||||||
var TAU = Math.PI*2;
|
var TAU = Math.PI*2;
|
||||||
@ -13922,11 +13974,9 @@ module.exports={
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/cartodb/carto",
|
"homepage": "https://github.com/cartodb/carto",
|
||||||
"_id": "carto@0.15.1-cdb1",
|
"_id": "carto@0.15.1-cdb1",
|
||||||
"dist": {
|
"_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7",
|
||||||
"shasum": "444d4ad0b3a83d0188ffc5d5c486b722aa5e6556"
|
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
||||||
},
|
"_from": "https://github.com/CartoDB/carto/archive/master.tar.gz"
|
||||||
"_from": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
|
||||||
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},{}]},{},[10])(10)
|
},{}]},{},[10])(10)
|
||||||
|
6
dist/torque.js
vendored
6
dist/torque.js
vendored
File diff suppressed because one or more lines are too long
96
dist/torque.uncompressed.js
vendored
96
dist/torque.uncompressed.js
vendored
@ -669,6 +669,7 @@ module.exports.TorqueLayer = TorqueLayer;
|
|||||||
// types
|
// types
|
||||||
var types = {
|
var types = {
|
||||||
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
||||||
|
Uint8ClampedArray: typeof(global['Uint8ClampedArray']) !== 'undefined' ? global.Uint8ClampedArray: Array,
|
||||||
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
||||||
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
||||||
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
||||||
@ -1613,6 +1614,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
|
|
||||||
this.provider = new this.providers[this.options.provider](this.options);
|
this.provider = new this.providers[this.options.provider](this.options);
|
||||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
||||||
|
this.renderer.options.errorCallback = this.options.errorCallback;
|
||||||
|
|
||||||
// this listener should be before tile loader
|
// this listener should be before tile loader
|
||||||
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
||||||
@ -1643,6 +1645,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSQL: function(sql) {
|
setSQL: function(sql) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||||
if (!this.provider || !this.provider.setSQL) {
|
if (!this.provider || !this.provider.setSQL) {
|
||||||
throw new Error("this provider does not support SQL");
|
throw new Error("this provider does not support SQL");
|
||||||
}
|
}
|
||||||
@ -1787,6 +1790,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
* set the cartocss for the current renderer
|
* set the cartocss for the current renderer
|
||||||
*/
|
*/
|
||||||
setCartoCSS: function(cartocss) {
|
setCartoCSS: function(cartocss) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||||
var shader = new carto.RendererJS().render(cartocss);
|
var shader = new carto.RendererJS().render(cartocss);
|
||||||
this.shader = shader;
|
this.shader = shader;
|
||||||
if (this.renderer) {
|
if (this.renderer) {
|
||||||
@ -1815,6 +1819,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
|
this.fire('remove');
|
||||||
CanvasLayer.prototype.onRemove.call(this);
|
CanvasLayer.prototype.onRemove.call(this);
|
||||||
this.animator.stop();
|
this.animator.stop();
|
||||||
this._removeTileLoader();
|
this._removeTileLoader();
|
||||||
@ -1855,6 +1860,11 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function (callback) {
|
||||||
|
this.options.errorCallback = callback;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -2138,6 +2148,11 @@ L.CanvasLayer = L.Class.extend({
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
error: function (callback) {
|
||||||
|
this.provider.options.errorCallback = callback;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
setOpacity: function (opacity) {
|
setOpacity: function (opacity) {
|
||||||
this.options.opacity = opacity;
|
this.options.opacity = opacity;
|
||||||
this._updateOpacity();
|
this._updateOpacity();
|
||||||
@ -2493,6 +2508,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function(map) {
|
onRemove: function(map) {
|
||||||
|
this.fire('remove');
|
||||||
this._removeTileLoader();
|
this._removeTileLoader();
|
||||||
map.off({
|
map.off({
|
||||||
'zoomend': this._clearCaches,
|
'zoomend': this._clearCaches,
|
||||||
@ -2533,6 +2549,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSQL: function(sql) {
|
setSQL: function(sql) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||||
if (!this.provider || !this.provider.setSQL) {
|
if (!this.provider || !this.provider.setSQL) {
|
||||||
throw new Error("this provider does not support SQL");
|
throw new Error("this provider does not support SQL");
|
||||||
}
|
}
|
||||||
@ -2693,6 +2710,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
* set the cartocss for the current renderer
|
* set the cartocss for the current renderer
|
||||||
*/
|
*/
|
||||||
setCartoCSS: function(cartocss) {
|
setCartoCSS: function(cartocss) {
|
||||||
|
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||||
if (!this.renderer) throw new Error('renderer is not valid');
|
if (!this.renderer) throw new Error('renderer is not valid');
|
||||||
var shader = new carto.RendererJS().render(cartocss);
|
var shader = new carto.RendererJS().render(cartocss);
|
||||||
this.renderer.setShader(shader);
|
this.renderer.setShader(shader);
|
||||||
@ -3867,6 +3885,7 @@ var Profiler = require('../profiler');
|
|||||||
var Uint8Array = torque.types.Uint8Array;
|
var Uint8Array = torque.types.Uint8Array;
|
||||||
var Int32Array = torque.types.Int32Array;
|
var Int32Array = torque.types.Int32Array;
|
||||||
var Uint32Array = torque.types.Uint32Array;
|
var Uint32Array = torque.types.Uint32Array;
|
||||||
|
var Uint8ClampedArray = torque.types.Uint8ClampedArray;
|
||||||
|
|
||||||
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
||||||
function format(str) {
|
function format(str) {
|
||||||
@ -3879,7 +3898,7 @@ var Profiler = require('../profiler');
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = function (options) {
|
var windshaft = function (options) {
|
||||||
this._ready = false;
|
this._ready = false;
|
||||||
this._tileQueue = [];
|
this._tileQueue = [];
|
||||||
this.options = options;
|
this.options = options;
|
||||||
@ -3889,6 +3908,13 @@ var Profiler = require('../profiler');
|
|||||||
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
||||||
this.options.tiler_port = options.tiler_port || 80;
|
this.options.tiler_port = options.tiler_port || 80;
|
||||||
|
|
||||||
|
// backwards compatible
|
||||||
|
if (!options.maps_api_template) {
|
||||||
|
this._buildMapsApiTemplate(this.options);
|
||||||
|
} else {
|
||||||
|
this.options.maps_api_template = options.maps_api_template;
|
||||||
|
}
|
||||||
|
|
||||||
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
||||||
|
|
||||||
if (this.options.data_aggregation) {
|
if (this.options.data_aggregation) {
|
||||||
@ -3903,7 +3929,7 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
json.prototype = {
|
windshaft.prototype = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the torque tile encoded in an efficient javascript
|
* return the torque tile encoded in an efficient javascript
|
||||||
@ -3938,7 +3964,7 @@ var Profiler = require('../profiler');
|
|||||||
dates = (1 + maxDateSlots) * rows.length;
|
dates = (1 + maxDateSlots) * rows.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = this.options.cumulative ? Uint32Array: Uint8Array;
|
var type = this.options.cumulative ? Uint32Array: Uint8ClampedArray;
|
||||||
|
|
||||||
// reserve memory for all the dates
|
// reserve memory for all the dates
|
||||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||||
@ -4202,31 +4228,53 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_tilerHost: function() {
|
_buildMapsApiTemplate: function(opts) {
|
||||||
var opts = this.options;
|
var user = opts.user_name || opts.user;
|
||||||
var user = (opts.user_name || opts.user);
|
opts.maps_api_template = opts.tiler_protocol +
|
||||||
return opts.tiler_protocol +
|
"://" + ((user) ? "{user}.":"") +
|
||||||
"://" + (user ? user + "." : "") +
|
|
||||||
opts.tiler_domain +
|
opts.tiler_domain +
|
||||||
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
||||||
},
|
},
|
||||||
|
|
||||||
url: function() {
|
_tilerHost: function() {
|
||||||
|
var opts = this.options;
|
||||||
|
var user = opts.user_name || opts.user;
|
||||||
|
return opts.maps_api_template.replace('{user}', user);
|
||||||
|
},
|
||||||
|
|
||||||
|
url: function () {
|
||||||
var opts = this.options;
|
var opts = this.options;
|
||||||
var protocol = opts.tiler_protocol || 'http';
|
|
||||||
if (!this.options.cdn_url || this.options.no_cdn) {
|
|
||||||
return this._tilerHost();
|
|
||||||
}
|
|
||||||
var h = protocol + "://"
|
|
||||||
if (protocol === 'http') {
|
|
||||||
h += "{s}.";
|
|
||||||
}
|
|
||||||
var cdn_host = opts.cdn_url;
|
var cdn_host = opts.cdn_url;
|
||||||
if(!cdn_host.http && !cdn_host.https) {
|
var has_empty_cdn = !cdn_host || (cdn_host && (!cdn_host.http && !cdn_host.https));
|
||||||
throw new Error("cdn_host should contain http and/or https entries");
|
|
||||||
|
if (opts.no_cdn || has_empty_cdn) {
|
||||||
|
return this._tilerHost();
|
||||||
|
} else {
|
||||||
|
var protocol = this.isHttps() ? 'https': 'http';
|
||||||
|
var h = protocol + "://";
|
||||||
|
if (!this.isHttps()) {
|
||||||
|
h += "{s}.";
|
||||||
|
}
|
||||||
|
var cdn_url = cdn_host[protocol];
|
||||||
|
// build default template url if the cdn url is not templatized
|
||||||
|
// this is for backwards compatiblity, ideally we should use the url
|
||||||
|
// that tiler sends to us right away
|
||||||
|
if (!this._isUserTemplateUrl(cdn_url)) {
|
||||||
|
cdn_url = cdn_url + "/{user}";
|
||||||
|
}
|
||||||
|
var user = opts.user_name || opts.user;
|
||||||
|
h += cdn_url.replace('{user}', user)
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
h += cdn_host[protocol] + "/" + (opts.user_name || opts.user);
|
|
||||||
return h;
|
},
|
||||||
|
|
||||||
|
_isUserTemplateUrl: function(t) {
|
||||||
|
return t && t.indexOf('{user}') !== -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
isHttps: function() {
|
||||||
|
return this.options.maps_api_template.indexOf('https') === 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_generateCartoCSS: function() {
|
_generateCartoCSS: function() {
|
||||||
@ -4293,6 +4341,10 @@ var Profiler = require('../profiler');
|
|||||||
torque.net.jsonp(url, function (data) {
|
torque.net.jsonp(url, function (data) {
|
||||||
map_instance_time.end();
|
map_instance_time.end();
|
||||||
if (data) {
|
if (data) {
|
||||||
|
if (data.errors){
|
||||||
|
self.options.errorCallback && self.options.errorCallback(data.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var torque_key = Object.keys(data.metadata.torque)[0]
|
var torque_key = Object.keys(data.metadata.torque)[0]
|
||||||
var opt = data.metadata.torque[torque_key];
|
var opt = data.metadata.torque[torque_key];
|
||||||
for(var k in opt) {
|
for(var k in opt) {
|
||||||
@ -4314,7 +4366,7 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = json;
|
module.exports = windshaft;
|
||||||
|
|
||||||
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
||||||
var TAU = Math.PI*2;
|
var TAU = Math.PI*2;
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var flags = {
|
var flags = {
|
||||||
sprites_to_images: userAgent().indexOf('Safari') === -1
|
sprites_to_images: userAgent().indexOf('Safari') === -1 && userAgent().indexOf('Firefox') === -1
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// min value to render a line.
|
// min value to render a line.
|
||||||
// it does not make sense to render a line of a width is not even visible
|
// it does not make sense to render a line of a width is not even visible
|
||||||
var LINEWIDTH_MIN_VALUE = 0.05;
|
var LINEWIDTH_MIN_VALUE = 0.05;
|
||||||
|
var MAX_SPRITE_RADIUS = 255;
|
||||||
|
|
||||||
function renderPoint(ctx, st) {
|
function renderPoint(ctx, st) {
|
||||||
ctx.fillStyle = st['marker-fill'];
|
ctx.fillStyle = st['marker-fill'];
|
||||||
@ -78,12 +79,13 @@
|
|||||||
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
|
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
|
||||||
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
|
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
|
||||||
}
|
}
|
||||||
ctx.drawImage(img, 0, 0, img.width, img.height);
|
ctx.drawImage(img, 0, 0, Math.min(img.width, MAX_SPRITE_RADIUS), Math.min(img.height, MAX_SPRITE_RADIUS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
renderPoint: renderPoint,
|
renderPoint: renderPoint,
|
||||||
renderSprite: renderSprite,
|
renderSprite: renderSprite,
|
||||||
renderRectangle: renderRectangle
|
renderRectangle: renderRectangle,
|
||||||
|
MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS
|
||||||
};
|
};
|
||||||
|
@ -132,17 +132,27 @@ var ballRenderer = require('./ball.js');
|
|||||||
// take into account the exterior ring to calculate the size
|
// take into account the exterior ring to calculate the size
|
||||||
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2;
|
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2;
|
||||||
var ctx = canvas.getContext('2d');
|
var ctx = canvas.getContext('2d');
|
||||||
var w = ctx.width = canvas.width = ctx.height = canvas.height = Math.ceil(canvasSize);
|
|
||||||
ctx.translate(w/2, w/2);
|
|
||||||
|
|
||||||
var img_name = this._qualifyURL(st["marker-file"] || st["point-file"]);
|
var markerFile = st["marker-file"] || st["point-file"];
|
||||||
if (img_name && this._icons.itemsToLoad <= 0) {
|
var qualifiedUrl = markerFile && this._qualifyURL(markerFile);
|
||||||
var img = this._icons[img_name];
|
|
||||||
img.w = st['marker-width'] || img.width;
|
if (qualifiedUrl && this._iconsToLoad <= 0 && this._icons[qualifiedUrl]) {
|
||||||
img.h = st['marker-width'] || st['marker-height'];
|
var img = this._icons[qualifiedUrl];
|
||||||
cartocss.renderSprite(ctx, img, st);
|
|
||||||
}
|
var dWidth = Math.min(st['marker-width'] * 2 || img.width, cartocss.MAX_SPRITE_RADIUS * 2);
|
||||||
else {
|
var dHeight = Math.min((st['marker-height'] || dWidth) * (img.width / img.height), cartocss.MAX_SPRITE_RADIUS * 2);
|
||||||
|
|
||||||
|
canvas.width = ctx.width = dWidth;
|
||||||
|
canvas.height = ctx.height = dHeight;
|
||||||
|
|
||||||
|
ctx.scale(dWidth/img.width, dHeight/img.height);
|
||||||
|
|
||||||
|
cartocss.renderSprite(ctx, img, st);
|
||||||
|
} else {
|
||||||
|
// take into account the exterior ring to calculate the size
|
||||||
|
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2;
|
||||||
|
var w = ctx.width = canvas.width = ctx.height = canvas.height = Math.ceil(canvasSize);
|
||||||
|
ctx.translate(w/2, w/2);
|
||||||
var mt = st['marker-type'];
|
var mt = st['marker-type'];
|
||||||
if (mt && mt === 'rectangle') {
|
if (mt && mt === 'rectangle') {
|
||||||
cartocss.renderRectangle(ctx, st);
|
cartocss.renderRectangle(ctx, st);
|
||||||
|
Loading…
Reference in New Issue
Block a user