Skip to content

Commit

Permalink
Fix a bug where lines with duplicate endpoint disappear on z18+ (#9218)
Browse files Browse the repository at this point in the history
* fix a bug with vanishing line with duplicate end points

* fix flow :(
  • Loading branch information
mourner authored Jan 27, 2020
1 parent be4f189 commit 99bfc7f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class LineBucket implements Bucket {

for (let i = first; i < len; i++) {

nextVertex = isPolygon && i === len - 1 ?
vertices[first + 1] : // if the line is closed, we treat the last vertex like the first
nextVertex = i === len - 1 ?
(isPolygon ? vertices[first + 1] : (undefined: any)) : // if it's a polygon, treat the last vertex like the first
vertices[i + 1]; // just the next vertex

// if two consecutive vertices exist, skip the current one
Expand Down
6 changes: 3 additions & 3 deletions src/style-spec/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export type VectorSourceSpecification = {
"scheme"?: "xyz" | "tms",
"minzoom"?: number,
"maxzoom"?: number,
"attribution"?: string
"attribution"?: string,
"promoteId"?: PromoteIdSpecification
}

export type RasterSourceSpecification = {
Expand All @@ -112,8 +113,7 @@ export type RasterDEMSourceSpecification = {
"maxzoom"?: number,
"tileSize"?: number,
"attribution"?: string,
"encoding"?: "terrarium" | "mapbox",
"promoteId"?: PromoteIdSpecification
"encoding"?: "terrarium" | "mapbox"
}

export type GeoJSONSourceSpecification = {|
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 32
}
},
"center": [-0.63938, 44.77458],
"zoom": 18,
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[-0.639208, 44.774651],
[-0.639605, 44.774487],
[-0.639605, 44.774487]
]
}
}
},
"layers": [
{
"id": "line",
"type": "line",
"source": "geojson",
"paint": {
"line-color": "#f44336",
"line-width": 10
}
}
]
}

0 comments on commit 99bfc7f

Please sign in to comment.