Skip to content

Commit

Permalink
Use hardcoded values
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed Nov 4, 2021
1 parent 7fa7c42 commit 7ef3d45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/geo/projection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ const projections = {
winkelTripel
};

export function getTransitionToMercatorEndRange() {
let maxEndRange = 0;
for (const projection in projections) {
if (projections[projection].range) {
maxEndRange = Math.max(maxEndRange, projections[projection].range[1]);
}
}
return maxEndRange;
}

export function getProjection(config: ProjectionSpecification) {
const projection = projections[config.name];
if (!projection) throw new Error(`Invalid projection name: ${config.name}`);
Expand Down
9 changes: 7 additions & 2 deletions src/render/draw_sky.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import assert from 'assert';

export default drawSky;

const OPACITY_ZOOM_START = 7;
const OPACITY_ZOOM_END = 8;

function drawSky(painter: Painter, sourceCache: SourceCache, layer: SkyLayer) {
const tr = painter.transform;
const isMercator = tr.projection.name === 'mercator';
const projectionEndRange = getTransitionToMercatorEndRange();
const transitionOpacity = isMercator ? 1.0 : smoothstep(projectionEndRange, projectionEndRange + 1, tr.zoom);
// For non-mercator projection, use a forced opacity transition.
// This transition is set to be 1.0 after the upper bound which
// ensures to be in the mercator projection.
const transitionOpacity = isMercator ? 1.0 : smoothstep(OPACITY_ZOOM_START, OPACITY_ZOOM_END, tr.zoom);
const opacity = layer.paint.get('sky-opacity') * transitionOpacity;
if (opacity === 0) {
return;
Expand Down

0 comments on commit 7ef3d45

Please sign in to comment.