Skip to content

Commit

Permalink
Lint and Flow fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
astojilj authored and akoylasar committed Jan 24, 2023
1 parent edce689 commit ff45cae
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/geo/lng_lat.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class LngLat {
toEcef(altitude: number): [number, number, number] {
const altInEcef = globeMetersToEcef(altitude);
const radius = GLOBE_RADIUS + altInEcef;
return latLngToECEF(this.lat, this.lng, radius);
const ecef = latLngToECEF(this.lat, this.lng, radius);
return [ecef[0], ecef[1], ecef[2]];
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,12 +1651,11 @@ class Transform {
globeToMercatorMatrix(): ?Array<number> {
if (this.projection.name === 'globe') {
const pixelsToMerc = 1 / this.worldSize;
const m = mat4.create();
mat4.fromScaling(m, [pixelsToMerc, pixelsToMerc, pixelsToMerc]);
const m = mat4.fromScaling([], [pixelsToMerc, pixelsToMerc, pixelsToMerc]);
mat4.multiply(m, m, this.globeMatrix);
return m;
}
return null;
return undefined;
}
recenterOnTerrain() {
Expand Down
4 changes: 2 additions & 2 deletions src/render/draw_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty

prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());
if (painter.transform.projection.name === "globe") {
prerender.call(implementation, context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition());
prerender.call(implementation, context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition(painter.transform.zoom));
} else {
prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());
}
Expand Down Expand Up @@ -77,7 +77,7 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty
context.setDepthMode(depthMode);

if (painter.transform.projection.name === "globe") {
implementation.render(context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition());
implementation.render(context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition(painter.transform.zoom));
} else {
implementation.render(context.gl, painter.transform.customLayerMatrix());
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ class Painter {

this.gpuTimingStart(layer);
if (!painter.transform.projection.unsupportedLayers || !painter.transform.projection.unsupportedLayers.includes(layer.type) ||
(painter.terrain && layer.isLayerDraped)) {
(painter.terrain && layer.type === 'custom')) {
draw[layer.type](painter, sourceCache, layer, coords, this.style.placement.variableOffsets, this.options.isInitialLoad);
}
this.gpuTimingEnd();
Expand Down
4 changes: 3 additions & 1 deletion src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ class Style extends Evented {

isLayerDraped(layer: StyleLayer): boolean {
if (!this.terrain) return false;
if (layer.isLayerDraped) return layer.isLayerDraped();
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-use]
if (typeof layer.isLayerDraped === 'function') return layer.isLayerDraped();
return drapedLayers[layer.type];
}

Expand Down
7 changes: 4 additions & 3 deletions src/style/style_layer/custom_style_layer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @flow

import StyleLayer from '../style_layer.js';
import MercatorCoordinate from '../../geo/mercator_coordinate.js';
import type Map from '../../ui/map.js';
import assert from 'assert';
import type {ValidationErrors} from '../validate_style.js';
import type {ProjectionSpecification} from '../style-spec/types.js';
import type {ProjectionSpecification} from '../../style-spec/types.js';

type CustomRenderMethod = (gl: WebGLRenderingContext, matrix: Array<number>, projection?: ProjectionSpecification, projectionToMercatorMatrix?: Array<number>, projectionToMercatorTransition?: number) => void;
type CustomRenderMethod = (gl: WebGLRenderingContext, matrix: Array<number>, projection: ?ProjectionSpecification, projectionToMercatorMatrix: ?Array<number>, projectionToMercatorTransition: ?number) => void;

/**
* Interface for custom style layers. This is a specification for
Expand Down Expand Up @@ -210,7 +211,7 @@ class CustomStyleLayer extends StyleLayer {
}

shouldRedrape(): boolean {
return this.implementation.shouldRerenderTiles !== undefined && this.implementation.shouldRerenderTiles();
return !!this.implementation.shouldRerenderTiles && this.implementation.shouldRerenderTiles();
}

recalculate() {}
Expand Down
3 changes: 2 additions & 1 deletion src/terrain/terrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import StencilMode from '../gl/stencil_mode.js';
import {DepthStencilAttachment} from '../gl/value.js';
import {drawTerrainRaster, drawTerrainDepth} from './draw_terrain_raster.js';
import type RasterStyleLayer from '../style/style_layer/raster_style_layer.js';
import type CustomStyleLayer from '../style/style_layer/custom_style_layer.js';
import {Elevation} from './elevation.js';
import Framebuffer from '../gl/framebuffer.js';
import ColorMode from '../gl/color_mode.js';
Expand Down Expand Up @@ -934,7 +935,7 @@ export class Terrain extends Elevation {
const layer = this._style._layers[id];
const isHidden = layer.isHidden(this.painter.transform.zoom);
if (layer.type === 'custom') {
return !isHidden && layer.shouldRedrape();
return !isHidden && ((layer: any): CustomStyleLayer).shouldRedrape();
}
return !isHidden && layer.hasTransition();
};
Expand Down

0 comments on commit ff45cae

Please sign in to comment.