Skip to content

Commit

Permalink
Fix symbol rendering for multipoints (#3763)
Browse files Browse the repository at this point in the history
* Fix symbol rendering for multipoints

* Add render tests, use vector tile feature type

* Update package.json
  • Loading branch information
lucaswoj authored Dec 13, 2016
1 parent b5fce34 commit 32fcbfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions js/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const loadGeometry = require('../load_geometry');
const CollisionFeature = require('../../symbol/collision_feature');
const findPoleOfInaccessibility = require('../../util/find_pole_of_inaccessibility');
const classifyRings = require('../../util/classify_rings');
const VectorTileFeature = require('vector-tile').VectorTileFeature;

const shapeText = Shaping.shapeText;
const shapeIcon = Shaping.shapeIcon;
Expand Down Expand Up @@ -160,7 +161,8 @@ class SymbolBucket {
index: i,
sourceLayerIndex: feature.sourceLayerIndex,
geometry: loadGeometry(feature),
properties: feature.properties
properties: feature.properties,
type: VectorTileFeature.types[feature.type]
});

if (icon) {
Expand Down Expand Up @@ -337,15 +339,18 @@ class SymbolBucket {
mayOverlap = layout['text-allow-overlap'] || layout['icon-allow-overlap'] ||
layout['text-ignore-placement'] || layout['icon-ignore-placement'],
symbolPlacement = layout['symbol-placement'],
isLine = symbolPlacement === 'line',
textRepeatDistance = symbolMinDistance / 2;

let list = null;
if (isLine) {
if (symbolPlacement === 'line') {
list = clipLine(lines, 0, 0, EXTENT, EXTENT);
} else {
// Only care about looping through the outer rings
list = classifyRings(lines, 0);
} else if (symbolPlacement === 'point') {
if (feature.type === 'Polygon') {
list = classifyRings(lines, 0);
} else {
list = [];
for (const point of lines) list.push([point]);
}
}

for (let i = 0; i < list.length; i++) {
Expand All @@ -355,7 +360,7 @@ class SymbolBucket {
let line = null;

// Calculate the anchor points around which you want to place labels
if (isLine) {
if (symbolPlacement === 'line') {
line = pointsOrRings;
anchors = getAnchors(
line,
Expand All @@ -380,7 +385,7 @@ class SymbolBucket {
for (let j = 0, len = anchors.length; j < len; j++) {
const anchor = anchors[j];

if (shapedTextOrientations[WritingMode.horizontal] && isLine) {
if (shapedTextOrientations[WritingMode.horizontal] && symbolPlacement === 'line') {
if (this.anchorIsTooClose(shapedTextOrientations[WritingMode.horizontal].text, textRepeatDistance, anchor)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"in-publish": "^2.0.0",
"jsdom": "^9.4.2",
"lodash.template": "^4.4.0",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f9a1131df12227208812802b8108304a10380509",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#8a047e6226b996fa8fc4c61a30aebb55c6234896",
"minifyify": "^7.0.1",
"npm-run-all": "^3.0.0",
"nyc": "^8.3.0",
Expand Down

0 comments on commit 32fcbfe

Please sign in to comment.