Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-gl

Package Overview
Dependencies
Maintainers
28
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl - npm Package Compare versions

Comparing version 2.12.1 to 2.13.0-beta.1

3

build/rollup_plugins.js

@@ -29,3 +29,4 @@

'process.env.CI': JSON.stringify(process.env.CI),
'process.env.UPDATE': JSON.stringify(process.env.UPDATE)
'process.env.UPDATE': JSON.stringify(process.env.UPDATE),
'process.env.USE_WEBGL2': JSON.stringify(process.env.USE_WEBGL2)
}) : false,

@@ -32,0 +33,0 @@ glsl('./src/shaders/*.glsl', production),

@@ -5,19 +5,19 @@ mapbox-gl-js v2.0

Copyright (c) 2020, Mapbox
Copyright © 2021 - 2023 Mapbox, Inc. All rights reserved.
All rights reserved.
The software and files in this repository (collectively, "Software") are
licensed under the Mapbox TOS for use only with the relevant Mapbox product(s)
listed at www.mapbox.com/pricing. This license allows developers with a
current active Mapbox account to use and modify the authorized portions of the
Software as needed for use only with the relevant Mapbox product(s) through
their Mapbox account in accordance with the Mapbox TOS. This license
terminates automatically if a developer no longer has a Mapbox account in good
standing or breaches the Mapbox TOS. For the license terms, please see the
Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox
Product Terms at www.mapbox.com/legal/service-terms. If this Software is a
SDK, modifications that change or interfere with marked portions of the code
related to billing, accounting, or data collection are not authorized and the
SDK sends limited de-identified location and usage data which is used in
accordance with the Mapbox TOS. [Updated 2023-01]
Mapbox gl-js version 2.0 or higher (“Mapbox Web SDK”) must be used according to
the Mapbox Terms of Service. This license allows developers with a current active
Mapbox account to use and modify the Mapbox Web SDK. Developers may modify the
Mapbox Web SDK code so long as the modifications do not change or interfere with
marked portions of the code related to billing, accounting, and anonymized data
collection. The Mapbox Web SDK only sends anonymized usage data, which Mapbox uses
for fixing bugs and errors, accounting, and generating aggregated anonymized
statistics. This license terminates automatically if a user no longer has an
active Mapbox account.
For the full license terms, please see the Mapbox Terms of Service at
https://www.mapbox.com/legal/tos/.
-------------------------------------------------------------------------------

@@ -24,0 +24,0 @@

{
"name": "mapbox-gl",
"description": "A WebGL interactive maps library",
"version": "2.12.1",
"version": "2.13.0-beta.1",
"main": "dist/mapbox-gl.js",

@@ -39,8 +39,7 @@ "style": "dist/mapbox-gl.css",

"@babel/eslint-parser": "^7.18.9",
"@babel/preset-flow": "^7.18.6",
"@mapbox/flow-remove-types": "^2.0.0",
"@mapbox/mvt-fixtures": "^3.10.0",
"@octokit/rest": "^19.0.4",
"@rollup/plugin-commonjs": "^23.0.3",
"@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",

@@ -66,4 +65,4 @@ "@rollup/plugin-replace": "^5.0.0",

"eslint-plugin-jsdoc": "^39.6.4",
"flow-bin": "0.145.0",
"gl": "6.0.1",
"flow-bin": "0.152.0",
"gl": "6.0.2",
"glob": "^8.0.3",

@@ -93,2 +92,3 @@ "is-builtin-module": "^3.2.0",

"selenium-webdriver": "^4.4.0",
"serve-static": "^1.15.0",
"shuffle-seed": "^1.1.6",

@@ -102,3 +102,3 @@ "sinon": "^15.0.0",

"tape-filter": "^1.0.4",
"testem": "^3.10.0"
"testem": "^3.10.1"
},

@@ -142,2 +142,3 @@ "browser": {

"test-render-firefox": "cross-env BROWSER=Firefox SUITE_NAME=render testem ci -f test/integration/testem/testem.js",
"test-render-safari": "cross-env BROWSER=Safari SUITE_NAME=render testem ci -f test/integration/testem/testem.js",
"test-render-prod": "BUILD=production SUITE_NAME=render testem ci -f test/integration/testem/testem.js",

@@ -144,0 +145,0 @@ "test-render-csp": "BUILD=csp SUITE_NAME=render testem ci -f test/integration/testem/testem.js",

@@ -33,8 +33,6 @@ [<img width="300" alt="Mapbox logo" src="https://static-assets.mapbox.com/www/logos/mapbox-logo-black.png">](https://www.mapbox.com/)

Copyright © 2021 Mapbox
Mapbox Web SDK
All rights reserved.
Copyright © 2021 - 2023 Mapbox, Inc. All rights reserved.
Mapbox GL JS version 2.0 or higher (“Mapbox Web SDK”) must be used according to the Mapbox Terms of Service. This license allows developers with a current active Mapbox account to use and modify the Mapbox Web SDK. Developers may modify the Mapbox Web SDK code so long as the modifications do not change or interfere with marked portions of the code related to billing, accounting, and anonymized data collection. The Mapbox Web SDK sends only anonymized usage data, which Mapbox uses for fixing bugs and errors, accounting, and generating aggregated anonymized statistics. This license terminates automatically if a user no longer has an active Mapbox account.
For the full license terms, please see the [Mapbox Terms of Service](https://www.mapbox.com/legal/tos/).
The software and files in this repository (collectively, “Software”) are licensed under the Mapbox TOS for use only with the relevant Mapbox product(s) listed at www.mapbox.com/pricing. This license allows developers with a current active Mapbox account to use and modify the authorized portions of the Software as needed for use only with the relevant Mapbox product(s) through their Mapbox account in accordance with the Mapbox TOS. This license terminates automatically if a developer no longer has a Mapbox account in good standing or breaches the Mapbox TOS. For the license terms, please see the Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox Product Terms at www.mapbox.com/legal/service-terms. If this Software is a SDK, modifications that change or interfere with marked portions of the code related to billing, accounting, or data collection are not authorized and the SDK sends limited de-identified location and usage data which is used in accordance with the Mapbox TOS. [Updated 2023-01]

@@ -5,2 +5,3 @@ // @flow

import LngLatBounds from './lng_lat_bounds.js';
import {GLOBE_RADIUS, globeMetersToEcef, latLngToECEF} from '../geo/projection/globe_util.js';

@@ -14,2 +15,7 @@ /*

/*
* The average circumference of the earth in meters.
*/
export const earthCircumference = 2 * Math.PI * earthRadius;
/**

@@ -126,2 +132,8 @@ * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.

toEcef(altitude: number): [number, number, number] {
const altInEcef = globeMetersToEcef(altitude);
const radius = GLOBE_RADIUS + altInEcef;
return (latLngToECEF(this.lat, this.lng, radius): any);
}
/**

@@ -128,0 +140,0 @@ * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties

// @flow
import LngLat, {earthRadius} from '../geo/lng_lat.js';
import LngLat, {earthCircumference} from '../geo/lng_lat.js';
import type {LngLatLike} from '../geo/lng_lat.js';
/*
* The average circumference of the world in meters.
*/
const earthCircumference = 2 * Math.PI * earthRadius; // meters
/*
* The circumference at a line of latitude in meters.

@@ -13,0 +8,0 @@ */

@@ -19,3 +19,3 @@ // @flow

import {Aabb, Ray} from '../../util/primitives.js';
import LngLat from '../lng_lat.js';
import LngLat, {earthRadius} from '../lng_lat.js';
import LngLatBounds from '../lng_lat_bounds.js';

@@ -52,3 +52,2 @@

export const GLOBE_RADIUS = EXTENT / Math.PI / 2.0;
export const GLOBE_METERS_TO_ECEF = mercatorZfromAltitude(1, 0.0) * 2.0 * GLOBE_RADIUS * Math.PI;
const GLOBE_NORMALIZATION_BIT_RANGE = 15;

@@ -73,2 +72,6 @@ const GLOBE_NORMALIZATION_MASK = (1 << (GLOBE_NORMALIZATION_BIT_RANGE - 1)) - 1;

export function globeMetersToEcef(d: number): number {
return d * GLOBE_RADIUS / earthRadius;
}
export function globePointCoordinate(tr: Transform, x: number, y: number, clampToHorizon: boolean = true): ?MercatorCoordinate {

@@ -384,3 +387,3 @@ const point0 = vec3.scale([], tr._camera.position, tr.worldSize);

let wrap = 0;
const tileCenterXFromCamera = (w + e) / 2 - camX;
const tileCenterXFromCamera = (w + e) / 2 - camX;
if (tileCenterXFromCamera > .5) {

@@ -396,6 +399,6 @@ wrap = -1;

// Transform Mercator coordinates to points on the plane tangent to the globe at cameraCenter.
w = ((w + wrap) * numTiles - camX) * mercatorScale + camX;
e = ((e + wrap) * numTiles - camX) * mercatorScale + camX;
n = (n * numTiles - camY) * mercatorScale + camY;
s = (s * numTiles - camY) * mercatorScale + camY;
w = ((w + wrap) * numTiles - camX) * mercatorScale + camX;
e = ((e + wrap) * numTiles - camX) * mercatorScale + camX;
n = (n * numTiles - camY) * mercatorScale + camY;
s = (s * numTiles - camY) * mercatorScale + camY;

@@ -643,3 +646,3 @@ return [[w, s, 0],

const pivotToCamera = vec3.normalize([], centerToPivot);
vec3.scale(pivotToCamera, pivotToCamera, tr.cameraToCenterDistance / tr.pixelsPerMeter * GLOBE_METERS_TO_ECEF);
vec3.scale(pivotToCamera, pivotToCamera, globeMetersToEcef(tr.cameraToCenterDistance / tr.pixelsPerMeter));
vec3.transformMat4(pivotToCamera, pivotToCamera, rotation);

@@ -700,2 +703,16 @@

// Generate terrain grid with embedded skirts
const EMBED_SKIRTS = true;
type GridLodSegments = {
withoutSkirts: SegmentVector,
withSkirts: SegmentVector
};
type GridWithLods = {
vertices: PosArray,
indices: TriangleIndexArray,
segments: Array<GridLodSegments>
};
export class GlobeSharedBuffers {

@@ -709,3 +726,3 @@ _poleNorthVertexBuffer: VertexBuffer;

_gridIndexBuffer: IndexBuffer;
_gridSegments: Array<SegmentVector>;
_gridSegments: Array<GridLodSegments>;

@@ -727,3 +744,6 @@ _wireframeIndexBuffer: IndexBuffer;

for (const segments of this._poleSegments) segments.destroy();
for (const segments of this._gridSegments) segments.destroy();
for (const segments of this._gridSegments) {
segments.withSkirts.destroy();
segments.withoutSkirts.destroy();
}

@@ -736,35 +756,132 @@ if (this._wireframeIndexBuffer) {

_createGrid(context: Context) {
const gridVertices = new PosArray();
const gridIndices = new TriangleIndexArray();
// Generate terrain grid vertices and indices for all LOD's
//
// Grid vertices memory layout:
//
// First line Skirt
// ┌───────────────┐
// │┌─────────────┐│
// Left ││┼┼┼┼┼┼┼┼┼┼┼┼┼││ Right
// Border ││┼┼┼┼┼┼┼┼┼┼┼┼┼││ Border
// Skirt │├─────────────┤│ Skirt
// ││ Main Grid ││
// │├─────────────┤│
// ││┼┼┼┼┼┼┼┼┼┼┼┼┼││
// ││┼┼┼┼┼┼┼┼┼┼┼┼┼││
// │└─────────────┘│
// ├───────────────┤
// ├───────────────┤
// └───────────────┘
// Bottom Skirt = Number of LOD's
//
_fillGridMeshWithLods(longitudinalCellsCount: number, latitudinalLods: number[]): GridWithLods {
const vertices = new PosArray();
const indices = new TriangleIndexArray();
const segments: Array<GridLodSegments> = [];
const quadExt = GLOBE_VERTEX_GRID_SIZE;
const vertexExt = quadExt + 1;
const xVertices = longitudinalCellsCount + 1 + 2 * (EMBED_SKIRTS ? 1 : 0);
const yVerticesHighLodNoStrip = latitudinalLods[0] + 1;
const yVerticesHighLodWithStrip = latitudinalLods[0] + 1 + (EMBED_SKIRTS ? 1 + latitudinalLods.length : 0);
for (let j = 0; j < vertexExt; j++)
for (let i = 0; i < vertexExt; i++)
gridVertices.emplaceBack(i, j);
// Index adjustment, used to make strip (x, y) vertex input attribute data
// to match same data on ordinary grid edges
const prepareVertex = (x: number, y: number, isSkirt: boolean) => {
if (!EMBED_SKIRTS) return [x, y];
this._gridSegments = [];
for (let k = 0, primitiveOffset = 0; k < GLOBE_LATITUDINAL_GRID_LOD_TABLE.length; k++) {
const latitudinalLod = GLOBE_LATITUDINAL_GRID_LOD_TABLE[k];
for (let j = 0; j < latitudinalLod; j++) {
for (let i = 0; i < quadExt; i++) {
const index = j * vertexExt + i;
gridIndices.emplaceBack(index + 1, index, index + vertexExt);
gridIndices.emplaceBack(index + vertexExt, index + vertexExt + 1, index + 1);
let adjustedX = (() => {
if (x === xVertices - 1) {
return x - 2;
} else if (x === 0) {
return x;
} else {
return x - 1;
}
})();
// Skirt factor is introduces as an offset to the .x coordinate, similar to how it's done for mercator grids
const skirtOffset = 24575;
adjustedX += isSkirt ? skirtOffset : 0;
return [adjustedX, y];
};
// Add first horizontal strip if present
if (EMBED_SKIRTS) {
for (let x = 0; x < xVertices; ++x) {
vertices.emplaceBack(...prepareVertex(x, 0, true));
}
}
const numVertices = (latitudinalLod + 1) * vertexExt;
const numPrimitives = latitudinalLod * quadExt * 2;
// Add main grid part with vertices strips embedded
for (let y = 0; y < yVerticesHighLodNoStrip; ++y) {
for (let x = 0; x < xVertices; ++x) {
const isSideBorder = (x === 0 || x === xVertices - 1);
this._gridSegments.push(SegmentVector.simpleSegment(0, primitiveOffset, numVertices, numPrimitives));
primitiveOffset += numPrimitives;
vertices.emplaceBack(...prepareVertex(x, y, isSideBorder && EMBED_SKIRTS));
}
}
this._gridBuffer = context.createVertexBuffer(gridVertices, posAttributes.members);
this._gridIndexBuffer = context.createIndexBuffer(gridIndices, true);
// Add bottom strips for each LOD
if (EMBED_SKIRTS) {
for (let lodIdx = 0; lodIdx < latitudinalLods.length; ++lodIdx) {
const lastYRowForLod = latitudinalLods[lodIdx];
for (let x = 0; x < xVertices; ++x) {
vertices.emplaceBack(...prepareVertex(x, lastYRowForLod, true));
}
}
}
// Fill triangles
for (let lodIdx = 0; lodIdx < latitudinalLods.length; ++lodIdx) {
const indexOffset = indices.length;
const yVerticesLod = latitudinalLods[lodIdx] + 1 + 2 * (EMBED_SKIRTS ? 1 : 0);
const skirtsOnlyIndices = new TriangleIndexArray();
for (let y = 0; y < yVerticesLod - 1; y++) {
const isLastLine = (y === yVerticesLod - 2);
const offsetToNextRow =
(isLastLine && EMBED_SKIRTS ?
(xVertices * (yVerticesHighLodWithStrip - latitudinalLods.length + lodIdx - y)) :
xVertices);
for (let x = 0; x < xVertices - 1; x++) {
const idx = y * xVertices + x;
const isSkirt = EMBED_SKIRTS && (y === 0 || isLastLine || x === 0 || x === xVertices - 2);
if (isSkirt) {
skirtsOnlyIndices.emplaceBack(idx + 1, idx, idx + offsetToNextRow);
skirtsOnlyIndices.emplaceBack(idx + offsetToNextRow, idx + offsetToNextRow + 1, idx + 1);
} else {
indices.emplaceBack(idx + 1, idx, idx + offsetToNextRow);
indices.emplaceBack(idx + offsetToNextRow, idx + offsetToNextRow + 1, idx + 1);
}
}
}
// Segments grid only
const withoutSkirts = SegmentVector.simpleSegment(0, indexOffset, vertices.length, indices.length - indexOffset);
for (let i = 0; i < skirtsOnlyIndices.uint16.length; i += 3) {
indices.emplaceBack(skirtsOnlyIndices.uint16[i], skirtsOnlyIndices.uint16[i + 1], skirtsOnlyIndices.uint16[i + 2]);
}
// Segments grid + skirts only
const withSkirts = SegmentVector.simpleSegment(0, indexOffset, vertices.length, indices.length - indexOffset);
segments.push({withoutSkirts, withSkirts});
}
return {vertices, indices, segments};
}
_createGrid(context: Context) {
const gridWithLods = this._fillGridMeshWithLods(GLOBE_VERTEX_GRID_SIZE, GLOBE_LATITUDINAL_GRID_LOD_TABLE);
this._gridSegments = gridWithLods.segments;
this._gridBuffer = context.createVertexBuffer(gridWithLods.vertices, posAttributes.members);
this._gridIndexBuffer = context.createIndexBuffer(gridWithLods.indices, true);
}
_createPoles(context: Context) {

@@ -807,4 +924,4 @@ const poleIndices = new TriangleIndexArray();

getGridBuffers(latitudinalLod: number): [VertexBuffer, IndexBuffer, SegmentVector] {
return [this._gridBuffer, this._gridIndexBuffer, this._gridSegments[latitudinalLod]];
getGridBuffers(latitudinalLod: number, withSkirts: boolean): [VertexBuffer, IndexBuffer, SegmentVector] {
return [this._gridBuffer, this._gridIndexBuffer, withSkirts ? this._gridSegments[latitudinalLod].withSkirts : this._gridSegments[latitudinalLod].withoutSkirts];
}

@@ -820,9 +937,11 @@

const quadExt = GLOBE_VERTEX_GRID_SIZE;
const vertexExt = quadExt + 1;
const vertexExt = quadExt + 1 + (EMBED_SKIRTS ? 2 : 0);
const iterOffset = EMBED_SKIRTS ? 1 : 0;
this._wireframeSegments = [];
for (let k = 0, primitiveOffset = 0; k < GLOBE_LATITUDINAL_GRID_LOD_TABLE.length; k++) {
const latitudinalLod = GLOBE_LATITUDINAL_GRID_LOD_TABLE[k];
for (let j = 0; j < latitudinalLod; j++) {
for (let i = 0; i < quadExt; i++) {
for (let j = iterOffset; j < latitudinalLod + iterOffset; j++) {
for (let i = iterOffset; i < quadExt + iterOffset; i++) {
const index = j * vertexExt + i;

@@ -829,0 +948,0 @@ wireframeIndices.emplaceBack(index, index + 1);

@@ -14,3 +14,2 @@ // @flow

import {
GLOBE_METERS_TO_ECEF,
GLOBE_SCALE_MATCH_LATITUDE,

@@ -24,3 +23,4 @@ latLngToECEF,

globePointCoordinate,
tileCoordToECEF
tileCoordToECEF,
globeMetersToEcef
} from './globe_util.js';

@@ -42,3 +42,3 @@

this.zAxisUnit = "pixels";
this.unsupportedLayers = ['debug', 'custom'];
this.unsupportedLayers = ['debug'];
this.range = [3, 5];

@@ -146,4 +146,4 @@ }

upVectorScale(id: CanonicalTileID): ElevationScale {
return {metersToTile: GLOBE_METERS_TO_ECEF * globeECEFNormalizationScale(globeTileBounds(id))};
return {metersToTile: globeMetersToEcef(globeECEFNormalizationScale(globeTileBounds(id)))};
}
}

@@ -28,2 +28,3 @@ // @flow

gl: WebGLRenderingContext;
isWebGL2: boolean;
extVertexArrayObject: any;

@@ -78,6 +79,17 @@ currentNumAttributes: ?number;

constructor(gl: WebGLRenderingContext) {
constructor(gl: WebGLRenderingContext, isWebGL2: boolean = false) {
this.gl = gl;
this.isWebGL2 = isWebGL2;
this.extVertexArrayObject = this.gl.getExtension('OES_vertex_array_object');
if (isWebGL2) {
/* $FlowFixMe[cannot-resolve-name] */ // Not adding dependency to webgl2 yet.
const gl2 = (gl: WebGL2RenderingContext);
this.extVertexArrayObject = {
createVertexArrayOES: gl2.createVertexArray.bind(gl),
deleteVertexArrayOES: gl2.deleteVertexArray.bind(gl),
bindVertexArrayOES: gl2.bindVertexArray.bind(gl)
};
}
this.clearColor = new ClearColor(this);

@@ -132,8 +144,7 @@ this.clearDepth = new ClearDepth(this);

this.extTextureHalfFloat = gl.getExtension('OES_texture_half_float');
if (this.extTextureHalfFloat) {
gl.getExtension('OES_texture_half_float_linear');
if (!isWebGL2) this.extTextureHalfFloat = gl.getExtension('OES_texture_half_float');
if (isWebGL2 || (this.extTextureHalfFloat && gl.getExtension('OES_texture_half_float_linear'))) {
this.extRenderToTextureHalfFloat = gl.getExtension('EXT_color_buffer_half_float');
}
this.extStandardDerivatives = gl.getExtension('OES_standard_derivatives');
this.extStandardDerivatives = isWebGL2 || gl.getExtension('OES_standard_derivatives');

@@ -140,0 +151,0 @@ this.extTimerQuery = gl.getExtension('EXT_disjoint_timer_query');

@@ -20,3 +20,3 @@ // @flow

const gl = context.gl;
const fbo = this.framebuffer = gl.createFramebuffer();
const fbo = this.framebuffer = ((gl.createFramebuffer(): any): WebGLFramebuffer);

@@ -23,0 +23,0 @@ this.colorAttachment = new ColorAttachment(context, fbo);

@@ -10,3 +10,3 @@ // @flow

context: Context;
buffer: WebGLBuffer;
buffer: ?WebGLBuffer;
dynamicDraw: boolean;

@@ -13,0 +13,0 @@

@@ -324,3 +324,3 @@ // @flow

export class Program extends BaseValue<?WebGLProgram> {
getDefault(): WebGLProgram {
getDefault(): WebGLProgram | null {
return null;

@@ -363,3 +363,3 @@ }

export class BindFramebuffer extends BaseValue<?WebGLFramebuffer> {
getDefault(): WebGLFramebuffer {
getDefault(): WebGLFramebuffer | null {
return null;

@@ -377,3 +377,3 @@ }

export class BindRenderbuffer extends BaseValue<?WebGLRenderbuffer> {
getDefault(): WebGLRenderbuffer {
getDefault(): WebGLRenderbuffer | null {
return null;

@@ -391,3 +391,3 @@ }

export class BindTexture extends BaseValue<?WebGLTexture> {
getDefault(): WebGLTexture {
getDefault(): WebGLTexture | null {
return null;

@@ -405,3 +405,3 @@ }

export class BindVertexBuffer extends BaseValue<?WebGLBuffer> {
getDefault(): WebGLBuffer {
getDefault(): WebGLBuffer | null {
return null;

@@ -419,3 +419,3 @@ }

export class BindElementBuffer extends BaseValue<?WebGLBuffer> {
getDefault(): WebGLBuffer {
getDefault(): WebGLBuffer | null {
return null;

@@ -422,0 +422,0 @@ }

@@ -39,3 +39,3 @@ // @flow

context: Context;
buffer: WebGLBuffer;
buffer: ?WebGLBuffer;

@@ -42,0 +42,0 @@ /**

@@ -8,8 +8,12 @@ // @flow

import {warnOnce} from '../util/util.js';
import {globeToMercatorTransition} from './../geo/projection/globe_util.js';
import type Painter from './painter.js';
import type {OverscaledTileID} from '../source/tile_id.js';
import type SourceCache from '../source/source_cache.js';
import type CustomStyleLayer from '../style/style_layer/custom_style_layer.js';
import MercatorCoordinate from '../geo/mercator_coordinate.js';
import assert from 'assert';
function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) {
function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer, coords: Array<OverscaledTileID>) {

@@ -19,4 +23,5 @@ const context = painter.context;

if (painter.transform.projection.unsupportedLayers && painter.transform.projection.unsupportedLayers.includes("custom")) {
warnOnce('Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.');
if (painter.transform.projection.unsupportedLayers && painter.transform.projection.unsupportedLayers.includes("custom") &&
!(painter.terrain && (painter.terrain.renderingToTexture || painter.renderPass === 'offscreen') && layer.isLayerDraped())) {
warnOnce('Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.');
return;

@@ -32,3 +37,8 @@ }

prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());
if (painter.transform.projection.name === "globe") {
const center = painter.transform.pointMerc;
prerender.call(implementation, context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition(painter.transform.zoom), [center.x, center.y], painter.transform.pixelsPerMeterRatio);
} else {
prerender.call(implementation, context.gl, painter.transform.customLayerMatrix());
}

@@ -41,2 +51,22 @@ context.setDirty();

if (painter.terrain && painter.terrain.renderingToTexture) {
assert(implementation.renderToTile);
assert(coords.length === 1);
const renderToTile = implementation.renderToTile;
if (renderToTile) {
const c = coords[0].canonical;
const unwrapped = new MercatorCoordinate(c.x + coords[0].wrap * (1 << c.z), c.y, c.z);
context.setDepthMode(DepthMode.disabled);
context.setStencilMode(StencilMode.disabled);
context.setColorMode(painter.colorModeForRenderPass());
painter.setCustomLayerDefaults();
renderToTile.call(implementation, context.gl, unwrapped);
context.setDirty();
painter.setBaseState();
}
return;
}
painter.setCustomLayerDefaults();

@@ -53,3 +83,8 @@

implementation.render(context.gl, painter.transform.customLayerMatrix());
if (painter.transform.projection.name === "globe") {
const center = painter.transform.pointMerc;
implementation.render(context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition(painter.transform.zoom), [center.x, center.y], painter.transform.pixelsPerMeterRatio);
} else {
implementation.render(context.gl, painter.transform.customLayerMatrix());
}

@@ -56,0 +91,0 @@ context.setDirty();

@@ -73,5 +73,2 @@ // @flow

baseDefines.push('PROJECTION_GLOBE_VIEW');
if (painter.style.terrainSetForDrapingOnly()) {
baseDefines.push('TERRAIN');
}
}

@@ -78,0 +75,0 @@ if (ao[0] > 0) { // intensity

@@ -123,4 +123,6 @@ // @flow

// Otherwise, fall back to a low precision texture
const internalFormat = context.extRenderToTextureHalfFloat ? context.extTextureHalfFloat.HALF_FLOAT_OES : gl.UNSIGNED_BYTE;
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, internalFormat, null);
/* $FlowFixMe[prop-missing] WebGL2 */
const type = context.extRenderToTextureHalfFloat ? (context.isWebGL2 ? gl.HALF_FLOAT : context.extTextureHalfFloat.HALF_FLOAT_OES) : gl.UNSIGNED_BYTE;
/* $FlowFixMe[prop-missing] WebGL2 */
gl.texImage2D(gl.TEXTURE_2D, 0, (context.isWebGL2 && context.extRenderToTextureHalfFloat) ? gl.RGBA16F : gl.RGBA, width, height, 0, gl.RGBA, type, null);
fbo.colorAttachment.set(texture);

@@ -127,0 +129,0 @@ }

@@ -166,4 +166,4 @@ // @flow

constructor(gl: WebGLRenderingContext, transform: Transform) {
this.context = new Context(gl);
constructor(gl: WebGLRenderingContext, transform: Transform, isWebGL2: boolean = false) {
this.context = new Context(gl, isWebGL2);
this.transform = transform;

@@ -707,3 +707,4 @@ this._tileTextures = {};

this.gpuTimingStart(layer);
if (!painter.transform.projection.unsupportedLayers || !painter.transform.projection.unsupportedLayers.includes(layer.type)) {
if (!painter.transform.projection.unsupportedLayers || !painter.transform.projection.unsupportedLayers.includes(layer.type) ||
(painter.terrain && layer.type === 'custom')) {
draw[layer.type](painter, sourceCache, layer, coords, this.style.placement.variableOffsets, this.options.isInitialLoad);

@@ -992,3 +993,5 @@ }

saveCanvasCopy() {
this.frameCopies.push(this.canvasCopy());
const canvas = this.canvasCopy();
if (!canvas) return;
this.frameCopies.push(canvas);
this.tileLoaded = false;

@@ -995,0 +998,0 @@ }

@@ -82,3 +82,3 @@ // @flow

const gl = context.gl;
this.program = gl.createProgram();
this.program = ((gl.createProgram(): any): WebGLProgram);

@@ -91,5 +91,6 @@ const staticAttrInfo = getTokenizedAttributes(source.staticAttributes);

defines = defines.concat(fixedDefines.map((define) => `#define ${define}`));
const version = context.isWebGL2 ? '#version 300 es\n' : '';
const fragmentSource = defines.concat(
context.extStandardDerivatives ? standardDerivativesExt.concat(preludeFragPrecisionQualifiers) : preludeFragPrecisionQualifiers,
const fragmentSource = version + defines.concat(
context.extStandardDerivatives && version.length === 0 ? standardDerivativesExt.concat(preludeFragPrecisionQualifiers) : preludeFragPrecisionQualifiers,
preludeFragPrecisionQualifiers,

@@ -100,3 +101,3 @@ preludeCommonSource,

source.fragmentSource).join('\n');
const vertexSource = defines.concat(
const vertexSource = version + defines.concat(
preludeVertPrecisionQualifiers,

@@ -109,3 +110,3 @@ preludeCommonSource,

const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
const fragmentShader = ((gl.createShader(gl.FRAGMENT_SHADER): any): WebGLShader);
if (gl.isContextLost()) {

@@ -120,3 +121,3 @@ this.failedToCreate = true;

const vertexShader = gl.createShader(gl.VERTEX_SHADER);
const vertexShader = ((gl.createShader(gl.VERTEX_SHADER): any): WebGLShader);
if (gl.isContextLost()) {

@@ -123,0 +124,0 @@ this.failedToCreate = true;

@@ -48,3 +48,3 @@ // @flow

this.format = format;
this.texture = context.gl.createTexture();
this.texture = ((context.gl.createTexture(): any): WebGLTexture);
this.update(image, options);

@@ -51,0 +51,0 @@ }

@@ -158,5 +158,5 @@ // @flow

tileSize: number;
attribution: string;
attribution: string | void;
roundZoom: boolean;
roundZoom: boolean | void;
tileBounds: ?TileBounds;

@@ -163,0 +163,0 @@ minTileCacheSize: ?number;

@@ -73,7 +73,7 @@ // @flow

tileSize: number;
attribution: string;
attribution: string | void;
promoteId: ?PromoteIdSpecification;
isTileClipped: boolean;
reparseOverscaled: boolean;
isTileClipped: boolean | void;
reparseOverscaled: boolean | void;
_data: GeoJSON | string;

@@ -80,0 +80,0 @@ _options: GeoJSONSourceSpecification;

@@ -112,2 +112,3 @@ // @flow

image: HTMLImageElement | ImageBitmap | ImageData;
// $FlowFixMe
tileID: CanonicalTileID;

@@ -114,0 +115,0 @@ _boundsArray: ?RasterBoundsArray;

@@ -28,2 +28,23 @@ // @flow

/**
* A source containing raster tiles.
* See the [Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#raster) for detailed documentation of options.
*
* @example
* map.addSource('some id', {
* type: 'raster',
* url: 'mapbox://mapbox.satellite',
* tileSize: 256
* });
*
* @example
* map.addSource('some id', {
* type: 'raster',
* tiles: ['https://img.nj.gov/imagerywms/Natural2015?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&transparent=true&width=256&height=256&layers=Natural2015'],
* tileSize: 256
* });
*
* @see [Example: Add a raster tile source](https://docs.mapbox.com/mapbox-gl-js/example/map-tiles/)
* @see [Example: Add a WMS source](https://docs.mapbox.com/mapbox-gl-js/example/wms/)
*/
class RasterTileSource extends Evented implements Source {

@@ -40,3 +61,3 @@ type: 'raster' | 'raster-dem';

tileBounds: TileBounds;
roundZoom: boolean;
roundZoom: boolean | void;
dispatcher: Dispatcher;

@@ -68,3 +89,3 @@ map: Map;

load() {
load(callback?: Callback<void>) {
this._loaded = false;

@@ -89,2 +110,4 @@ this.fire(new Event('dataloading', {dataType: 'source'}));

}
if (callback) callback(err);
});

@@ -102,7 +125,59 @@ }

/**
* Reloads the source data and re-renders the map.
*
* @example
* map.getSource('source-id').reload();
*/
reload() {
this.cancelTileJSONRequest();
this.load(() => this.map.style._clearSource(this.id));
}
/**
* Sets the source `tiles` property and re-renders the map.
*
* @param {string[]} tiles An array of one or more tile source URLs, as in the TileJSON spec.
* @returns {RasterTileSource} Returns itself to allow for method chaining.
* @example
* map.addSource('source-id', {
* type: 'raster',
* tiles: ['https://some_end_point.net/{z}/{x}/{y}.png'],
* tileSize: 256
* });
*
* // Set the endpoint associated with a raster tile source.
* map.getSource('source-id').setTiles(['https://another_end_point.net/{z}/{x}/{y}.png']);
*/
setTiles(tiles: Array<string>): this {
this._options.tiles = tiles;
this.reload();
return this;
}
/**
* Sets the source `url` property and re-renders the map.
*
* @param {string} url A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`.
* @returns {RasterTileSource} Returns itself to allow for method chaining.
* @example
* map.addSource('source-id', {
* type: 'raster',
* url: 'mapbox://mapbox.satellite'
* });
*
* // Update raster tile source to a new URL endpoint
* map.getSource('source-id').setUrl('mapbox://mapbox.satellite');
*/
setUrl(url: string): this {
this.url = url;
this._options.url = url;
this.reload();
return this;
}
onRemove() {
if (this._tileJSONRequest) {
this._tileJSONRequest.cancel();
this._tileJSONRequest = null;
}
this.cancelTileJSONRequest();
}

@@ -171,4 +246,10 @@

}
cancelTileJSONRequest() {
if (!this._tileJSONRequest) return;
this._tileJSONRequest.cancel();
this._tileJSONRequest = null;
}
}
export default RasterTileSource;

@@ -134,3 +134,3 @@ // @flow

if (deleteWholeFeatureState) this.state[sourceLayer][feature] = {};
else {
else if (this.state[sourceLayer][feature]) {
for (const key of Object.keys(this.deletedStates[sourceLayer][feature])) {

@@ -137,0 +137,0 @@ delete this.state[sourceLayer][feature][key];

@@ -389,3 +389,3 @@ // @flow

this.imageAtlasTexture = new Texture(context, this.imageAtlas.image, gl.RGBA);
this.imageAtlas.uploaded = true;
((this.imageAtlas: any): ImageAtlas).uploaded = true;
}

@@ -400,3 +400,3 @@

this.lineAtlasTexture = new Texture(context, this.lineAtlas.image, gl.ALPHA);
this.lineAtlas.uploaded = true;
((this.lineAtlas: any): LineAtlas).uploaded = true;
}

@@ -403,0 +403,0 @@ }

@@ -68,4 +68,4 @@ // @flow

tileBounds: TileBounds;
reparseOverscaled: boolean;
isTileClipped: boolean;
reparseOverscaled: boolean | void;
isTileClipped: boolean | void;
_tileJSONRequest: ?Cancelable;

@@ -147,20 +147,13 @@ _loaded: boolean;

/**
* Reloads the source data and re-renders the map.
*
* @example
* map.getSource('source-id').reload();
*/
reload() {
this.cancelTileJSONRequest();
const clearTiles = () => {
const sourceCaches = this.map.style._getSourceCaches(this.id);
for (const sourceCache of sourceCaches) {
sourceCache.clearTiles();
}
};
this.load(clearTiles);
this.load(() => this.map.style._clearSource(this.id));
}
setSourceProperty(callback: Function) {
callback();
this.reload();
}
/**

@@ -172,3 +165,3 @@ * Sets the source `tiles` property and re-renders the map.

* @example
* map.addSource('vector_source_id', {
* map.addSource('source-id', {
* type: 'vector',

@@ -180,6 +173,4 @@ * tiles: ['https://some_end_point.net/{z}/{x}/{y}.mvt'],

*
* const vectorTileSource = map.getSource('vector_source_id');
*
* // Set the endpoint associated with a vector tile source.
* vectorTileSource.setTiles(['https://another_end_point.net/{z}/{x}/{y}.mvt']);
* map.getSource('source-id').setTiles(['https://another_end_point.net/{z}/{x}/{y}.mvt']);
*/

@@ -199,3 +190,3 @@ setTiles(tiles: Array<string>): this {

* @example
* map.addSource('vector_source_id', {
* map.addSource('source-id', {
* type: 'vector',

@@ -205,6 +196,4 @@ * url: 'mapbox://mapbox.mapbox-streets-v7'

*
* const vectorTileSource = map.getSource('vector_source_id');
*
* // Update vector tile source to a new URL endpoint
* vectorTileSource.setUrl("mapbox://mapbox.mapbox-streets-v8");
* map.getSource('source-id').setUrl("mapbox://mapbox.mapbox-streets-v8");
*/

@@ -211,0 +200,0 @@ setUrl(url: string): this {

{
"name": "@mapbox/mapbox-gl-style-spec",
"description": "a specification for mapbox gl styles",
"version": "13.28.0",
"version": "13.29.0-dev",
"author": "Mapbox",

@@ -6,0 +6,0 @@ "keywords": [

// @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';
type CustomRenderMethod = (gl: WebGLRenderingContext, matrix: Array<number>) => void;
type CustomRenderMethod = (gl: WebGLRenderingContext, matrix: Array<number>, projection: ?ProjectionSpecification, projectionToMercatorMatrix: ?Array<number>, projectionToMercatorTransition: ?number, centerInMercator: ?Array<number>, pixelsPerMeterRatio: ?number) => void;

@@ -157,2 +159,4 @@ /**

prerender: ?CustomRenderMethod,
renderToTile: ?(gl: WebGLRenderingContext, tileId: MercatorCoordinate) => void,
shouldRerenderTiles: ?() => boolean,
onAdd: ?(map: Map, gl: WebGLRenderingContext) => void,

@@ -206,2 +210,10 @@ onRemove: ?(map: Map, gl: WebGLRenderingContext) => void

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

@@ -208,0 +220,0 @@ updateTransitions() {}

@@ -73,2 +73,6 @@ // @flow

widthExpression(): StylePropertyExpression {
return this._transitionablePaint._values['line-width'].value.expression;
}
recalculate(parameters: EvaluationParameters, availableImages: Array<string>) {

@@ -75,0 +79,0 @@ super.recalculate(parameters, availableImages);

@@ -174,2 +174,5 @@ // @flow

batches.forEach(isWireframe => {
const tr = painter.transform;
const skirtHeightValue = skirtHeight(tr.zoom) * terrain.exaggeration();
// This code assumes the rendering is batched into mesh terrain and then wireframe

@@ -211,3 +214,3 @@ // terrain (if applicable) so that this is enough to ensure the correct program is

mercatorCenter, tr.frustumCorners.TL, tr.frustumCorners.TR, tr.frustumCorners.BR,
tr.frustumCorners.BL, tr.globeCenterInViewSpace, tr.globeRadius, viewport, gridMatrix);
tr.frustumCorners.BL, tr.globeCenterInViewSpace, tr.globeRadius, viewport, skirtHeightValue, gridMatrix);

@@ -223,3 +226,3 @@ setShaderMode(shaderMode, isWireframe);

sharedBuffers.getWirefameBuffers(painter.context, latitudinalLod) :
sharedBuffers.getGridBuffers(latitudinalLod);
sharedBuffers.getGridBuffers(latitudinalLod, skirtHeightValue !== 0);

@@ -260,3 +263,3 @@ program.draw(context, primitive, depthMode, stencilMode, colorMode, CullFaceMode.backCCW,

tr.frustumCorners.TL, tr.frustumCorners.TR, tr.frustumCorners.BR, tr.frustumCorners.BL,
tr.globeCenterInViewSpace, tr.globeRadius, viewport), "globe_pole_raster", vertexBuffer,
tr.globeCenterInViewSpace, tr.globeRadius, viewport, 0), "globe_pole_raster", vertexBuffer,
indexBuffer, segment);

@@ -263,0 +266,0 @@

@@ -27,2 +27,3 @@ // @flow

'u_grid_matrix': UniformMatrix3f,
'u_skirt_height': Uniform1f,
'u_frustum_tl': Uniform3f,

@@ -65,2 +66,3 @@ 'u_frustum_tr': Uniform3f,

'u_grid_matrix': new UniformMatrix3f(context),
'u_skirt_height': new Uniform1f(context),
'u_frustum_tl': new Uniform3f(context),

@@ -108,2 +110,3 @@ 'u_frustum_tr': new Uniform3f(context),

viewport: [number, number],
skirtHeight: number,
gridMatrix: ?Mat4

@@ -125,3 +128,4 @@ ): UniformValues<GlobeRasterUniformsType> => ({

'u_viewport': viewport,
'u_grid_matrix': gridMatrix ? Float32Array.from(gridMatrix) : new Float32Array(9)
'u_grid_matrix': gridMatrix ? Float32Array.from(gridMatrix) : new Float32Array(9),
'u_skirt_height': skirtHeight
});

@@ -128,0 +132,0 @@

@@ -518,5 +518,5 @@ // @flow

if (eventStarted("drag") && around) {
if ((zoomDelta || eventStarted("drag")) && around) {
this._dragOrigin = toVec3(tr.pointCoordinate3D(around));
// Construct the tracking ellipsoid every time user changes the drag origin.
// Construct the tracking ellipsoid every time user changes the zoom or drag origin.
// Direction of the ray will define size of the shape and hence defining the available range of movement

@@ -523,0 +523,0 @@ this._trackingEllipsoid.setup(tr._camera.position, this._dragOrigin);

@@ -151,3 +151,2 @@ // @flow

return finishRequest(response, cacheableResponse, requestTime);
} else {

@@ -157,7 +156,7 @@ return callback(new AJAXError(response.statusText, response.status, requestParameters.url));

}).catch(error => {
if (error.code === 20) {
if (error.name === 'AbortError') {
// silence expected AbortError
return;
}
callback(new Error(error.message));
callback(new Error(`${error.message} ${requestParameters.url}`));
});

@@ -164,0 +163,0 @@ };

@@ -131,3 +131,3 @@ // @flow

sharedCache
((sharedCache: any): Promise<Cache>)
.then(cache => {

@@ -134,0 +134,0 @@ // manually strip URL instead of `ignoreSearch: true` because of a known

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc