Skip to content

Commit

Permalink
Evaluate feature-state dependent layer IDs on bucket creation instead…
Browse files Browse the repository at this point in the history
… of deserialize
  • Loading branch information
Asheem Mamoowala committed Jan 18, 2019
1 parent 2119eaa commit 671073e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/data/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface Bucket {
hasPattern: boolean;
+layers: Array<any>;
+stateDependentLayers: Array<any>;

+stateDependentLayerIds: Array<string>;
populate(features: Array<IndexedFeature>, options: PopulateParameters): void;
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[string]: ImagePosition}): void;
isEmpty(): boolean;
Expand Down Expand Up @@ -107,7 +107,9 @@ export function deserialize(input: Array<Bucket>, style: Style): {[string]: Buck
// look up StyleLayer objects from layer ids (since we don't
// want to waste time serializing/copying them from the worker)
(bucket: any).layers = layers;
(bucket: any).stateDependentLayers = layers.filter((l) => l.isStateDependent());
if ((bucket: any).stateDependentLayerIds) {
(bucket: any).stateDependentLayers = (bucket: any).stateDependentLayerIds.map((lId) => layers.find((l) => l.id == lId));
}
for (const layer of layers) {
output[layer.id] = bucket;
}
Expand Down
2 changes: 2 additions & 0 deletions src/data/bucket/circle_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class CircleBucket<Layer: CircleStyleLayer | HeatmapStyleLayer> implements Bucke
this.indexArray = new TriangleIndexArray();
this.segments = new SegmentVector();
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes, options.layers, options.zoom);
this.stateDependentLayerIds = this.layers.filter( (l) => l.isStateDependent()).map((l) => l.id);

}

populate(features: Array<IndexedFeature>, options: PopulateParameters) {
Expand Down
2 changes: 2 additions & 0 deletions src/data/bucket/fill_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class FillBucket implements Bucket {
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes, options.layers, options.zoom);
this.segments = new SegmentVector();
this.segments2 = new SegmentVector();
this.stateDependentLayerIds = this.layers.filter( (l) => l.isStateDependent()).map((l) => l.id);

}

populate(features: Array<IndexedFeature>, options: PopulateParameters) {
Expand Down
2 changes: 2 additions & 0 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class FillExtrusionBucket implements Bucket {
this.indexArray = new TriangleIndexArray();
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes, options.layers, options.zoom);
this.segments = new SegmentVector();
this.stateDependentLayerIds = this.layers.filter( (l) => l.isStateDependent()).map((l) => l.id);

}

populate(features: Array<IndexedFeature>, options: PopulateParameters) {
Expand Down
2 changes: 2 additions & 0 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class LineBucket implements Bucket {
this.indexArray = new TriangleIndexArray();
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes, options.layers, options.zoom);
this.segments = new SegmentVector();

this.stateDependentLayerIds = this.layers.filter( (l) => l.isStateDependent()).map((l) => l.id);
}

populate(features: Array<IndexedFeature>, options: PopulateParameters) {
Expand Down
2 changes: 2 additions & 0 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class SymbolBucket implements Bucket {
this.sortFeaturesByY = zOrderByViewportY && (layout.get('text-allow-overlap') || layout.get('icon-allow-overlap') ||
layout.get('text-ignore-placement') || layout.get('icon-ignore-placement'));

this.stateDependentLayerIds = this.layers.filter( (l) => l.isStateDependent()).map((l) => l.id);

this.sourceID = options.sourceID;
}

Expand Down

0 comments on commit 671073e

Please sign in to comment.