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

V0.53.1 #7961

Merged
merged 5 commits into from
Feb 27, 2019
Merged

V0.53.1 #7961

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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.53.1

## Bug fixes
* Turn off telemetry for Mapbox Atlas ([#7945](https://github.com/mapbox/mapbox-gl-js/pull/7945))
* Fix order of 3D features in query results (fix #7883) ([#7953](https://github.com/mapbox/mapbox-gl-js/pull/7953))
* Fix RemovePaintState benchmarks ([#7930](https://github.com/mapbox/mapbox-gl-js/pull/7930))

## 0.53.0

## Features and improvements
Expand Down
12 changes: 6 additions & 6 deletions bench/benchmarks/remove_paint_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RemovePaintState extends Benchmark {
}
}

class propertyLevelRemove extends RemovePaintState {
class PropertyLevelRemove extends RemovePaintState {
bench() {

for (let i = 0; i < this.numFeatures; i += 50) {
Expand All @@ -82,7 +82,7 @@ class propertyLevelRemove extends RemovePaintState {
}
}

class featureLevelRemove extends RemovePaintState {
class FeatureLevelRemove extends RemovePaintState {
bench() {

for (let i = 0; i < this.numFeatures; i += 50) {
Expand All @@ -96,7 +96,7 @@ class featureLevelRemove extends RemovePaintState {
}
}

class sourceLevelRemove extends RemovePaintState {
class SourceLevelRemove extends RemovePaintState {
bench() {

for (let i = 0; i < this.numFeatures; i += 50) {
Expand All @@ -111,7 +111,7 @@ class sourceLevelRemove extends RemovePaintState {
}

export default [
propertyLevelRemove,
featureLevelRemove,
sourceLevelRemove
PropertyLevelRemove,
FeatureLevelRemove,
SourceLevelRemove
];
4 changes: 2 additions & 2 deletions bench/versions/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import SymbolLayout from '../benchmarks/symbol_layout';
import WorkerTransfer from '../benchmarks/worker_transfer';
import Paint from '../benchmarks/paint';
import PaintStates from '../benchmarks/paint_states';
import RemovePaintState from '../benchmarks/remove_paint_state';
import RemovePaintStateBenchmarks from '../benchmarks/remove_paint_state';
import LayerBenchmarks from '../benchmarks/layers';
import Load from '../benchmarks/map_load';
import Validate from '../benchmarks/style_validate';
Expand All @@ -47,7 +47,7 @@ register(new StyleLayerCreate(style));
ExpressionBenchmarks.forEach((Bench) => register(new Bench(style)));
register(new WorkerTransfer(style));
register(new PaintStates(center));
register(new RemovePaintState(center));
RemovePaintStateBenchmarks.forEach((Bench) => register(new Bench(center)));
LayerBenchmarks.forEach((Bench) => register(new Bench()));
register(new Load());
register(new LayoutDDS());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mapbox-gl",
"description": "A WebGL interactive maps library",
"version": "0.53.0",
"version": "0.53.1",
"main": "dist/mapbox-gl.js",
"style": "dist/mapbox-gl.css",
"license": "SEE LICENSE IN LICENSE.txt",
Expand Down
60 changes: 48 additions & 12 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,32 +942,68 @@ class Style extends Evented {
}

_flattenAndSortRenderedFeatures(sourceResults: Array<any>) {
const features = [];
// Feature order is complicated.
// The order between features in two 2D layers is always determined by layer order.
// The order between features in two 3D layers is always determined by depth.
// The order between a feature in a 2D layer and a 3D layer is tricky:
// Most often layer order determines the feature order in this case. If
// a line layer is above a extrusion layer the line feature will be rendered
// above the extrusion. If the line layer is below the extrusion layer,
// it will be rendered below it.
//
// There is a weird case though.
// You have layers in this order: extrusion_layer_a, line_layer, extrusion_layer_b
// Each layer has a feature that overlaps the other features.
// The feature in extrusion_layer_a is closer than the feature in extrusion_layer_b so it is rendered above.
// The feature in line_layer is rendered above extrusion_layer_a.
// This means that that the line_layer feature is above the extrusion_layer_b feature despite
// it being in an earlier layer.

const isLayer3D = layerId => this._layers[layerId].type === 'fill-extrusion';

const layerIndex = {};
const features3D = [];
for (let l = this._order.length - 1; l >= 0; l--) {
const layerId = this._order[l];
for (const sourceResult of sourceResults) {
const layerFeatures = sourceResult[layerId];
if (layerFeatures) {
if (this._layers[layerId].type === 'fill-extrusion') {
if (isLayer3D(layerId)) {
layerIndex[layerId] = l;
for (const sourceResult of sourceResults) {
const layerFeatures = sourceResult[layerId];
if (layerFeatures) {
for (const featureWrapper of layerFeatures) {
features3D.push(featureWrapper);
}
} else {
for (const featureWrapper of layerFeatures) {
features.push(featureWrapper.feature);
}
}
}
}
}

features3D.sort((a, b) => {
return a.intersectionZ - b.intersectionZ;
return b.intersectionZ - a.intersectionZ;
});

for (const featureWrapper of features3D) {
features.push(featureWrapper.feature);
const features = [];
for (let l = this._order.length - 1; l >= 0; l--) {
const layerId = this._order[l];

if (isLayer3D(layerId)) {
// add all 3D features that are in or above the current layer
for (let i = features3D.length - 1; i >= 0; i--) {
const topmost3D = features3D[i].feature;
if (layerIndex[topmost3D.layer.id] < l) break;
features.push(topmost3D);
features3D.pop();
}
} else {
for (const sourceResult of sourceResults) {
const layerFeatures = sourceResult[layerId];
if (layerFeatures) {
for (const featureWrapper of layerFeatures) {
features.push(featureWrapper.feature);
}
}
}
}
}

return features;
Expand Down
7 changes: 5 additions & 2 deletions src/util/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

type Config = {|
API_URL: string,
EVENTS_URL: string,
EVENTS_URL: ?string,
FEEDBACK_URL: string,
REQUIRE_ACCESS_TOKEN: boolean,
ACCESS_TOKEN: ?string,
Expand All @@ -12,10 +12,13 @@ type Config = {|
const config: Config = {
API_URL: 'https://api.mapbox.com',
get EVENTS_URL() {
if (!this.API_URL) { return null; }
if (this.API_URL.indexOf('https://api.mapbox.cn') === 0) {
return 'https://events.mapbox.cn/events/v2';
} else {
} else if (this.API_URL.indexOf('https://api.mapbox.com') === 0) {
return 'https://events.mapbox.com/events/v2';
} else {
return null;
}
},
FEEDBACK_URL: 'https://apps.mapbox.com/feedback',
Expand Down
7 changes: 5 additions & 2 deletions src/util/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class TelemetryEvent {
* to TelemetryEvent#saveData
*/
postEvent(timestamp: number, additionalPayload: {[string]: any}, callback: (err: ?Error) => void) {
if (!config.EVENTS_URL) return;
const eventsUrlObject: UrlObject = parseUrl(config.EVENTS_URL);
eventsUrlObject.params.push(`access_token=${config.ACCESS_TOKEN || ''}`);
const payload: Object = {
Expand Down Expand Up @@ -297,7 +298,8 @@ export class MapLoadEvent extends TelemetryEvent {
postMapLoadEvent(tileUrls: Array<string>, mapId: number) {
//Enabled only when Mapbox Access Token is set and a source uses
// mapbox tiles.
if (config.ACCESS_TOKEN &&
if (config.EVENTS_URL &&
config.ACCESS_TOKEN &&
Array.isArray(tileUrls) &&
tileUrls.some(url => isMapboxURL(url) || isMapboxHTTPURL(url))) {
this.queueRequest({id: mapId, timestamp: Date.now()});
Expand Down Expand Up @@ -336,7 +338,8 @@ export class TurnstileEvent extends TelemetryEvent {
postTurnstileEvent(tileUrls: Array<string>) {
//Enabled only when Mapbox Access Token is set and a source uses
// mapbox tiles.
if (config.ACCESS_TOKEN &&
if (config.EVENTS_URL &&
config.ACCESS_TOKEN &&
Array.isArray(tileUrls) &&
tileUrls.some(url => isMapboxURL(url) || isMapboxHTTPURL(url))) {
this.queueRequest(Date.now());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
[
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-30.0146484375,
0
],
[
-30.0146484375,
50.00773901463688
],
[
30.0146484375,
50.00773901463688
],
[
30.0146484375,
0
],
[
-30.0146484375,
0
]
]
]
},
"type": "Feature",
"properties": {
"layer": "upper"
},
"source": "fill-upper",
"state": {}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-10.01953125,
-20.01464544534136
],
[
-10.01953125,
40.01078714046551
],
[
39.990234375,
40.01078714046551
],
[
39.990234375,
-20.01464544534136
],
[
-10.01953125,
-20.01464544534136
]
]
]
},
"type": "Feature",
"properties": {
"layer": "extrusion_closer"
},
"source": "extrusion_closer",
"state": {}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-39.990234375,
-40.01078714046552
],
[
-39.990234375,
40.01078714046551
],
[
10.01953125,
40.01078714046551
],
[
10.01953125,
-40.01078714046552
],
[
-39.990234375,
-40.01078714046552
]
]
]
},
"type": "Feature",
"properties": {
"layer": "extrusion_further"
},
"source": "extrusion",
"state": {}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-50.009765625,
-50.00773901463686
],
[
-50.009765625,
50.00773901463688
],
[
50.009765625,
50.00773901463688
],
[
50.009765625,
-50.00773901463686
],
[
-50.009765625,
-50.00773901463686
]
]
]
},
"type": "Feature",
"properties": {
"layer": "fill-lower"
},
"source": "fill-lower",
"state": {}
}
]
Loading