Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable property functions for icon-rotate #2738

Merged
merged 4 commits into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions js/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,16 @@ SymbolBucket.prototype.populateBuffers = function(collisionTile, stacks, icons)
}
if (image.pixelRatio !== 1) {
this.iconsNeedLinear = true;
} else if (layout['icon-rotate'] !== 0 || !this.layer.isLayoutValueFeatureConstant('icon-rotate')) {
this.iconsNeedLinear = true;
}
}
} else {
shapedIcon = null;
}

if (shapedText || shapedIcon) {
this.addFeature(geometries[k], shapedText, shapedIcon, features[k].index);
this.addFeature(geometries[k], shapedText, shapedIcon, features[k]);
}
}
this.symbolInstancesEndIndex = this.symbolInstancesArray.length;
Expand All @@ -251,7 +253,7 @@ SymbolBucket.prototype.populateBuffers = function(collisionTile, stacks, icons)
this.trimArrays();
};

SymbolBucket.prototype.addFeature = function(lines, shapedText, shapedIcon, featureIndex) {
SymbolBucket.prototype.addFeature = function(lines, shapedText, shapedIcon, feature) {
var layout = this.layer.layout;

var glyphSize = 24;
Expand Down Expand Up @@ -322,10 +324,10 @@ SymbolBucket.prototype.addFeature = function(lines, shapedText, shapedIcon, feat
// be drawn across tile boundaries. Instead they need to be included in
// the buffers for both tiles and clipped to tile boundaries at draw time.
var addToBuffers = inside || mayOverlap;
this.addSymbolInstance(anchor, line, shapedText, shapedIcon, layout,
addToBuffers, this.symbolInstancesArray.length, this.collisionBoxArray, featureIndex, this.sourceLayerIndex, this.index,
this.addSymbolInstance(anchor, line, shapedText, shapedIcon, this.layer,
addToBuffers, this.symbolInstancesArray.length, this.collisionBoxArray, feature.index, this.sourceLayerIndex, this.index,
textBoxScale, textPadding, textAlongLine,
iconBoxScale, iconPadding, iconAlongLine);
iconBoxScale, iconPadding, iconAlongLine, {zoom: this.zoom}, feature.properties);
}
}
};
Expand Down Expand Up @@ -557,13 +559,13 @@ SymbolBucket.prototype.addToDebugBuffers = function(collisionTile) {
}
};

SymbolBucket.prototype.addSymbolInstance = function(anchor, line, shapedText, shapedIcon, layout, addToBuffers, index, collisionBoxArray, featureIndex, sourceLayerIndex, bucketIndex,
SymbolBucket.prototype.addSymbolInstance = function(anchor, line, shapedText, shapedIcon, layer, addToBuffers, index, collisionBoxArray, featureIndex, sourceLayerIndex, bucketIndex,
textBoxScale, textPadding, textAlongLine,
iconBoxScale, iconPadding, iconAlongLine) {
iconBoxScale, iconPadding, iconAlongLine, globalProperties, featureProperties) {

var glyphQuadStartIndex, glyphQuadEndIndex, iconQuadStartIndex, iconQuadEndIndex, textCollisionFeature, iconCollisionFeature, glyphQuads, iconQuads;
if (shapedText) {
glyphQuads = addToBuffers ? getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textAlongLine) : [];
glyphQuads = addToBuffers ? getGlyphQuads(anchor, shapedText, textBoxScale, line, layer, textAlongLine) : [];
textCollisionFeature = new CollisionFeature(collisionBoxArray, line, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedText, textBoxScale, textPadding, textAlongLine, false);
}

Expand All @@ -579,7 +581,7 @@ SymbolBucket.prototype.addSymbolInstance = function(anchor, line, shapedText, sh
var textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : this.collisionBoxArray.length;

if (shapedIcon) {
iconQuads = addToBuffers ? getIconQuads(anchor, shapedIcon, iconBoxScale, line, layout, iconAlongLine, shapedText) : [];
iconQuads = addToBuffers ? getIconQuads(anchor, shapedIcon, iconBoxScale, line, layer, iconAlongLine, shapedText, globalProperties, featureProperties) : [];
iconCollisionFeature = new CollisionFeature(collisionBoxArray, line, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, iconAlongLine, true);
}

Expand Down Expand Up @@ -632,4 +634,3 @@ SymbolBucket.prototype.addSymbolQuad = function(symbolQuad) {
symbolQuad.maxScale,
symbolQuad.minScale);
};

10 changes: 10 additions & 0 deletions js/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ StyleLayer.prototype = util.inherit(Evented, {
}
},

isLayoutValueFeatureConstant: function(name) {
var declaration = this._layoutDeclarations[name];

if (declaration) {
return declaration.isFeatureConstant;
} else {
return true;
}
},

isPaintValueZoomConstant: function(name) {
var transition = this._paintTransitions[name];

Expand Down
16 changes: 8 additions & 8 deletions js/symbol/quads.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ function SymbolQuad(anchorPoint, tl, tr, bl, br, tex, anchorAngle, glyphAngle, m
* @param {PositionedIcon} shapedIcon
* @param {number} boxScale A magic number for converting glyph metric units to geometry units.
* @param {Array<Array<Point>>} line
* @param {LayoutProperties} layout
* @param {StyleLayer} layer
* @param {boolean} alongLine Whether the icon should be placed along the line.
* @param {Shaping} shapedText Shaping for corresponding text
* @returns {Array<SymbolQuad>}
* @private
*/
function getIconQuads(anchor, shapedIcon, boxScale, line, layout, alongLine, shapedText) {

function getIconQuads(anchor, shapedIcon, boxScale, line, layer, alongLine, shapedText, globalProperties, featureProperties) {
var rect = shapedIcon.image.rect;
var layout = layer.layout;

var border = 1;
var left = shapedIcon.left - border;
Expand Down Expand Up @@ -97,7 +97,7 @@ function getIconQuads(anchor, shapedIcon, boxScale, line, layout, alongLine, sha
bl = new Point(left, bottom);
}

var angle = layout['icon-rotate'] * Math.PI / 180;
var angle = layer.getLayoutValue('icon-rotate', globalProperties, featureProperties) * Math.PI / 180;
if (alongLine) {
var prev = line[anchor.segment];
if (anchor.y === prev.y && anchor.x === prev.x && anchor.segment + 1 < line.length) {
Expand Down Expand Up @@ -129,15 +129,15 @@ function getIconQuads(anchor, shapedIcon, boxScale, line, layout, alongLine, sha
* @param {Shaping} shaping
* @param {number} boxScale A magic number for converting from glyph metric units to geometry units.
* @param {Array<Array<Point>>} line
* @param {LayoutProperties} layout
* @param {StyleLayer} layer
* @param {boolean} alongLine Whether the label should be placed along the line.
* @returns {Array<SymbolQuad>}
* @private
*/
function getGlyphQuads(anchor, shaping, boxScale, line, layout, alongLine) {
function getGlyphQuads(anchor, shaping, boxScale, line, layer, alongLine) {

var textRotate = layout['text-rotate'] * Math.PI / 180;
var keepUpright = layout['text-keep-upright'];
var textRotate = layer.layout['text-rotate'] * Math.PI / 180;
var keepUpright = layer.layout['text-keep-upright'];

var positionedGlyphs = shaping.positionedGlyphs;
var quads = [];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"highlight.js": "9.3.0",
"istanbul": "^0.4.2",
"lodash": "^4.13.1",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#146a348f1768ce13e153fce3b32bbed469aa5fe4",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#c403b6560d4d645221a5ce2dc02cc428cb065842",
"nyc": "6.4.0",
"remark": "4.2.2",
"remark-html": "3.0.0",
Expand Down
Loading