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

Fix symbol rendering for multipoints #3763

Merged
merged 3 commits into from
Dec 13, 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: 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