Skip to content

Commit

Permalink
Merge branch 'issue-1693' of github.com:CartoDB/cartodb into issue-1693
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartones committed Mar 31, 2015
2 parents b4c64c8 + 60fec98 commit 099fa95
Show file tree
Hide file tree
Showing 4 changed files with 5,705 additions and 692 deletions.
2 changes: 1 addition & 1 deletion lib/assets/javascripts/cdb
Submodule cdb updated from 704629 to c9c5d1
4 changes: 2 additions & 2 deletions vendor/assets/javascripts/cartodb.mod.odyssey.uncompressed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// version: 3.12.13
// sha: 87b09e52d698f3983fe208b7893b3442f857ed20
// version: 3.12.12
// sha: 35ee91fc6a1e781487c2be680707848dce71bda9

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.O=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

Expand Down
143 changes: 115 additions & 28 deletions vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
this.renderer.renderTile(tile, this.key);
}
}
this.renderer.applyFilters();
},

getActivePointsBBox: function(step) {
Expand Down Expand Up @@ -1821,6 +1822,42 @@ GMapsTorqueLayer.prototype = torque.extend({},
this.animator.stop();
this._removeTileLoader();
google.maps.event.removeListener(this._cacheListener);
},

getValueForPos: function(x, y, step) {
step = step === undefined ? this.key: step;
var t, tile, pos, value = null, xx, yy;
for(t in this._tiles) {
tile = this._tiles[t];
pos = this.getTilePos(tile.coord);
xx = x - pos.x;
yy = y - pos.y;
if (xx >= 0 && yy >= 0 && xx < this.renderer.TILE_SIZE && yy <= this.renderer.TILE_SIZE) {
value = this.renderer.getValueFor(tile, step, xx, yy);
}
if (value !== null) {
return value;
}
}
return null;
},
getValueForBBox: function(x, y, w, h) {
var xf = x + w, yf = y + h;
var sum = 0;
for(_y = y; y<yf; y+=this.options.resolution){
for(_x = x; x<xf; x+=this.options.resolution){
var thisValue = this.getValueForPos(_x,_y);
if (thisValue){
var bb = thisValue.bbox;
var proj = this.getProjection()
var xy = proj.fromLatLngToContainerPixel(new google.maps.LatLng(bb[1].lat, bb[1].lon));
if(xy.x < xf && xy.y < yf){
sum += thisValue.value;
}
}
}
}
return sum;
}

});
Expand Down Expand Up @@ -2716,6 +2753,24 @@ L.TorqueLayer = L.CanvasLayer.extend({
return null;
},

getValueForBBox: function(x, y, w, h) {
var xf = x + w, yf = y + h, _x=x;
var sum = 0;
for(_y = y; _y<yf; _y+=this.options.resolution){
for(_x = x; _x<xf; _x+=this.options.resolution){
var thisValue = this.getValueForPos(_x,_y);
if (thisValue){
var bb = thisValue.bbox;
var xy = this._map.latLngToContainerPoint([bb[1].lat, bb[1].lon]);
if(xy.x < xf && xy.y < yf){
sum += thisValue.value;
}
}
}
}
return sum;
},

invalidate: function() {
this.provider.reload();
}
Expand Down Expand Up @@ -3827,7 +3882,7 @@ var Profiler = require('../profiler');
return str;
}

var json = function (options) {
var windshaft = function (options) {
this._ready = false;
this._tileQueue = [];
this.options = options;
Expand All @@ -3837,6 +3892,13 @@ var Profiler = require('../profiler');
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
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;

if (this.options.data_aggregation) {
Expand All @@ -3851,7 +3913,7 @@ var Profiler = require('../profiler');
}
};

json.prototype = {
windshaft.prototype = {

/**
* return the torque tile encoded in an efficient javascript
Expand Down Expand Up @@ -4150,31 +4212,53 @@ var Profiler = require('../profiler');
}
},

_tilerHost: function() {
var opts = this.options;
var user = (opts.user_name || opts.user);
return opts.tiler_protocol +
"://" + (user ? user + "." : "") +
_buildMapsApiTemplate: function(opts) {
var user = opts.user_name || opts.user;
opts.maps_api_template = opts.tiler_protocol +
"://" + ((user) ? "{user}.":"") +
opts.tiler_domain +
((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}', opts.user);
},

url: function () {
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;
if(!cdn_host.http && !cdn_host.https) {
throw new Error("cdn_host should contain http and/or https entries");
var has_empty_cdn = !cdn_host || (cdn_host && (!cdn_host.http && !cdn_host.https));

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() {
Expand Down Expand Up @@ -4262,7 +4346,7 @@ var Profiler = require('../profiler');

};

module.exports = json;
module.exports = windshaft;

},{"../":10,"../profiler":17}],22:[function(require,module,exports){
var TAU = Math.PI*2;
Expand All @@ -4282,19 +4366,20 @@ var Profiler = require('../profiler');
ctx.beginPath();
ctx.arc(0, 0, pixel_size, 0, TAU, true, true);
ctx.closePath();

if (st['marker-opacity'] !== undefined ) st['marker-fill-opacity'] = st['marker-line-opacity'] = st['marker-opacity'];

if (st['marker-fill']) {
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'] >= 0? st['marker-fill-opacity']: 1;

if (ctx.globalAlpha > 0) {
ctx.fill();
}
ctx.fill();
}

// stroke
ctx.globalAlpha = 1.0;
if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) {
if (st['marker-line-opacity'] !== undefined) {
ctx.globalAlpha = st['marker-line-opacity'];
}
ctx.globalAlpha = st['marker-line-opacity'] >= 0? st['marker-line-opacity']: 1;
if (st['marker-line-width'] !== undefined) {
ctx.lineWidth = st['marker-line-width'];
}
Expand Down Expand Up @@ -5199,6 +5284,7 @@ var GMapsTorqueLayerView = function(layerModel, gmapsMap) {
tiler_protocol: layerModel.get('tiler_protocol'),
tiler_domain: layerModel.get('tiler_domain'),
tiler_port: layerModel.get('tiler_port'),
maps_api_template: layerModel.get('maps_api_template'),
stat_tag: layerModel.get('stat_tag'),
animationDuration: layerModel.get('torque-duration'),
steps: layerModel.get('torque-steps'),
Expand Down Expand Up @@ -5309,6 +5395,7 @@ var LeafLetTorqueLayer = L.TorqueLayer.extend({
tiler_protocol: layerModel.get('tiler_protocol'),
tiler_domain: layerModel.get('tiler_domain'),
tiler_port: layerModel.get('tiler_port'),
maps_api_template: layerModel.get('maps_api_template'),
stat_tag: layerModel.get('stat_tag'),
animationDuration: layerModel.get('torque-duration'),
steps: layerModel.get('torque-steps'),
Expand Down
Loading

0 comments on commit 099fa95

Please sign in to comment.