Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chippieTV committed Aug 9, 2021
1 parent 140ad58 commit db9e55d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/data/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export function deserialize(input: Array<Bucket>, style: Style): {

// look up StyleLayer objects from layer ids (since we don't
// want to waste time serializing/copying them from the worker)
// these 'any' are because 'layers' and 'stateDependentLayers' are readonly
// removing readonly removes the need for any but readonly is most likely important outside of this file
// Bucket is an abstract class so seems to only be extended from
(bucket as any).layers = layers;
if ((bucket as any).stateDependentLayerIds) {
(bucket as any).stateDependentLayers = (bucket as any).stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);
Expand Down
7 changes: 3 additions & 4 deletions src/data/bucket/circle_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class CircleBucket<Layer extends CircleStyleLayer | HeatmapStyleLayer> implement

populate(features: Array<IndexedFeature>, options: PopulateParameters, canonical: CanonicalTileID) {
const styleLayer = this.layers[0];
const bucketFeatures = [];
const bucketFeatures: BucketFeature[] = [];
let circleSortKey = null;
let sortFeaturesByKey = false;

// Heatmap layers are handled in this bucket and have no evaluated properties, so we check our access
if (styleLayer.type === 'circle') {
circleSortKey = (styleLayer as any as CircleStyleLayer).layout.get('circle-sort-key');
circleSortKey = (styleLayer as CircleStyleLayer).layout.get('circle-sort-key');
sortFeaturesByKey = !circleSortKey.isConstant();
}

Expand All @@ -94,7 +94,6 @@ class CircleBucket<Layer extends CircleStyleLayer | HeatmapStyleLayer> implement
if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) continue;

const sortKey = sortFeaturesByKey ?
// $FlowFixMe
circleSortKey.evaluate(evaluationFeature, {}, canonical) :
undefined;

Expand All @@ -116,7 +115,7 @@ class CircleBucket<Layer extends CircleStyleLayer | HeatmapStyleLayer> implement
if (sortFeaturesByKey) {
bucketFeatures.sort((a, b) => {
// a.sortKey is always a number when in use
return (a.sortKey as any as number) - (b.sortKey as any as number);
return (a.sortKey) - (b.sortKey);
});
}

Expand Down
5 changes: 2 additions & 3 deletions src/data/bucket/fill_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FillBucket implements Bucket {
this.hasPattern = hasPattern('fill', this.layers, options);
const fillSortKey = this.layers[0].layout.get('fill-sort-key');
const sortFeaturesByKey = !fillSortKey.isConstant();
const bucketFeatures = [];
const bucketFeatures: BucketFeature[] = [];

for (const {feature, id, index, sourceLayerIndex} of features) {
const needGeometry = this.layers[0]._featureFilter.needGeometry;
Expand Down Expand Up @@ -105,8 +105,7 @@ class FillBucket implements Bucket {

if (sortFeaturesByKey) {
bucketFeatures.sort((a, b) => {
// a.sortKey is always a number when in use
return (a.sortKey as any as number) - (b.sortKey as any as number);
return (a.sortKey) - (b.sortKey);
});
}

Expand Down
11 changes: 5 additions & 6 deletions src/data/bucket/line_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type LineClips = {

type GradientTexture = {
texture: Texture,
gradient: RGBAImage | undefined | null,
gradient?: RGBAImage,
version: number
};

Expand All @@ -88,7 +88,7 @@ class LineBucket implements Bucket {
totalDistance: number;
maxLineLength: number;
scaledDistance: number;
lineClips: LineClips | undefined | null;
lineClips?: LineClips;

e1: number;
e2: number;
Expand Down Expand Up @@ -147,7 +147,7 @@ class LineBucket implements Bucket {
this.hasPattern = hasPattern('line', this.layers, options);
const lineSortKey = this.layers[0].layout.get('line-sort-key');
const sortFeaturesByKey = !lineSortKey.isConstant();
const bucketFeatures = [];
const bucketFeatures: BucketFeature[] = [];

for (const {feature, id, index, sourceLayerIndex} of features) {
const needGeometry = this.layers[0]._featureFilter.needGeometry;
Expand Down Expand Up @@ -175,8 +175,7 @@ class LineBucket implements Bucket {

if (sortFeaturesByKey) {
bucketFeatures.sort((a, b) => {
// a.sortKey is always a number when in use
return (a.sortKey as any as number) - (b.sortKey as any as number);
return (a.sortKey) - (b.sortKey);
});
}

Expand Down Expand Up @@ -240,7 +239,7 @@ class LineBucket implements Bucket {
this.segments.destroy();
}

lineFeatureClips(feature: BucketFeature): LineClips | undefined | null {
lineFeatureClips(feature: BucketFeature): LineClips | undefined {
if (!!feature.properties && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_start') && Object.prototype.hasOwnProperty.call(feature.properties, 'mapbox_clip_end')) {
const start = +feature.properties['mapbox_clip_start'];
const end = +feature.properties['mapbox_clip_end'];
Expand Down
12 changes: 6 additions & 6 deletions src/data/bucket/symbol_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class SymbolBucket implements Bucket {
if (this.sortFeaturesByKey) {
this.features.sort((a, b) => {
// a.sortKey is always a number when sortFeaturesByKey is true
return (a.sortKey as any as number) - (b.sortKey as any as number);
return (a.sortKey as number) - (b.sortKey as number);
});
}
}
Expand Down Expand Up @@ -720,7 +720,7 @@ class SymbolBucket implements Bucket {

addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {
for (let b = startIndex; b < endIndex; b++) {
const box: CollisionBox = (this.collisionBoxArray.get(b) as any);
const box: CollisionBox = (this.collisionBoxArray.get(b));
const x1 = box.x1;
const y1 = box.y1;
const x2 = box.x2;
Expand Down Expand Up @@ -765,27 +765,27 @@ class SymbolBucket implements Bucket {

const collisionArrays = {} as CollisionArrays;
for (let k = textStartIndex; k < textEndIndex; k++) {
const box: CollisionBox = (collisionBoxArray.get(k) as any);
const box: CollisionBox = collisionBoxArray.get(k);
collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
collisionArrays.textFeatureIndex = box.featureIndex;
break; // Only one box allowed per instance
}
for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {
const box: CollisionBox = (collisionBoxArray.get(k) as any);
const box: CollisionBox = collisionBoxArray.get(k);
collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
collisionArrays.verticalTextFeatureIndex = box.featureIndex;
break; // Only one box allowed per instance
}
for (let k = iconStartIndex; k < iconEndIndex; k++) {
// An icon can only have one box now, so this indexing is a bit vestigial...
const box: CollisionBox = (collisionBoxArray.get(k) as any);
const box: CollisionBox = collisionBoxArray.get(k);
collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
collisionArrays.iconFeatureIndex = box.featureIndex;
break; // Only one box allowed per instance
}
for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {
// An icon can only have one box now, so this indexing is a bit vestigial...
const box: CollisionBox = (collisionBoxArray.get(k) as any);
const box: CollisionBox = collisionBoxArray.get(k);
collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
collisionArrays.verticalIconFeatureIndex = box.featureIndex;
break; // Only one box allowed per instance
Expand Down
2 changes: 1 addition & 1 deletion src/data/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type VertexArrayObject from '../render/vertex_array_object';
import type {StructArray} from '../util/struct_array';

export type Segment = {
sortKey: number | void,
sortKey: number,
vertexOffset: number,
primitiveOffset: number,
vertexLength: number,
Expand Down

0 comments on commit db9e55d

Please sign in to comment.