updated torque

This commit is contained in:
javi 2014-10-21 17:16:23 +02:00
parent 4df45fb5b6
commit 2047b1871f

View File

@ -626,6 +626,10 @@ exports.torque.common.TorqueLayer = TorqueLayer;
return exports.torque.extend({}, a);
}
exports.torque.isFunction = function(f) {
return typeof f == 'function' || false;
}
exports.torque.isArray = function(value) {
return value && typeof value == 'object' && Object.prototype.toString.call(value) == '[object Array]';
};
@ -641,6 +645,10 @@ exports.torque.common.TorqueLayer = TorqueLayer;
return !!document.createElement('canvas');
};
exports.torque.flags = {
sprites_to_images: navigator.userAgent.indexOf('Safari') === -1
}
})(typeof exports === "undefined" ? this : exports);
if (typeof module !== "undefined") {
@ -1976,11 +1984,12 @@ exports.Profiler = Profiler;
return refresh;
},
_extraParams: function() {
if (this.options.extra_params) {
_extraParams: function(e) {
e = torque.extend(torque.extend({}, e), this.options.extra_params);
if (e) {
var p = [];
for(var k in this.options.extra_params) {
var v = this.options.extra_params[k];
for(var k in e) {
var v = e[k];
if (v) {
if (torque.isArray(v)) {
for (var i = 0, len = v.length; i < len; i++) {
@ -2136,7 +2145,6 @@ exports.Profiler = Profiler;
if(named) {
//tiles/template
url = this._tilerHost() + "/api/v1/map/named/" + named.name + "/jsonp"
//url = this._tilerHost() + "/map/" + named.name + "/jsonp"
} else {
layergroup = {
"version": "1.0.1",
@ -2151,7 +2159,7 @@ exports.Profiler = Profiler;
}]
};
}
var extra = this._extraParams();
var extra = this._extraParams(this.options.stat_tag ? { stat_tag: this.options.stat_tag }: {} );
// tiler needs map_key instead of api_key
// so replace it
@ -2207,6 +2215,10 @@ exports.Profiler = Profiler;
// function name
var fnName = options.callbackName || 'torque_' + Date.now();
if (torque.isFunction(fnName)) {
fnName = fnName();
}
function clean() {
head.removeChild(script);
clearTimeout(timeoutTimer);
@ -2297,6 +2309,10 @@ exports.Profiler = Profiler;
exports.torque = exports.torque || {};
var TAU = Math.PI*2;
// min value to render a line.
// it does not make sense to render a line of a width is not even visible
var LINEWIDTH_MIN_VALUE = 0.05;
function renderPoint(ctx, st) {
ctx.fillStyle = st.fillStyle;
var pixel_size = st['point-radius'];
@ -2316,7 +2332,7 @@ exports.Profiler = Profiler;
// stroke
ctx.globalAlpha = 1.0;
if (st.strokeStyle && st.lineWidth) {
if (st.strokeStyle && st.lineWidth && st.lineWidth > LINEWIDTH_MIN_VALUE) {
if (st.strokeOpacity) {
ctx.globalAlpha = st.strokeOpacity;
}
@ -2448,7 +2464,11 @@ exports.Profiler = Profiler;
var pointSize = st['point-radius'];
if (!pointSize) {
throw new Error("marker-width property should be set");
return null;
}
if (st.fillOpacity === 0 && !st.strokeOpacity) {
return null;
}
var canvas = document.createElement('canvas');
@ -2470,9 +2490,12 @@ exports.Profiler = Profiler;
}
}
prof.end(true);
var i = new Image();
i.src = canvas.toDataURL();
return i;
if (torque.flags.sprites_to_images) {
var i = new Image();
i.src = canvas.toDataURL();
return i;
}
return canvas;
},
//
@ -2522,12 +2545,14 @@ exports.Profiler = Profiler;
var c = tile.renderData[pixelIndex + p];
if(c) {
var sp = sprites[c];
if(!sp) {
if(sp === undefined) {
sp = sprites[c] = this.generateSprite(shader, c, _.extend({ zoom: tile.z, 'frame-offset': frame_offset }, shaderVars));
}
var x = tile.x[posIdx]- (sp.width >> 1);
var y = tileMax - tile.y[posIdx]; // flip mercator
ctx.drawImage(sp, x, y - (sp.height >> 1));
if (sp) {
var x = tile.x[posIdx]- (sp.width >> 1);
var y = tileMax - tile.y[posIdx]; // flip mercator
ctx.drawImage(sp, x, y - (sp.height >> 1));
}
}
}
}